From 07008042feb2c011d8515a9b96b9a5ba9c00b8da Mon Sep 17 00:00:00 2001 From: "John R. D'Orazio" Date: Sun, 21 May 2023 23:35:18 +0200 Subject: [PATCH 1/5] deprecated see https://phabricator.wikimedia.org/T280984 --- maintenance/importEntities.php | 4 ++-- src/EntityImporterFactory.php | 8 ++------ tests/integration/ApiEntityLookupIntegrationTest.php | 2 +- tests/integration/EntityImporterFactoryTest.php | 2 +- 4 files changed, 6 insertions(+), 10 deletions(-) diff --git a/maintenance/importEntities.php b/maintenance/importEntities.php index b294662..7d7571e 100644 --- a/maintenance/importEntities.php +++ b/maintenance/importEntities.php @@ -109,7 +109,7 @@ private function newEntityIdListBuilderFactory() { ); return new EntityIdListBuilderFactory( - WikibaseRepo::getDefaultInstance()->getEntityIdParser(), + WikibaseRepo::getEntityIdParser(), new PropertyIdLister(), $queryRunner, $this->getConfig()->get( 'WBImportSourceApi' ) @@ -118,7 +118,7 @@ private function newEntityIdListBuilderFactory() { private function newEntityImporter() { $entityImporterFactory = new EntityImporterFactory( - WikibaseRepo::getDefaultInstance()->getStore()->getEntityStore(), + WikibaseRepo::getEntityStore(), wfGetLB(), $this->logger, $this->getConfig()->get( 'WBImportSourceApi' ) diff --git a/src/EntityImporterFactory.php b/src/EntityImporterFactory.php index 18b06c6..123b9a9 100644 --- a/src/EntityImporterFactory.php +++ b/src/EntityImporterFactory.php @@ -103,11 +103,9 @@ private function newStatementsImporter() { private function getImportedEntityMappingStore() { if ( $this->importedEntityMappingStore === null ) { - $wikibaseRepo = WikibaseRepo::getDefaultInstance(); - $this->importedEntityMappingStore = new DBImportedEntityMappingStore( $this->loadBalancer, - $wikibaseRepo->getEntityIdParser() + WikibaseRepo::getEntityIdParser() ); } @@ -115,9 +113,7 @@ private function getImportedEntityMappingStore() { } private function newEntityDeserializer() { - $wikibaseRepo = WikibaseRepo::getDefaultInstance(); - - $deserializerFactory = $wikibaseRepo->getBaseDataModelDeserializerFactory(); + $deserializerFactory = WikibaseRepo::getBaseDataModelDeserializerFactory(); return $deserializerFactory->newEntityDeserializer(); } diff --git a/tests/integration/ApiEntityLookupIntegrationTest.php b/tests/integration/ApiEntityLookupIntegrationTest.php index 42914e9..db9c657 100644 --- a/tests/integration/ApiEntityLookupIntegrationTest.php +++ b/tests/integration/ApiEntityLookupIntegrationTest.php @@ -35,7 +35,7 @@ public function testGetEntity() { private function getApiEntityLookup() { $entityImporterFactory = new EntityImporterFactory( - WikibaseRepo::getDefaultInstance()->getStore()->getEntityStore(), + WikibaseRepo::getEntityStore(), wfGetLB(), $this->newLogger(), 'https://www.wikidata.org/w/api.php' diff --git a/tests/integration/EntityImporterFactoryTest.php b/tests/integration/EntityImporterFactoryTest.php index 0878fc6..b40a3ba 100644 --- a/tests/integration/EntityImporterFactoryTest.php +++ b/tests/integration/EntityImporterFactoryTest.php @@ -31,7 +31,7 @@ public function testGetApiEntityLookup() { private function newEntityImporterFactory() { return new EntityImporterFactory( - WikibaseRepo::getDefaultInstance()->getStore()->getEntityStore(), + WikibaseRepo::getEntityStore(), wfGetLB(), $this->newLogger(), 'https://www.wikidata.org/w/api.php' From 60035b25eac211438754248f7982a5f303b4dead Mon Sep 17 00:00:00 2001 From: "John R. D'Orazio" Date: Sun, 21 May 2023 23:49:02 +0200 Subject: [PATCH 2/5] deprecated use MediaWikiServices::getDBLoadBalancer(), see https://doc.wikimedia.org/mediawiki-core/1.28.0/php/GlobalFunctions_8php.html#ac754ed03dae548a273d73ecae876a8ca --- maintenance/importEntities.php | 2 +- tests/integration/ApiEntityLookupIntegrationTest.php | 2 +- tests/integration/EntityImporterFactoryTest.php | 2 +- tests/integration/Store/DBImportedEntityMappingStoreTest.php | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/maintenance/importEntities.php b/maintenance/importEntities.php index 7d7571e..9880633 100644 --- a/maintenance/importEntities.php +++ b/maintenance/importEntities.php @@ -119,7 +119,7 @@ private function newEntityIdListBuilderFactory() { private function newEntityImporter() { $entityImporterFactory = new EntityImporterFactory( WikibaseRepo::getEntityStore(), - wfGetLB(), + MediaWikiServices::getDBLoadBalancer(), $this->logger, $this->getConfig()->get( 'WBImportSourceApi' ) ); diff --git a/tests/integration/ApiEntityLookupIntegrationTest.php b/tests/integration/ApiEntityLookupIntegrationTest.php index db9c657..5312d11 100644 --- a/tests/integration/ApiEntityLookupIntegrationTest.php +++ b/tests/integration/ApiEntityLookupIntegrationTest.php @@ -36,7 +36,7 @@ public function testGetEntity() { private function getApiEntityLookup() { $entityImporterFactory = new EntityImporterFactory( WikibaseRepo::getEntityStore(), - wfGetLB(), + MediaWikiServices::getDBLoadBalancer(), $this->newLogger(), 'https://www.wikidata.org/w/api.php' ); diff --git a/tests/integration/EntityImporterFactoryTest.php b/tests/integration/EntityImporterFactoryTest.php index b40a3ba..83ad5f6 100644 --- a/tests/integration/EntityImporterFactoryTest.php +++ b/tests/integration/EntityImporterFactoryTest.php @@ -32,7 +32,7 @@ public function testGetApiEntityLookup() { private function newEntityImporterFactory() { return new EntityImporterFactory( WikibaseRepo::getEntityStore(), - wfGetLB(), + MediaWikiServices::getDBLoadBalancer(), $this->newLogger(), 'https://www.wikidata.org/w/api.php' ); diff --git a/tests/integration/Store/DBImportedEntityMappingStoreTest.php b/tests/integration/Store/DBImportedEntityMappingStoreTest.php index 77daf21..dabc2d5 100644 --- a/tests/integration/Store/DBImportedEntityMappingStoreTest.php +++ b/tests/integration/Store/DBImportedEntityMappingStoreTest.php @@ -45,7 +45,7 @@ public function testGetOriginalId() { private function newDBImportedEntityMappingStore() { return new DBImportedEntityMappingStore( - wfGetLB(), + MediaWikiServices::getDBLoadBalancer(), new BasicEntityIdParser() ); } From 3e5e1adbed29b28040937f0959e27faf08ca3abe Mon Sep 17 00:00:00 2001 From: "John R. D'Orazio" Date: Sun, 21 May 2023 23:53:03 +0200 Subject: [PATCH 3/5] use MediaWiki\MediaWikiServices --- maintenance/importEntities.php | 1 + tests/integration/ApiEntityLookupIntegrationTest.php | 1 + tests/integration/EntityImporterFactoryTest.php | 1 + tests/integration/Store/DBImportedEntityMappingStoreTest.php | 1 + 4 files changed, 4 insertions(+) diff --git a/maintenance/importEntities.php b/maintenance/importEntities.php index 9880633..475493b 100644 --- a/maintenance/importEntities.php +++ b/maintenance/importEntities.php @@ -13,6 +13,7 @@ use Wikibase\Import\QueryRunner; use Wikibase\Import\PropertyIdLister; use Wikibase\Repo\WikibaseRepo; +use MediaWiki\MediaWikiServices; $IP = getenv( 'MW_INSTALL_PATH' ); if ( $IP === false ) { diff --git a/tests/integration/ApiEntityLookupIntegrationTest.php b/tests/integration/ApiEntityLookupIntegrationTest.php index 5312d11..2093018 100644 --- a/tests/integration/ApiEntityLookupIntegrationTest.php +++ b/tests/integration/ApiEntityLookupIntegrationTest.php @@ -8,6 +8,7 @@ use Wikibase\DataModel\Entity\PropertyId; use Wikibase\Import\EntityImporterFactory; use Wikibase\Repo\WikibaseRepo; +use MediaWiki\MediaWikiServices; /** * @group WikibaseImport diff --git a/tests/integration/EntityImporterFactoryTest.php b/tests/integration/EntityImporterFactoryTest.php index 83ad5f6..c79c371 100644 --- a/tests/integration/EntityImporterFactoryTest.php +++ b/tests/integration/EntityImporterFactoryTest.php @@ -7,6 +7,7 @@ use Wikibase\Import\EntityImporter; use Wikibase\Import\EntityImporterFactory; use Wikibase\Repo\WikibaseRepo; +use MediaWiki\MediaWikiServices; /** * @group WikibaseImport diff --git a/tests/integration/Store/DBImportedEntityMappingStoreTest.php b/tests/integration/Store/DBImportedEntityMappingStoreTest.php index dabc2d5..5c3d49f 100644 --- a/tests/integration/Store/DBImportedEntityMappingStoreTest.php +++ b/tests/integration/Store/DBImportedEntityMappingStoreTest.php @@ -6,6 +6,7 @@ use Wikibase\DataModel\Entity\ItemId; use Wikibase\DataModel\Entity\PropertyId; use Wikibase\Import\Store\DBImportedEntityMappingStore; +use MediaWiki\MediaWikiServices; /** * @group WikibaseImport From 3ba2a8aec547bf659be344829d740c88e805115b Mon Sep 17 00:00:00 2001 From: "John R. D'Orazio" Date: Sun, 21 May 2023 23:57:06 +0200 Subject: [PATCH 4/5] fix non-static method getDBLoadBalancer --- maintenance/importEntities.php | 2 +- tests/integration/ApiEntityLookupIntegrationTest.php | 2 +- tests/integration/EntityImporterFactoryTest.php | 2 +- tests/integration/Store/DBImportedEntityMappingStoreTest.php | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/maintenance/importEntities.php b/maintenance/importEntities.php index 475493b..e7013bf 100644 --- a/maintenance/importEntities.php +++ b/maintenance/importEntities.php @@ -120,7 +120,7 @@ private function newEntityIdListBuilderFactory() { private function newEntityImporter() { $entityImporterFactory = new EntityImporterFactory( WikibaseRepo::getEntityStore(), - MediaWikiServices::getDBLoadBalancer(), + MediaWikiServices::getInstance()->getDBLoadBalancer(), $this->logger, $this->getConfig()->get( 'WBImportSourceApi' ) ); diff --git a/tests/integration/ApiEntityLookupIntegrationTest.php b/tests/integration/ApiEntityLookupIntegrationTest.php index 2093018..1bcb772 100644 --- a/tests/integration/ApiEntityLookupIntegrationTest.php +++ b/tests/integration/ApiEntityLookupIntegrationTest.php @@ -37,7 +37,7 @@ public function testGetEntity() { private function getApiEntityLookup() { $entityImporterFactory = new EntityImporterFactory( WikibaseRepo::getEntityStore(), - MediaWikiServices::getDBLoadBalancer(), + MediaWikiServices::getInstance()->getDBLoadBalancer(), $this->newLogger(), 'https://www.wikidata.org/w/api.php' ); diff --git a/tests/integration/EntityImporterFactoryTest.php b/tests/integration/EntityImporterFactoryTest.php index c79c371..7074f25 100644 --- a/tests/integration/EntityImporterFactoryTest.php +++ b/tests/integration/EntityImporterFactoryTest.php @@ -33,7 +33,7 @@ public function testGetApiEntityLookup() { private function newEntityImporterFactory() { return new EntityImporterFactory( WikibaseRepo::getEntityStore(), - MediaWikiServices::getDBLoadBalancer(), + MediaWikiServices::getInstance()->getDBLoadBalancer(), $this->newLogger(), 'https://www.wikidata.org/w/api.php' ); diff --git a/tests/integration/Store/DBImportedEntityMappingStoreTest.php b/tests/integration/Store/DBImportedEntityMappingStoreTest.php index 5c3d49f..31c14ca 100644 --- a/tests/integration/Store/DBImportedEntityMappingStoreTest.php +++ b/tests/integration/Store/DBImportedEntityMappingStoreTest.php @@ -46,7 +46,7 @@ public function testGetOriginalId() { private function newDBImportedEntityMappingStore() { return new DBImportedEntityMappingStore( - MediaWikiServices::getDBLoadBalancer(), + MediaWikiServices::getInstance()->getDBLoadBalancer(), new BasicEntityIdParser() ); } From cf5ec0d757a2eed2a74a0d24d1e12df5b0082016 Mon Sep 17 00:00:00 2001 From: "John R. D'Orazio" Date: Mon, 22 May 2023 00:09:28 +0200 Subject: [PATCH 5/5] SerializerFactory now under Serializers --- src/EntityImporterFactory.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/EntityImporterFactory.php b/src/EntityImporterFactory.php index 123b9a9..fcf9a63 100644 --- a/src/EntityImporterFactory.php +++ b/src/EntityImporterFactory.php @@ -5,8 +5,8 @@ use DataValues\Serializers\DataValueSerializer; use LoadBalancer; use Psr\Log\LoggerInterface; -use Wikibase\DataModel\DeserializerFactory; -use Wikibase\DataModel\SerializerFactory; +use Wikibase\DataModel\Serializers\DeserializerFactory; +use Wikibase\DataModel\Serializers\SerializerFactory; use Wikibase\Lib\Store\EntityStore; use Wikibase\Import\Store\DBImportedEntityMappingStore; use Wikibase\Import\Store\ImportedEntityMappingStore;