Hoo man has uploaded a new change for review. https://gerrit.wikimedia.org/r/206386
Change subject: Make label/description uniqueness checks case insensitive for properties ...................................................................... Make label/description uniqueness checks case insensitive for properties Bug: T97129 Change-Id: Idfc3cbbc66d00b9ef6fbd010c9edd81213541d00 --- M lib/includes/store/sql/TermSqlIndex.php M lib/tests/phpunit/store/TermIndexTest.php 2 files changed, 25 insertions(+), 9 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/86/206386/1 diff --git a/lib/includes/store/sql/TermSqlIndex.php b/lib/includes/store/sql/TermSqlIndex.php index 0d54f05..8d4c247 100644 --- a/lib/includes/store/sql/TermSqlIndex.php +++ b/lib/includes/store/sql/TermSqlIndex.php @@ -10,6 +10,7 @@ use Wikibase\DataModel\Entity\EntityDocument; use Wikibase\DataModel\Entity\EntityId; use Wikibase\DataModel\Entity\Item; +use Wikibase\DataModel\Entity\Property; use Wikibase\DataModel\LegacyIdInterpreter; use Wikibase\DataModel\Term\AliasGroup; use Wikibase\DataModel\Term\Fingerprint; @@ -827,13 +828,16 @@ $templates = $this->makeQueryTerms( $labels, Term::TYPE_LABEL ); + // Property label conflict checks aren't case sensitive. T73785/T97129 + // XXX: This knowledge should probably not be here :/ + $caseSensitive = $entityType !== Property::ENTITY_TYPE; $labelConflicts = $this->getMatchingTerms( $templates, Term::TYPE_LABEL, $entityType, array( 'LIMIT' => $this->maxConflicts, - 'caseSensitive' => false + 'caseSensitive' => $caseSensitive ) ); @@ -891,11 +895,23 @@ $description = $descriptions[$lang]; $matchConditions = array( - 'L.term_language' => $lang, - 'L.term_search_key' => $this->getSearchKey( $label, $lang ), - 'D.term_search_key' => $this->getSearchKey( $description, $lang ) + 'L.term_language' => $lang ); + // Property conflict checks aren't case sensitive. T73785/T97129 + // XXX: This knowledge should probably not be here :/ + if ( $entityType === Property::ENTITY_TYPE ) { + $matchConditions = array( + 'L.term_text' => $label, + 'D.term_text' => $description, + ); + } else { + $matchConditions = array( + 'L.term_search_key' => $this->getSearchKey( $label, $lang ), + 'D.term_search_key' => $this->getSearchKey( $description, $lang ) + ); + } + $termConditions[] = $dbr->makeList( $matchConditions, LIST_AND ); } diff --git a/lib/tests/phpunit/store/TermIndexTest.php b/lib/tests/phpunit/store/TermIndexTest.php index 4090b3b..2b577bc 100644 --- a/lib/tests/phpunit/store/TermIndexTest.php +++ b/lib/tests/phpunit/store/TermIndexTest.php @@ -389,7 +389,7 @@ array( 'de' => 'Foo' ), array( 'P6' ), ), - 'by label, different case' => array( + 'by label, different case (property only)' => array( $entities, Property::ENTITY_TYPE, array( 'de' => 'fOO' ), @@ -452,16 +452,16 @@ array( 'de' => 'Bar' ), array( 'Q1' ), ), - 'by label and description, different label capitalization' => array( + 'by label and description, different label capitalization (property only)' => array( $entities, - Item::ENTITY_TYPE, + Property::ENTITY_TYPE, array( 'de' => 'fOO' ), array( 'de' => 'Bar' ), array( 'Q1' ), ), - 'by label and description, different description capitalization' => array( + 'by label and description, different description capitalization (property only)' => array( $entities, - Item::ENTITY_TYPE, + Property::ENTITY_TYPE, array( 'de' => 'Foo' ), array( 'de' => 'bAR' ), array( 'Q1' ), -- To view, visit https://gerrit.wikimedia.org/r/206386 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Idfc3cbbc66d00b9ef6fbd010c9edd81213541d00 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Hoo man <h...@online.de> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits