Anomie has uploaded a new change for review.
https://gerrit.wikimedia.org/r/172794
Change subject: API: Don't add searchinfo or interwiki info from
generator=search
......................................................................
API: Don't add searchinfo or interwiki info from generator=search
Generators should generally just generate titles without adding
additional stuff to the result.
OTOH, there's no reason a generator can't generate interwiki titles.
Bug: 73321
Change-Id: I55d1d35c9d8bedbc68a201fab9d455bc011cc4d8
---
M includes/api/ApiQuerySearch.php
1 file changed, 36 insertions(+), 29 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core
refs/changes/94/172794/1
diff --git a/includes/api/ApiQuerySearch.php b/includes/api/ApiQuerySearch.php
index cc9f9aa..0f33d07 100644
--- a/includes/api/ApiQuerySearch.php
+++ b/includes/api/ApiQuerySearch.php
@@ -116,18 +116,20 @@
$this->dieUsage( $matches->getWikiText(),
'search-error' );
}
- $apiResult = $this->getResult();
- // Add search meta data to result
- if ( isset( $searchInfo['totalhits'] ) ) {
- $totalhits = $matches->getTotalHits();
- if ( $totalhits !== null ) {
- $apiResult->addValue( array( 'query',
'searchinfo' ),
- 'totalhits', $totalhits );
+ if ( $resultPageSet === null ) {
+ $apiResult = $this->getResult();
+ // Add search meta data to result
+ if ( isset( $searchInfo['totalhits'] ) ) {
+ $totalhits = $matches->getTotalHits();
+ if ( $totalhits !== null ) {
+ $apiResult->addValue( array( 'query',
'searchinfo' ),
+ 'totalhits', $totalhits );
+ }
}
- }
- if ( isset( $searchInfo['suggestion'] ) &&
$matches->hasSuggestion() ) {
- $apiResult->addValue( array( 'query', 'searchinfo' ),
- 'suggestion', $matches->getSuggestionQuery() );
+ if ( isset( $searchInfo['suggestion'] ) &&
$matches->hasSuggestion() ) {
+ $apiResult->addValue( array( 'query',
'searchinfo' ),
+ 'suggestion',
$matches->getSuggestionQuery() );
+ }
}
// Add the search results to the result
@@ -151,7 +153,7 @@
}
$title = $result->getTitle();
- if ( is_null( $resultPageSet ) ) {
+ if ( $resultPageSet === null ) {
$vals = array();
ApiQueryBase::addTitleInfo( $vals, $title );
@@ -207,7 +209,7 @@
$hasInterwikiResults = true;
// Include number of results if requested
- if ( isset( $searchInfo['totalhits'] ) ) {
+ if ( $resultPageSet === null && isset(
$searchInfo['totalhits'] ) ) {
$totalhits = $matches->getTotalHits();
if ( $totalhits !== null ) {
$apiResult->addValue( array( 'query',
'interwikisearchinfo' ),
@@ -218,30 +220,35 @@
$result = $matches->next();
while ( $result ) {
$title = $result->getTitle();
- $vals = array(
- 'namespace' =>
$result->getInterwikiNamespaceText(),
- 'title' => $title->getText(),
- 'url' => $title->getFullUrl(),
- );
- // Add item to results and see whether it fits
- $fit = $apiResult->addValue(
- array( 'query', 'interwiki' .
$this->getModuleName(), $result->getInterwikiPrefix() ),
- null,
- $vals
- );
+ if ( $resultPageSet === null ) {
+ $vals = array(
+ 'namespace' =>
$result->getInterwikiNamespaceText(),
+ 'title' => $title->getText(),
+ 'url' => $title->getFullUrl(),
+ );
- if ( !$fit ) {
- // We hit the limit. We can't really
provide any meaningful
- // pagination info so just bail out
- break;
+ // Add item to results and see whether
it fits
+ $fit = $apiResult->addValue(
+ array( 'query', 'interwiki' .
$this->getModuleName(), $result->getInterwikiPrefix() ),
+ null,
+ $vals
+ );
+
+ if ( !$fit ) {
+ // We hit the limit. We can't
really provide any meaningful
+ // pagination info so just bail
out
+ break;
+ }
+ } else {
+ $titles[] = $title;
}
$result = $matches->next();
}
}
- if ( is_null( $resultPageSet ) ) {
+ if ( $resultPageSet === null ) {
$apiResult->setIndexedTagName_internal( array(
'query', $this->getModuleName()
), 'p' );
--
To view, visit https://gerrit.wikimedia.org/r/172794
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I55d1d35c9d8bedbc68a201fab9d455bc011cc4d8
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Anomie <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits