jenkins-bot has submitted this change and it was merged. Change subject: Replace deprecated getPrefixedId in Client and Lib ......................................................................
Replace deprecated getPrefixedId in Client and Lib In case you wonder, the removed method is unused and broken anyway. Change-Id: I6fa896855890d4195663a946a9a67356ee47a3f6 --- M client/includes/ChangeHandler.php M client/includes/LangLinkHandler.php M lib/includes/changes/EntityChangeFactory.php M lib/includes/formatters/EntityIdHtmlLinkFormatter.php M lib/includes/formatters/EntityIdLabelFormatter.php M lib/includes/serializers/ByPropertyListSerializer.php M lib/includes/serializers/ClaimSerializer.php M lib/includes/serializers/EntitySerializer.php M lib/includes/serializers/ReferenceSerializer.php M lib/includes/serializers/SnakSerializer.php M lib/includes/store/sql/SiteLinkTable.php M lib/includes/store/sql/SqlEntityInfoBuilder.php M lib/includes/store/sql/TermSqlIndex.php M lib/tests/phpunit/ChangesTableTest.php M lib/tests/phpunit/MockRepository.php M lib/tests/phpunit/MockRepositoryTest.php M lib/tests/phpunit/changes/EntityChangeTest.php M lib/tests/phpunit/formatters/EntityIdLinkFormatterTest.php M lib/tests/phpunit/formatters/EntityIdTitleFormatterTest.php M lib/tests/phpunit/formatters/WikibaseSnakFormatterBuildersTest.php M lib/tests/phpunit/formatters/WikibaseValueFormatterBuildersTest.php 21 files changed, 41 insertions(+), 70 deletions(-) Approvals: Bene: Looks good to me, approved jenkins-bot: Verified diff --git a/client/includes/ChangeHandler.php b/client/includes/ChangeHandler.php index 9601647..4fc108c 100644 --- a/client/includes/ChangeHandler.php +++ b/client/includes/ChangeHandler.php @@ -211,7 +211,7 @@ $groups = array(); foreach ( $changes as $change ) { - $id = $change->getEntityId()->getPrefixedId(); + $id = $change->getEntityId()->getSerialization(); if ( !isset( $groups[$id] ) ) { $groups[$id] = array(); @@ -466,8 +466,6 @@ return 0; } - - // ========================================================================================== /** * Handle the provided changes. diff --git a/client/includes/LangLinkHandler.php b/client/includes/LangLinkHandler.php index 1da6aa2..cc93b8b 100644 --- a/client/includes/LangLinkHandler.php +++ b/client/includes/LangLinkHandler.php @@ -120,8 +120,8 @@ $itemId = $this->getItemIdForTitle( $title ); if ( $itemId !== null ) { - wfDebugLog( __CLASS__, __FUNCTION__ . ": Item ID for " . $title->getFullText() - . " is " . $itemId->getPrefixedId() ); + wfDebugLog( __CLASS__, __FUNCTION__ . ': Item ID for ' . $title->getFullText() + . ' is ' . $itemId->getSerialization() ); //NOTE: SiteLinks we could get from $this->siteLinkLookup do not contain badges, // so we have to fetch the links from the Item. diff --git a/lib/includes/changes/EntityChangeFactory.php b/lib/includes/changes/EntityChangeFactory.php index ec39d86..7f24474 100644 --- a/lib/includes/changes/EntityChangeFactory.php +++ b/lib/includes/changes/EntityChangeFactory.php @@ -49,7 +49,6 @@ $this->entityFactory = $entityFactory; } - /** * @since 0.5 * @@ -76,7 +75,7 @@ ); if ( !$instance->hasField( 'object_id' ) ) { - $instance->setField( 'object_id', $entityId->getPrefixedId() ); + $instance->setField( 'object_id', $entityId->getSerialization() ); } if ( !$instance->hasField( 'info' ) ) { diff --git a/lib/includes/formatters/EntityIdHtmlLinkFormatter.php b/lib/includes/formatters/EntityIdHtmlLinkFormatter.php index a3a6b0f..b813795 100644 --- a/lib/includes/formatters/EntityIdHtmlLinkFormatter.php +++ b/lib/includes/formatters/EntityIdHtmlLinkFormatter.php @@ -47,14 +47,14 @@ if ( isset( $this->entityTitleLookup ) ) { $title = $this->entityTitleLookup->getTitleForId( $entityId ); } else { - $title = Title::newFromText( $entityId->getPrefixedId() ); + $title = Title::newFromText( $entityId->getSerialization() ); } $attributes = array( 'title' => $title->getPrefixedText(), 'href' => $title->getLocalURL() ); - $label = $entityId->getPrefixedId(); + $label = $entityId->getSerialization(); if ( $this->getOption( self::OPT_LOOKUP_LABEL ) ) { try { diff --git a/lib/includes/formatters/EntityIdLabelFormatter.php b/lib/includes/formatters/EntityIdLabelFormatter.php index d7e242b..b3c1d9f 100644 --- a/lib/includes/formatters/EntityIdLabelFormatter.php +++ b/lib/includes/formatters/EntityIdLabelFormatter.php @@ -100,7 +100,7 @@ if ( !is_string( $label ) ) { switch ( $this->getOption( self::OPT_LABEL_FALLBACK ) ) { case self::FALLBACK_PREFIXED_ID: - $label = $entityId->getPrefixedId(); + $label = $entityId->getSerialization(); break; case self::FALLBACK_EMPTY_STRING: $label = ''; diff --git a/lib/includes/serializers/ByPropertyListSerializer.php b/lib/includes/serializers/ByPropertyListSerializer.php index ef758d4..86bce1a 100644 --- a/lib/includes/serializers/ByPropertyListSerializer.php +++ b/lib/includes/serializers/ByPropertyListSerializer.php @@ -83,11 +83,11 @@ $this->setIndexedTagName( $serializedObjects, $this->elementName ); if ( $this->options->shouldIndexTags() ) { - $serializedObjects['id'] = $propertyId->getPrefixedId(); + $serializedObjects['id'] = $propertyId->getSerialization(); $serialization[] = $serializedObjects; } else { - $key = $propertyId->getPrefixedId(); + $key = $propertyId->getSerialization(); if ( $this->getOptions()->shouldUseUpperCaseIdsAsKeys() ) { $key = strtoupper( $key ); diff --git a/lib/includes/serializers/ClaimSerializer.php b/lib/includes/serializers/ClaimSerializer.php index 6685701..7f3d36f 100644 --- a/lib/includes/serializers/ClaimSerializer.php +++ b/lib/includes/serializers/ClaimSerializer.php @@ -117,9 +117,9 @@ $serialization['qualifiers-order'] = array(); /** @var Snak $snak */ foreach( $claim->getQualifiers() as $snak ) { - $id = $snak->getPropertyId()->getPrefixedId(); + $id = $snak->getPropertyId()->getSerialization(); if ( !in_array( $id, $serialization['qualifiers-order'] ) ) { - $serialization['qualifiers-order'][] = $snak->getPropertyId()->getPrefixedId(); + $serialization['qualifiers-order'][] = $snak->getPropertyId()->getSerialization(); } } $this->setIndexedTagName( $serialization['qualifiers-order'], 'property' ); diff --git a/lib/includes/serializers/EntitySerializer.php b/lib/includes/serializers/EntitySerializer.php index 30cb111..9d94a17 100644 --- a/lib/includes/serializers/EntitySerializer.php +++ b/lib/includes/serializers/EntitySerializer.php @@ -120,7 +120,7 @@ } //NOTE: when changing the serialization structure, update docs/json.wiki too! - $serialization['id'] = $entity->getId() ? $entity->getId()->getPrefixedId() : ''; + $serialization['id'] = $entity->getId() ? $entity->getId()->getSerialization() : ''; $serialization['type'] = $entity->getType(); diff --git a/lib/includes/serializers/ReferenceSerializer.php b/lib/includes/serializers/ReferenceSerializer.php index 8c76fe8..1ef95de 100644 --- a/lib/includes/serializers/ReferenceSerializer.php +++ b/lib/includes/serializers/ReferenceSerializer.php @@ -72,7 +72,7 @@ $serialization['snaks-order'] = array(); /** @var Snak $snak */ foreach( $snaks as $snak ) { - $id = $snak->getPropertyId()->getPrefixedId(); + $id = $snak->getPropertyId()->getSerialization(); if( !in_array( $id, $serialization['snaks-order'] ) ) { $serialization['snaks-order'][] = $id; } diff --git a/lib/includes/serializers/SnakSerializer.php b/lib/includes/serializers/SnakSerializer.php index b5245e3..4d40c3d 100644 --- a/lib/includes/serializers/SnakSerializer.php +++ b/lib/includes/serializers/SnakSerializer.php @@ -4,11 +4,11 @@ use DataValues\DataValueFactory; use InvalidArgumentException; +use Wikibase\DataModel\Entity\PropertyDataTypeLookup; use Wikibase\DataModel\Entity\PropertyId; +use Wikibase\DataModel\Entity\PropertyNotFoundException; use Wikibase\DataModel\Snak\PropertyValueSnak; use Wikibase\DataModel\Snak\Snak; -use Wikibase\DataModel\Entity\PropertyDataTypeLookup; -use Wikibase\DataModel\Entity\PropertyNotFoundException; /** * Serializer for Snak objects. @@ -63,6 +63,7 @@ //NOTE: when changing the serialization structure, update docs/json.wiki too! $serialization = array(); + $propertyId = $snak->getPropertyId(); if( $this->options->hasOption( SerializationOptions::OPT_SERIALIZE_SNAKS_WITH_HASH ) && $this->options->getOption( SerializationOptions::OPT_SERIALIZE_SNAKS_WITH_HASH ) @@ -72,12 +73,10 @@ } $serialization['snaktype'] = $snak->getType(); - - $serialization['property'] = $snak->getPropertyId()->getPrefixedId(); + $serialization['property'] = $propertyId->getSerialization(); if ( $snak instanceof PropertyValueSnak ) { if ( $this->dataTypeLookup !== null ) { - $propertyId = $snak->getPropertyId(); try { $serialization['datatype'] = $this->dataTypeLookup->getDataTypeIdForProperty( $propertyId ); } catch ( PropertyNotFoundException $ex ) { diff --git a/lib/includes/store/sql/SiteLinkTable.php b/lib/includes/store/sql/SiteLinkTable.php index f2aaa45..06eb099 100644 --- a/lib/includes/store/sql/SiteLinkTable.php +++ b/lib/includes/store/sql/SiteLinkTable.php @@ -145,7 +145,7 @@ public function insertLinksInternal( Item $item, $links, DatabaseBase $dbw ) { wfProfileIn( __METHOD__ ); - wfDebugLog( __CLASS__, __FUNCTION__ . ": inserting links for " . $item->getId()->getPrefixedId() ); + wfDebugLog( __CLASS__, __FUNCTION__ . ': inserting links for ' . $item->getId()->getSerialization() ); $success = true; foreach ( $links as $link ) { @@ -186,7 +186,7 @@ public function deleteLinksInternal( Item $item, $links, DatabaseBase $dbw ) { wfProfileIn( __METHOD__ ); - wfDebugLog( __CLASS__, __FUNCTION__ . ": deleting links for " . $item->getId()->getPrefixedId() ); + wfDebugLog( __CLASS__, __FUNCTION__ . ': deleting links for ' . $item->getId()->getSerialization() ); //TODO: We can do this in a single query by collecting all the site IDs into a set. diff --git a/lib/includes/store/sql/SqlEntityInfoBuilder.php b/lib/includes/store/sql/SqlEntityInfoBuilder.php index bfad64f..8d6c469 100644 --- a/lib/includes/store/sql/SqlEntityInfoBuilder.php +++ b/lib/includes/store/sql/SqlEntityInfoBuilder.php @@ -493,7 +493,7 @@ private function injectDataTypes( ResultWrapper $dbResult ) { foreach ( $dbResult as $row ) { $id = PropertyId::newFromNumber( (int)$row->pi_property_id ); - $key = $id->getPrefixedId(); + $key = $id->getSerialization(); if ( !isset( $this->entityInfo[$key] ) ) { continue; diff --git a/lib/includes/store/sql/TermSqlIndex.php b/lib/includes/store/sql/TermSqlIndex.php index 7973bd3..689cbfe 100644 --- a/lib/includes/store/sql/TermSqlIndex.php +++ b/lib/includes/store/sql/TermSqlIndex.php @@ -141,7 +141,7 @@ 'term_entity_type' => $entity->getId()->getEntityType() ); - wfDebugLog( __CLASS__, __FUNCTION__ . ": inserting terms for " . $entity->getId()->getPrefixedId() ); + wfDebugLog( __CLASS__, __FUNCTION__ . ': inserting terms for ' . $entity->getId()->getSerialization() ); $weightField = array(); if ( $this->supportsWeight() ) { @@ -245,7 +245,7 @@ $uniqueKeyFields = array( 'term_entity_type', 'term_entity_id', 'term_language', 'term_type', 'term_text' ); - wfDebugLog( __CLASS__, __FUNCTION__ . ": deleting terms for " . $entity->getId()->getPrefixedId() ); + wfDebugLog( __CLASS__, __FUNCTION__ . ': deleting terms for ' . $entity->getId()->getSerialization() ); $success = true; foreach ( $terms as $term ) { @@ -417,7 +417,7 @@ $numericIds = array(); foreach ( $ids as $id ) { if ( $id->getEntityType() !== $entityType ) { - throw new MWException( "ID " . $id->getPrefixedId() + throw new MWException( 'ID ' . $id->getSerialization() . " does not refer to an entity of type $entityType." ); } diff --git a/lib/tests/phpunit/ChangesTableTest.php b/lib/tests/phpunit/ChangesTableTest.php index 2795c11..fc5221e 100644 --- a/lib/tests/phpunit/ChangesTableTest.php +++ b/lib/tests/phpunit/ChangesTableTest.php @@ -80,7 +80,7 @@ 'time' => '20120101000000', 'user_id' => $wgUser->getId(), 'revision_id' => 9001, - 'object_id' => $id->getPrefixedId(), + 'object_id' => $id->getSerialization(), 'info' => array( 'diff' => $diff1, ) @@ -93,7 +93,7 @@ 'time' => '20120101000005', 'user_id' => $wgUser->getId(), 'revision_id' => 9002, - 'object_id' => $id->getPrefixedId(), + 'object_id' => $id->getSerialization(), 'info' => array( 'diff' => $diff2, ) diff --git a/lib/tests/phpunit/MockRepository.php b/lib/tests/phpunit/MockRepository.php index 5a93978..f644b3c 100644 --- a/lib/tests/phpunit/MockRepository.php +++ b/lib/tests/phpunit/MockRepository.php @@ -5,7 +5,6 @@ use DatabaseBase; use Status; use User; -use Wikibase\DataModel\Claim\Claims; use Wikibase\DataModel\Entity\BasicEntityIdParser; use Wikibase\DataModel\Entity\Entity; use Wikibase\DataModel\Entity\EntityId; @@ -14,9 +13,9 @@ use Wikibase\DataModel\Entity\Property; use Wikibase\DataModel\Entity\PropertyDataTypeLookup; use Wikibase\DataModel\Entity\PropertyId; +use Wikibase\DataModel\Entity\PropertyNotFoundException; use Wikibase\DataModel\SiteLink; use Wikibase\EntityRevision; -use Wikibase\DataModel\Entity\PropertyNotFoundException; use Wikibase\Lib\Store\EntityInfoBuilderFactory; use Wikibase\Lib\Store\EntityLookup; use Wikibase\Lib\Store\EntityRedirect; @@ -116,7 +115,7 @@ * @throw StorageException */ public function getEntityRevision( EntityId $entityId, $revision = 0 ) { - $key = $entityId->getPrefixedId(); + $key = $entityId->getSerialization(); if ( isset( $this->redirects[$key] ) ) { throw new UnresolvedRedirectException( $this->redirects[$key]->getTargetId() ); @@ -326,7 +325,7 @@ $this->registerSiteLinks( $entity ); } - $key = $entity->getId()->getPrefixedId(); + $key = $entity->getId()->getSerialization(); if ( !array_key_exists( $key, $this->entities ) ) { $this->entities[$key] = array(); @@ -397,7 +396,7 @@ $oldEntity = null; // ignore } - $key = $id->getPrefixedId(); + $key = $id->getSerialization(); unset( $this->entities[$key] ); unset( $this->redirects[$key] ); @@ -528,12 +527,11 @@ $entities = array(); foreach ( $entityIds as $entityId ) { - if ( is_string( $entityId ) ) { $entityId = $this->parseId( $entityId ); } - $entities[$entityId->getPrefixedId()] = $this->getEntity( $entityId ); + $entities[$entityId->getSerialization()] = $this->getEntity( $entityId ); } return $entities; @@ -561,31 +559,6 @@ // FIXME: throw InvalidArgumentException rather then failing silently return array(); - } - - /** - * Returns these claims from the given entity that have a main Snak for the property - * identified by $propertyLabel in the language given by $langCode. - * - * @since 0.4 - * - * @param Entity $entity - * @param string $propertyLabel - * @param string $langCode - * - * @return Claims - */ - public function getClaimsByPropertyLabel( Entity $entity, $propertyLabel, $langCode ) { - $prop = $this->getPropertyByLabel( $propertyLabel, $langCode ); - - if ( !$prop ) { - return new Claims(); - } - - $allClaims = new Claims( $entity->getClaims() ); - $theClaims = $allClaims->getClaimsForProperty( $prop->getId()->getNumericId() ); - - return $theClaims; } public function getPropertyByLabel( $propertyLabel, $langCode ) { @@ -756,7 +729,7 @@ * @return bool */ public function userWasLastToEdit( User $user, EntityId $id, $lastRevId ) { - $key = $id->getPrefixedId(); + $key = $id->getSerialization(); if ( !isset( $this->entities[$key] ) ) { return false; } @@ -879,4 +852,5 @@ return null; } + } diff --git a/lib/tests/phpunit/MockRepositoryTest.php b/lib/tests/phpunit/MockRepositoryTest.php index 38f92bb..568eec5 100644 --- a/lib/tests/phpunit/MockRepositoryTest.php +++ b/lib/tests/phpunit/MockRepositoryTest.php @@ -436,7 +436,7 @@ $actual = array(); foreach ( $entities as $key => $e ) { if ( is_object( $e ) ) { - $actual[ $e->getId()->getPrefixedId() ] = $e->getLabels(); + $actual[ $e->getId()->getSerialization() ] = $e->getLabels(); } else { $actual[ $key ] = $e; } diff --git a/lib/tests/phpunit/changes/EntityChangeTest.php b/lib/tests/phpunit/changes/EntityChangeTest.php index 9b5ac73..ae521e3 100644 --- a/lib/tests/phpunit/changes/EntityChangeTest.php +++ b/lib/tests/phpunit/changes/EntityChangeTest.php @@ -179,7 +179,7 @@ public function testToString( EntityChange $entityChange ) { $s = "$entityChange"; // magically calls __toString() - $id = $entityChange->getEntityId()->getPrefixedId(); + $id = $entityChange->getEntityId()->getSerialization(); $type = $entityChange->getType(); $this->assertTrue( stripos( $s, $id ) !== false, "missing entity ID $id" ); diff --git a/lib/tests/phpunit/formatters/EntityIdLinkFormatterTest.php b/lib/tests/phpunit/formatters/EntityIdLinkFormatterTest.php index 18d21de..4c5ecc9 100644 --- a/lib/tests/phpunit/formatters/EntityIdLinkFormatterTest.php +++ b/lib/tests/phpunit/formatters/EntityIdLinkFormatterTest.php @@ -60,9 +60,9 @@ public function getTitleForId( EntityId $id ) { if ( $id->getEntityType() === Item::ENTITY_TYPE ) { - $name = 'ITEM-TEST--' . $id->getPrefixedId(); + $name = 'ITEM-TEST--' . $id->getSerialization(); } elseif ( $id->getEntityType() === Property::ENTITY_TYPE ) { - $name = 'PROPERTY-TEST--' . $id->getPrefixedId(); + $name = 'PROPERTY-TEST--' . $id->getSerialization(); } else { throw new LogicException( "oops!" ); } diff --git a/lib/tests/phpunit/formatters/EntityIdTitleFormatterTest.php b/lib/tests/phpunit/formatters/EntityIdTitleFormatterTest.php index fe98b0c..970adf0 100644 --- a/lib/tests/phpunit/formatters/EntityIdTitleFormatterTest.php +++ b/lib/tests/phpunit/formatters/EntityIdTitleFormatterTest.php @@ -60,9 +60,9 @@ public function getTitleForId( EntityId $id ) { if ( $id->getEntityType() === Item::ENTITY_TYPE ) { - $name = 'ITEM-TEST--' . $id->getPrefixedId(); + $name = 'ITEM-TEST--' . $id->getSerialization(); } elseif ( $id->getEntityType() === Property::ENTITY_TYPE ) { - $name = 'PROPERTY-TEST--' . $id->getPrefixedId(); + $name = 'PROPERTY-TEST--' . $id->getSerialization(); } else { throw new LogicException( "oops!" ); } diff --git a/lib/tests/phpunit/formatters/WikibaseSnakFormatterBuildersTest.php b/lib/tests/phpunit/formatters/WikibaseSnakFormatterBuildersTest.php index 5ffc70f..073e35d 100644 --- a/lib/tests/phpunit/formatters/WikibaseSnakFormatterBuildersTest.php +++ b/lib/tests/phpunit/formatters/WikibaseSnakFormatterBuildersTest.php @@ -59,7 +59,7 @@ $entity = EntityFactory::singleton()->newEmpty( $entityId->getEntityType() ); $entity->setId( $entityId ); - $entity->setLabel( 'en', 'Label for ' . $entityId->getPrefixedId() ); + $entity->setLabel( 'en', 'Label for ' . $entityId->getSerialization() ); $entityLookup = $this->getMock( 'Wikibase\Lib\Store\EntityLookup' ); $entityLookup->expects( $this->any() ) diff --git a/lib/tests/phpunit/formatters/WikibaseValueFormatterBuildersTest.php b/lib/tests/phpunit/formatters/WikibaseValueFormatterBuildersTest.php index 782ed82..aa6bd33 100644 --- a/lib/tests/phpunit/formatters/WikibaseValueFormatterBuildersTest.php +++ b/lib/tests/phpunit/formatters/WikibaseValueFormatterBuildersTest.php @@ -47,7 +47,7 @@ private function newWikibaseValueFormatterBuilders( EntityId $entityId ) { $entity = EntityFactory::singleton()->newEmpty( $entityId->getEntityType() ); $entity->setId( $entityId ); - $entity->setLabel( 'en', 'Label for ' . $entityId->getPrefixedId() ); + $entity->setLabel( 'en', 'Label for ' . $entityId->getSerialization() ); $entityLookup = $this->getMock( 'Wikibase\Lib\Store\EntityLookup' ); $entityLookup->expects( $this->any() ) @@ -492,4 +492,5 @@ ), ); } + } -- To view, visit https://gerrit.wikimedia.org/r/166383 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I6fa896855890d4195663a946a9a67356ee47a3f6 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Thiemo Mättig (WMDE) <thiemo.maet...@wikimedia.de> Gerrit-Reviewer: Bene <benestar.wikime...@gmail.com> Gerrit-Reviewer: Thiemo Mättig (WMDE) <thiemo.maet...@wikimedia.de> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits