Aude has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/221811

Change subject: Add searchentities alias param only for alias search results
......................................................................

Add searchentities alias param only for alias search results

The array and param need to be omitted if the result is not
an alias.

If it is empty array, then the suggester still shows "Also known as:"
and then nothing (no aliases, nothing...).  Previously (and on Wikidata)
"Also known as:" is omitted if there are none.

Bug: T104273
Change-Id: Ia5eaa1ba74a4f6fbc19cef1caf7f7dc42bb70016
---
M repo/includes/api/SearchEntities.php
M repo/tests/phpunit/includes/api/SearchEntitiesTest.php
2 files changed, 6 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase 
refs/changes/11/221811/1

diff --git a/repo/includes/api/SearchEntities.php 
b/repo/includes/api/SearchEntities.php
index 3d89e0d..c54e7fb 100644
--- a/repo/includes/api/SearchEntities.php
+++ b/repo/includes/api/SearchEntities.php
@@ -180,7 +180,8 @@
                        $entry['url'] = $title->getFullUrl();
                        $entry = array_merge( $entry, $this->termsToArray( 
$match['displayTerms'] ) );
                        $entry['match']['type'] = 
$match[TermIndexSearchInteractor::MATCHEDTERMTYPE_KEY];
-                       //Special handeling for 'entityId's as these are not 
actually Term objects
+
+                       //Special handling for 'entityId's as these are not 
actually Term objects
                        if ( $entry['match']['type'] === 'entityId' ) {
                                $entry['match']['text'] = $match['entityId'];
                                $entry['aliases'] = array( $match['entityId'] );
@@ -189,7 +190,10 @@
                                $matchedTerm = 
$match[TermIndexSearchInteractor::MATCHEDTERM_KEY];
                                $entry['match']['language'] = 
$matchedTerm->getLanguageCode();
                                $entry['match']['text'] = 
$matchedTerm->getText();
-                               $entry['aliases'] = array( 
$matchedTerm->getText() );
+
+                               if ( $match['matchedTermType'] === 'alias' ) {
+                                       $entry['aliases'] = array( 
$matchedTerm->getText() );
+                               }
                        }
                        $entries[] = $entry;
                }
diff --git a/repo/tests/phpunit/includes/api/SearchEntitiesTest.php 
b/repo/tests/phpunit/includes/api/SearchEntitiesTest.php
index e3b1217..c5d9acb 100644
--- a/repo/tests/phpunit/includes/api/SearchEntitiesTest.php
+++ b/repo/tests/phpunit/includes/api/SearchEntitiesTest.php
@@ -249,7 +249,6 @@
                        'url' => 'http://fullTitleUrl',
                        TermIndexEntry::TYPE_LABEL => 'FooHeHe',
                        TermIndexEntry::TYPE_DESCRIPTION => 'FooHeHe en 
description',
-                       'aliases' => array( 'Fooooo' ),
                        'match' => array(
                                'type' => 'label',
                                'language' => 'en-gb',

-- 
To view, visit https://gerrit.wikimedia.org/r/221811
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia5eaa1ba74a4f6fbc19cef1caf7f7dc42bb70016
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Aude <aude.w...@gmail.com>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to