Lucas Werkmeister (WMDE) has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/363212 )
Change subject: Support claimid with lowercase entity ID ...................................................................... Support claimid with lowercase entity ID Old Wikidata statements have a statement GUID like > q42$8419C20C-8EF8-4EC0-80D6-AF1CA55E7557 instead of the current format, which is: > Q42$8419c20c-8ef8-4ec0-80d6-af1ca55e7557 When we parse this string, it is split up into entity ID and GUID part, and StatementGuid holds both and reassembles the serialization from those parts; the StatementGuid’s serialization is therefore > Q42$8419C20C-8EF8-4EC0-80D6-AF1CA55E7557 since the entity ID was normalized during parsing, but nothing was done to the GUID part. When we search for this statement by its statement GUID, StatementList::getFirstStatementWithGuid walks the statements and does a simple string comparison on the entire statement GUID, which means that the statement is not found because of the case mismatch in the entity ID. To remedy this, we try to find the statement again if the change was unsuccessful, this time with the first character (the Q or P of the entity ID) lowercased. (The assumption that “convert the first character to lowercase” is a meaningful operation may not necessarily hold for future entity types, but hopefully future entity types will never introduce this sort of case confusion into the statement GUIDs stored in the database, so this should not matter.) Bug: T165020 Change-Id: Icbe934f8b0b018705a8f38ee17a6a7c8439afef0 --- M includes/ConstraintCheck/DelegatingConstraintChecker.php 1 file changed, 5 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikibaseQualityConstraints refs/changes/12/363212/1 diff --git a/includes/ConstraintCheck/DelegatingConstraintChecker.php b/includes/ConstraintCheck/DelegatingConstraintChecker.php index d7eb5b7..6d3b66e 100644 --- a/includes/ConstraintCheck/DelegatingConstraintChecker.php +++ b/includes/ConstraintCheck/DelegatingConstraintChecker.php @@ -132,6 +132,11 @@ $entity = $this->entityLookup->getEntity( $entityId ); if ( $entity instanceof StatementListProvider ) { $statement = $entity->getStatements()->getFirstStatementWithGuid( $guid->getSerialization() ); + if ( $statement === null ) { + // try lowercasing the entity ID for legacy statement GUIDs + $guidSerialization = lcfirst( $guid->getSerialization() ); + $statement = $entity->getStatements()->getFirstStatementWithGuid( $guidSerialization ); + } if ( $statement ) { $result = $this->checkStatement( $entity, $statement, $constraintIds ); $output = $this->sortResult( $result ); -- To view, visit https://gerrit.wikimedia.org/r/363212 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Icbe934f8b0b018705a8f38ee17a6a7c8439afef0 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/WikibaseQualityConstraints Gerrit-Branch: master Gerrit-Owner: Lucas Werkmeister (WMDE) <lucas.werkmeis...@wikimedia.de> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits