Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/EntityImporterFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public function newEntityImporter() {
$this->getApiEntityLookup(),
$this->entityStore,
$this->getImportedEntityMappingStore(),
new PagePropsStatementCountLookup( $this->loadBalancer ),
new PagePropsStatementCountLookup( $this->loadBalancer, $this->getEntityNamespaceLookup() ),
$this->logger
);
}
Expand Down Expand Up @@ -127,6 +127,12 @@ private function newSerializerFactory() {
new DataValueSerializer()
);
}

private function getEntityNamespaceLookup() {
$wikibaseRepo = WikibaseRepo::getDefaultInstance();

return $wikibaseRepo->getEntityNamespaceLookup();
}
}

$maintClass = "Wikibase\Import\Maintenance\ImportEntities";
Expand Down
12 changes: 9 additions & 3 deletions src/PagePropsStatementCountLookup.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,21 @@

namespace Wikibase\Import;

use Exception;
use LoadBalancer;
use Wikibase\DataModel\Entity\EntityId;
use Wikibase\Lib\Store\EntityNamespaceLookup;
use Wikibase\Repo\WikibaseRepo;

class PagePropsStatementCountLookup implements StatementsCountLookup {

private $loadBalancer;

public function __construct( LoadBalancer $loadBalancer ) {
private $lookup;

public function __construct( LoadBalancer $loadBalancer, EntityNamespaceLookup $lookup ) {
$this->loadBalancer = $loadBalancer;
$this->lookup = $lookup;
}

public function getStatementCount( EntityId $entityId ) {
Expand All @@ -20,7 +26,7 @@ public function getStatementCount( EntityId $entityId ) {
array( 'page_props', 'page' ),
array( 'pp_value' ),
array(
'page_namespace' => 0,
'page_namespace' => $this->lookup->getEntityNamespace( $entityId->getEntityType() ),
'page_title' => $entityId->getSerialization(),
'pp_propname' => 'wb-claims'
),
Expand All @@ -32,7 +38,7 @@ public function getStatementCount( EntityId $entityId ) {
$this->loadBalancer->closeConnection( $db );

if ( $res === false ) {
return 0;
throw new Exception( 'Could not find entity ' . $entityId->getSerialization() . ' in page_props!' );
}

return (int)$res->pp_value;
Expand Down