PranavK has uploaded a new change for review.
https://gerrit.wikimedia.org/r/258967
Change subject: wbsearchentities: Make returning the entity URL optinal
......................................................................
wbsearchentities: Make returning the entity URL optinal
Bug: T103875
Change-Id: I63a694141d9b5222cb672fba0c62ff54eef58993
---
M repo/i18n/en.json
M repo/i18n/qqq.json
M repo/includes/api/SearchEntities.php
M repo/tests/phpunit/includes/api/SearchEntitiesTest.php
4 files changed, 49 insertions(+), 1 deletion(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase
refs/changes/67/258967/1
diff --git a/repo/i18n/en.json b/repo/i18n/en.json
index 5fd946d..40aa965 100644
--- a/repo/i18n/en.json
+++ b/repo/i18n/en.json
@@ -495,11 +495,13 @@
"apihelp-wbsearchentities-param-language": "Search in this language.",
"apihelp-wbsearchentities-param-strictlanguage": "Whether to disable
language fallback",
"apihelp-wbsearchentities-param-type": "Search for this type of
entity.",
+ "apihelp-wbsearchentities-param-props": "Return these properties for
each entity.",
"apihelp-wbsearchentities-param-limit": "Maximal number of results",
"apihelp-wbsearchentities-param-continue": "Offset where to continue a
search",
"apihelp-wbsearchentities-example-1": "Search for \"abc\" in English
language, with defaults for type and limit",
"apihelp-wbsearchentities-example-2": "Search for \"abc\" in English
language with a limit of 50",
"apihelp-wbsearchentities-example-3": "Search for \"alphabet\" in
English language for type property",
+ "apihelp-wbsearchentities-example-4": "Search for \"alphabet\" in
English language, and return URL",
"apihelp-query+wbsearch-description": "Searches for entities using
labels and aliases.\nThis can be used as a generator for other
queries.\nReturns the matched term that should be displayed.",
"apihelp-query+wbsearch-param-search": "Search for this text.",
"apihelp-query+wbsearch-param-language": "Search in this language.",
@@ -604,3 +606,5 @@
"apihelp-wbsetsitelink-example-7": "Change the link to the Polish page
from the item with ID \"Q42\" without changing badges",
"apihelp-wbsetsitelink-example-8": "Change the link to the Polish page
from the item with ID \"Q42\" and remove all of its badges"
}
+
+
diff --git a/repo/i18n/qqq.json b/repo/i18n/qqq.json
index bc1b925..dd347d7 100644
--- a/repo/i18n/qqq.json
+++ b/repo/i18n/qqq.json
@@ -526,9 +526,11 @@
"apihelp-wbsearchentities-param-type":
"{{doc-apihelp-param|wbsearchentities|type}}",
"apihelp-wbsearchentities-param-limit":
"{{doc-apihelp-param|wbsearchentities|limit}}",
"apihelp-wbsearchentities-param-continue":
"{{doc-apihelp-param|wbsearchentities|continue}}",
+ "apihelp-wbsearchentities-param-props":
"{{doc-apihelp-param|wbsearchentities|props}}",
"apihelp-wbsearchentities-example-1":
"{{doc-apihelp-example|wbsearchentities}}",
"apihelp-wbsearchentities-example-2":
"{{doc-apihelp-example|wbsearchentities}}",
"apihelp-wbsearchentities-example-3":
"{{doc-apihelp-example|wbsearchentities}}",
+ "apihelp-wbsearchentities-example-4":
"{{doc-apihelp-example|wbsearchentities}}",
"apihelp-query+wbsearch-description":
"{{doc-apihelp-description|query+wbsearch}}",
"apihelp-query+wbsearch-param-search":
"{{doc-apihelp-param|query+wbsearch|search}}",
"apihelp-query+wbsearch-param-language":
"{{doc-apihelp-param|query+wbsearch|language}}",
@@ -633,3 +635,5 @@
"apihelp-wbsetsitelink-example-7":
"{{doc-apihelp-example|wbsetsitelink}}",
"apihelp-wbsetsitelink-example-8":
"{{doc-apihelp-example|wbsetsitelink}}"
}
+
+
diff --git a/repo/includes/api/SearchEntities.php
b/repo/includes/api/SearchEntities.php
index 3e6a4bf..2decbcb 100644
--- a/repo/includes/api/SearchEntities.php
+++ b/repo/includes/api/SearchEntities.php
@@ -143,10 +143,13 @@
$entry = array(
'id' => $match->getEntityId()->getSerialization(),
'concepturi' => $this->conceptBaseUri .
$match->getEntityId()->getSerialization(),
- 'url' => $title->getFullUrl(),
'title' => $title->getPrefixedText(),
'pageid' => $title->getArticleID()
);
+
+ if ( $params['props'] === 'url' ) {
+ $entry['url'] = $title->getFullUrl();
+ }
$displayLabel = $match->getDisplayLabel();
@@ -275,6 +278,11 @@
self::PARAM_TYPE => 'integer',
self::PARAM_REQUIRED => false,
),
+ 'props' => array(
+ self::PARAM_TYPE => array( 'url' ),
+ self::PARAM_REQUIRED => false,
+ ),
+
);
}
@@ -289,7 +297,12 @@
'apihelp-wbsearchentities-example-2',
'action=wbsearchentities&search=alphabet&language=en&type=property' =>
'apihelp-wbsearchentities-example-3',
+
'action=wbsearchentities&search=alphabet&language=en&props=url' =>
+ 'apihelp-wbsearchentities-example-4',
+
);
}
}
+
+
diff --git a/repo/tests/phpunit/includes/api/SearchEntitiesTest.php
b/repo/tests/phpunit/includes/api/SearchEntitiesTest.php
index d526cf4..9e1fdfd 100644
--- a/repo/tests/phpunit/includes/api/SearchEntitiesTest.php
+++ b/repo/tests/phpunit/includes/api/SearchEntitiesTest.php
@@ -189,6 +189,14 @@
new Term( 'fr', 'ADisplayLabel' )
);
+ $q444Match = new TermSearchResult(
+ new Term( 'en-ca', 'BlahMatch' ),
+ 'alias',
+ new ItemId( 'Q444' ),
+ new Term( 'it', 'BlahDisplay' )
+ );
+
+
$q111Result = array(
'id' => 'Q111',
'concepturi' => 'concept:Q111',
@@ -234,6 +242,23 @@
'text' => 'AMatchedTerm',
),
);
+
+ $q444Result = array(
+ 'id' => 'Q444',
+ 'concepturi' => 'concept:Q444',
+ 'url' => 'http://fullTitleUrl',
+ 'title' => 'Prefixed:Title',
+ 'pageid' => 42,
+ 'label' => 'BlahDisplay',
+ 'aliases' => array( 'BlahMatch' ),
+ 'match' => array(
+ 'type' => 'alias',
+ 'language' => 'en-ca',
+ 'text' => 'BlahMatch',
+ 'props' => 'url',
+ ),
+ );
+
return array(
'No exact match' => array(
@@ -299,3 +324,5 @@
}
}
+
+
--
To view, visit https://gerrit.wikimedia.org/r/258967
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I63a694141d9b5222cb672fba0c62ff54eef58993
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: PranavK <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits