jenkins-bot has submitted this change and it was merged.
Change subject: (bug 56010) Parse lowercase ids in ByPropertyListUnserializer
......................................................................
(bug 56010) Parse lowercase ids in ByPropertyListUnserializer
cherry-pick from Iac8f4e7c
Change-Id: Iac8f4e7cbda907fde186532fea0fbfa4894a322b
---
M lib/includes/serializers/ByPropertyListUnserializer.php
1 file changed, 11 insertions(+), 4 deletions(-)
Approvals:
Aude: Looks good to me, approved
jenkins-bot: Verified
diff --git a/lib/includes/serializers/ByPropertyListUnserializer.php
b/lib/includes/serializers/ByPropertyListUnserializer.php
index ca99b9e..3adc3cb 100644
--- a/lib/includes/serializers/ByPropertyListUnserializer.php
+++ b/lib/includes/serializers/ByPropertyListUnserializer.php
@@ -4,6 +4,8 @@
use InvalidArgumentException;
use OutOfBoundsException;
+use Wikibase\DataModel\Entity\PropertyId;
+use Wikibase\Lib\EntityIdParser;
/**
* Serializer for Traversable objects that need to be grouped
@@ -65,19 +67,24 @@
*/
public function newFromSerialization( array $serialization ) {
$elements = array();
+ $idParser = new EntityIdParser();
foreach ( $serialization as $propertyId => $byPropId ) {
if ( !is_array( $byPropId ) ) {
throw new InvalidArgumentException( "Element
with key '$propertyId' should be an array, found " . gettype( $byPropId ) );
}
+ $propertyId = $idParser->parse( $propertyId );
+
foreach ( $byPropId as $serializedElement ) {
$element =
$this->elementUnserializer->newFromSerialization( $serializedElement );
- // FIXME: usage of deprecated method
getPrefixedId
- $elementPropertyId =
$element->getPropertyId()->getPrefixedId();
- if ( $elementPropertyId !== $propertyId ) {
- throw new OutOfBoundsException(
"Element with id '$elementPropertyId' found in list with id '$propertyId'" );
+ /** @var PropertyId $elementPropertyId */
+ $elementPropertyId = $element->getPropertyId();
+
+ if ( !$elementPropertyId->equals( $propertyId )
) {
+ throw new OutOfBoundsException(
"Element with id '" . $elementPropertyId->getSerialization() .
+ "' found in list with id '" .
$propertyId->getSerialization() . "'" );
}
$elements[] = $element;
--
To view, visit https://gerrit.wikimedia.org/r/92321
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Iac8f4e7cbda907fde186532fea0fbfa4894a322b
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: mw1.23-wmf1
Gerrit-Owner: Aude <[email protected]>
Gerrit-Reviewer: Addshore <[email protected]>
Gerrit-Reviewer: Aude <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits