WMDE-leszek has uploaded a new change for review. (
https://gerrit.wikimedia.org/r/342642 )
Change subject: Use custom-entity-type-aware entity serializer in
EntityDataSerializationService
......................................................................
Use custom-entity-type-aware entity serializer in EntityDataSerializationService
SerializerFactory from DataModel component provides the entity serializer
capable of serializing items and properties.
WikibaseRepo top-level factory in turn provides the entity serializer
able to process entities of all defined types (using serializer factory
callbacks from entity type definitions).
EntityDataSerializationService should be using the latter in order to
be able to process custom entity types like MediaInfo.
Bug: T160426
Change-Id: I6cd55f51befccaab2c7c3ec703f5a4df0f4addfd
---
M repo/includes/LinkedData/EntityDataSerializationService.php
M repo/includes/Specials/SpecialEntityData.php
M repo/tests/phpunit/includes/LinkedData/EntityDataRequestHandlerTest.php
M repo/tests/phpunit/includes/LinkedData/EntityDataSerializationServiceTest.php
M repo/tests/phpunit/includes/Specials/SpecialEntityDataTest.php
5 files changed, 20 insertions(+), 4 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase
refs/changes/42/342642/1
diff --git a/repo/includes/LinkedData/EntityDataSerializationService.php
b/repo/includes/LinkedData/EntityDataSerializationService.php
index 8dcbcde..cf93104 100644
--- a/repo/includes/LinkedData/EntityDataSerializationService.php
+++ b/repo/includes/LinkedData/EntityDataSerializationService.php
@@ -10,6 +10,7 @@
use MWException;
use PageProps;
use RequestContext;
+use Serializers\Serializer;
use SiteList;
use SiteLookup;
use Wikibase\DataModel\Entity\EntityId;
@@ -61,6 +62,11 @@
private $serializerFactory;
/**
+ * @var Serializer
+ */
+ private $entitySerializer;
+
+ /**
* @var PropertyDataTypeLookup
*/
private $propertyLookup;
@@ -109,6 +115,7 @@
* @param SiteList $sites
* @param EntityDataFormatProvider $entityDataFormatProvider
* @param SerializerFactory $serializerFactory
+ * @param Serializer $entitySerializer
* @param SiteLookup $siteLookup
* @param RdfVocabulary $rdfVocabulary
*/
@@ -121,17 +128,19 @@
SiteList $sites,
EntityDataFormatProvider $entityDataFormatProvider,
SerializerFactory $serializerFactory,
+ Serializer $entitySerializer,
SiteLookup $siteLookup,
RdfVocabulary $rdfVocabulary
) {
$this->entityLookup = $entityLookup;
$this->entityTitleLookup = $entityTitleLookup;
- $this->serializerFactory = $serializerFactory;
$this->propertyLookup = $propertyLookup;
$this->valueSnakRdfBuilderFactory = $valueSnakRdfBuilderFactory;
$this->entityRdfBuilderFactory = $entityRdfBuilderFactory;
$this->sites = $sites;
$this->entityDataFormatProvider = $entityDataFormatProvider;
+ $this->serializerFactory = $serializerFactory;
+ $this->entitySerializer = $entitySerializer;
$this->siteLookup = $siteLookup;
$this->rdfVocabulary = $rdfVocabulary;
@@ -407,7 +416,7 @@
$res,
$this->entityTitleLookup,
$this->serializerFactory,
- $this->serializerFactory->newEntitySerializer(),
+ $this->entitySerializer,
$this->siteLookup,
$this->propertyLookup,
false // Never add meta data for this service
diff --git a/repo/includes/Specials/SpecialEntityData.php
b/repo/includes/Specials/SpecialEntityData.php
index 041d951..82f680e 100644
--- a/repo/includes/Specials/SpecialEntityData.php
+++ b/repo/includes/Specials/SpecialEntityData.php
@@ -76,9 +76,12 @@
$entityIdParser = $wikibaseRepo->getEntityIdParser();
$entityDataFormatProvider = new EntityDataFormatProvider();
+
+ $serializerFactoryOptions =
SerializerFactory::OPTION_SERIALIZE_MAIN_SNAKS_WITHOUT_HASH +
+
SerializerFactory::OPTION_SERIALIZE_REFERENCE_SNAKS_WITHOUT_HASH;
+
$serializerFactory = $wikibaseRepo->getSerializerFactory(
-
SerializerFactory::OPTION_SERIALIZE_MAIN_SNAKS_WITHOUT_HASH +
-
SerializerFactory::OPTION_SERIALIZE_REFERENCE_SNAKS_WITHOUT_HASH
+ $serializerFactoryOptions
);
$serializationService = new EntityDataSerializationService(
@@ -90,6 +93,7 @@
$wikibaseRepo->getSiteLookup()->getSites(),
$entityDataFormatProvider,
$serializerFactory,
+ $wikibaseRepo->getEntitySerializer(
$serializerFactoryOptions ),
$wikibaseRepo->getSiteLookup(),
$wikibaseRepo->getRdfVocabulary()
);
diff --git
a/repo/tests/phpunit/includes/LinkedData/EntityDataRequestHandlerTest.php
b/repo/tests/phpunit/includes/LinkedData/EntityDataRequestHandlerTest.php
index e892571..3ec15fa 100644
--- a/repo/tests/phpunit/includes/LinkedData/EntityDataRequestHandlerTest.php
+++ b/repo/tests/phpunit/includes/LinkedData/EntityDataRequestHandlerTest.php
@@ -109,6 +109,7 @@
new SiteList(),
$entityDataFormatProvider,
$serializerFactory,
+ $serializerFactory->newEntitySerializer(),
new HashSiteStore(),
new RdfVocabulary(
EntityDataSerializationServiceTest::URI_BASE,
diff --git
a/repo/tests/phpunit/includes/LinkedData/EntityDataSerializationServiceTest.php
b/repo/tests/phpunit/includes/LinkedData/EntityDataSerializationServiceTest.php
index b45b97f..66a2f7a 100644
---
a/repo/tests/phpunit/includes/LinkedData/EntityDataSerializationServiceTest.php
+++
b/repo/tests/phpunit/includes/LinkedData/EntityDataSerializationServiceTest.php
@@ -112,6 +112,7 @@
new SiteList(),
new EntityDataFormatProvider(),
$serializerFactory,
+ $serializerFactory->newEntitySerializer(),
new HashSiteStore(),
new RdfVocabulary( self::URI_BASE, self::URI_DATA )
);
diff --git a/repo/tests/phpunit/includes/Specials/SpecialEntityDataTest.php
b/repo/tests/phpunit/includes/Specials/SpecialEntityDataTest.php
index 3da2042..a59861a 100644
--- a/repo/tests/phpunit/includes/Specials/SpecialEntityDataTest.php
+++ b/repo/tests/phpunit/includes/Specials/SpecialEntityDataTest.php
@@ -92,6 +92,7 @@
new SiteList(),
$entityDataFormatProvider,
$serializerFactory,
+ $serializerFactory->newEntitySerializer(),
new HashSiteStore(),
new RdfVocabulary( self::URI_BASE, self::URI_DATA )
);
--
To view, visit https://gerrit.wikimedia.org/r/342642
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I6cd55f51befccaab2c7c3ec703f5a4df0f4addfd
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: WMDE-leszek <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits