jenkins-bot has submitted this change and it was merged.

Change subject: Add "concepturi" field to wbsearchentities API results
......................................................................


Add "concepturi" field to wbsearchentities API results

Currently needed for the unit suggester, but probably useful in many
other use cases.

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

Approvals:
  Jonas Kress (WMDE): Looks good to me, but someone else must approve
  Daniel Kinzler: Looks good to me, approved
  Addshore: Looks good to me, but someone else must approve
  jenkins-bot: Verified



diff --git a/repo/includes/api/SearchEntities.php 
b/repo/includes/api/SearchEntities.php
index 9f5236c..9bc83ea 100644
--- a/repo/includes/api/SearchEntities.php
+++ b/repo/includes/api/SearchEntities.php
@@ -69,6 +69,11 @@
        private $entityTypes;
 
        /**
+        * @var string
+        */
+       private $conceptBaseUri;
+
+       /**
         * @param ApiMain $mainModule
         * @param string $moduleName
         * @param string $modulePrefix
@@ -90,7 +95,8 @@
                                $repo->getTermLookup(),
                                $repo->getLanguageFallbackChainFactory()
                                ->newFromLanguageCode( 
$this->getLanguage()->getCode() )
-                       )
+                       ),
+                       $repo->getSettings()->getSetting( 'conceptBaseUri' )
                );
        }
 
@@ -104,6 +110,7 @@
         * @param TermIndexSearchInteractor $termIndexSearchInteractor
         * @param TermIndex $termIndex
         * @param LabelDescriptionLookup $labelDescriptionLookup
+        * @param string $conceptBaseUri
         */
        public function setServices(
                EntityTitleLookup $titleLookup,
@@ -112,7 +119,8 @@
                ContentLanguages $termLanguages,
                TermIndexSearchInteractor $termIndexSearchInteractor,
                TermIndex $termIndex,
-               LabelDescriptionLookup $labelDescriptionLookup
+               LabelDescriptionLookup $labelDescriptionLookup,
+               $conceptBaseUri
        ) {
                $this->titleLookup = $titleLookup;
                $this->idParser = $idParser;
@@ -121,6 +129,7 @@
                $this->termIndexSearchInteractor = $termIndexSearchInteractor;
                $this->termIndex = $termIndex;
                $this->labelDescriptionLookup = $labelDescriptionLookup;
+               $this->conceptBaseUri = $conceptBaseUri;
        }
 
        /**
@@ -175,6 +184,7 @@
                        $title = $this->titleLookup->getTitleForId( 
$match->getEntityId() );
                        $entry = array();
                        $entry['id'] = 
$match->getEntityId()->getSerialization();
+                       $entry['concepturi'] = $this->conceptBaseUri . 
$match->getEntityId()->getSerialization();
                        $entry['url'] = $title->getFullUrl();
                        $entry['title'] = $title->getPrefixedText();
                        $entry['pageid'] = $title->getArticleID();
diff --git a/repo/tests/phpunit/includes/api/SearchEntitiesTest.php 
b/repo/tests/phpunit/includes/api/SearchEntitiesTest.php
index 27e8230..5a72504 100644
--- a/repo/tests/phpunit/includes/api/SearchEntitiesTest.php
+++ b/repo/tests/phpunit/includes/api/SearchEntitiesTest.php
@@ -170,7 +170,8 @@
                        $this->getMockContentLanguages(),
                        $searchInteractor,
                        $this->getMockTermIndex(),
-                       $this->getMockLabelDescriptionLookup()
+                       $this->getMockLabelDescriptionLookup(),
+                       'concept:'
                );
 
                $module->execute();
@@ -230,6 +231,7 @@
                );
                $q222Result = array(
                        'id' => 'Q222',
+                       'concepturi' => 'concept:Q222',
                        'url' => 'http://fullTitleUrl',
                        'title' => 'Prefixed:Title',
                        'pageid' => 42,
@@ -244,6 +246,7 @@
                );
                $q333Result = array(
                        'id' => 'Q333',
+                       'concepturi' => 'concept:Q333',
                        'url' => 'http://fullTitleUrl',
                        'title' => 'Prefixed:Title',
                        'pageid' => 42,
@@ -267,6 +270,7 @@
                                array(
                                        array(
                                                'id' => 'Q111',
+                                               'concepturi' => 'concept:Q111',
                                                'url' => 'http://fullTitleUrl',
                                                'title' => 'Prefixed:Title',
                                                'pageid' => 42,
@@ -328,6 +332,7 @@
                foreach ( $result['search'] as $key => $searchresult ) {
                        $this->assertInternalType( 'integer', $key );
                        $this->assertArrayHasKey( 'id', $searchresult );
+                       $this->assertArrayHasKey( 'concepturi', $searchresult );
                        $this->assertArrayHasKey( 'url', $searchresult );
                }
        }

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I6b305800b74e7fda6c687196abb7c4ce7f12e2f9
Gerrit-PatchSet: 4
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Thiemo Mättig (WMDE) <thiemo.maet...@wikimedia.de>
Gerrit-Reviewer: Addshore <addshorew...@gmail.com>
Gerrit-Reviewer: Aude <aude.w...@gmail.com>
Gerrit-Reviewer: Daniel Kinzler <daniel.kinz...@wikimedia.de>
Gerrit-Reviewer: Jonas Kress (WMDE) <jonas.kr...@wikimedia.de>
Gerrit-Reviewer: jenkins-bot <>

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

Reply via email to