MaxSem has submitted this change and it was merged.
Change subject: Add globe to prop of prop=coordinates and list=geosearch
......................................................................
Add globe to prop of prop=coordinates and list=geosearch
Bug: 44403
Change-Id: Iad81cbf17c5987260b14c0fd18ec9421ccb87f80
---
M api/ApiQueryCoordinates.php
M api/ApiQueryGeoSearch.php
M api/ApiQueryGeoSearchDb.php
M api/ApiQueryGeoSearchSolr.php
4 files changed, 21 insertions(+), 7 deletions(-)
Approvals:
awjrichards: Verified; Looks good to me, approved
jenkins-bot: Checked
diff --git a/api/ApiQueryCoordinates.php b/api/ApiQueryCoordinates.php
index c75df7a..7f8da15 100644
--- a/api/ApiQueryCoordinates.php
+++ b/api/ApiQueryCoordinates.php
@@ -9,6 +9,7 @@
}
public function execute() {
+ global $wgDefaultGlobe;
$titles = $this->getPageSet()->getGoodTitles();
if ( count( $titles ) == 0 ) {
return;
@@ -60,7 +61,10 @@
foreach( $params['prop'] as $prop ) {
if ( isset( Coord::$fieldMapping[$prop] ) &&
isset( $row->{Coord::$fieldMapping[$prop]} ) ) {
$field = Coord::$fieldMapping[$prop];
- $vals[$prop] = $row->$field;
+ // Don't output default globe
+ if ( !( $prop === 'globe' &&
$row->$field === $wgDefaultGlobe ) ) {
+ $vals[$prop] = $row->$field;
+ }
}
}
$fit = $this->addPageSubItem( $row->gt_page_id, $vals );
@@ -87,8 +91,8 @@
ApiBase::PARAM_TYPE => 'string',
),
'prop' => array(
- ApiBase::PARAM_TYPE => array( 'type', 'name',
'dim', 'country', 'region' ),
- ApiBase::PARAM_DFLT => '',
+ ApiBase::PARAM_TYPE => array( 'type', 'name',
'dim', 'country', 'region', 'globe' ),
+ ApiBase::PARAM_DFLT => 'globe',
ApiBase::PARAM_ISMULTI => true,
),
'primary' => array(
diff --git a/api/ApiQueryGeoSearch.php b/api/ApiQueryGeoSearch.php
index 6e2d192..1ce929d 100644
--- a/api/ApiQueryGeoSearch.php
+++ b/api/ApiQueryGeoSearch.php
@@ -136,8 +136,8 @@
ApiBase::PARAM_ISMULTI => true,
),
'prop' => array(
- ApiBase::PARAM_TYPE => array( 'type', 'name',
'dim', 'country', 'region' ),
- ApiBase::PARAM_DFLT => '',
+ ApiBase::PARAM_TYPE => array( 'type', 'name',
'dim', 'country', 'region', 'globe' ),
+ ApiBase::PARAM_DFLT => 'globe',
ApiBase::PARAM_ISMULTI => true,
),
'primary' => array(
diff --git a/api/ApiQueryGeoSearchDb.php b/api/ApiQueryGeoSearchDb.php
index 40152af..d21ce65 100644
--- a/api/ApiQueryGeoSearchDb.php
+++ b/api/ApiQueryGeoSearchDb.php
@@ -10,6 +10,8 @@
* @param ApiPageSet $resultPageSet
*/
protected function run( $resultPageSet = null ) {
+ global $wgDefaultGlobe;
+
wfProfileIn( __METHOD__ );
parent::run( $resultPageSet );
$params = $this->extractRequestParams();
@@ -71,7 +73,10 @@
foreach( $params['prop'] as $prop ) {
if ( isset( Coord::$fieldMapping[$prop]
) && isset( $row->{Coord::$fieldMapping[$prop]} ) ) {
$field =
Coord::$fieldMapping[$prop];
- $vals[$prop] = $row->$field;
+ // Don't output default globe
+ if ( !( $prop === 'globe' &&
$row->$field === $wgDefaultGlobe ) ) {
+ $vals[$prop] =
$row->$field;
+ }
}
}
$fit = $result->addValue( array( 'query',
$this->getModuleName() ), null, $vals );
diff --git a/api/ApiQueryGeoSearchSolr.php b/api/ApiQueryGeoSearchSolr.php
index ae78c8b..8fc1820 100644
--- a/api/ApiQueryGeoSearchSolr.php
+++ b/api/ApiQueryGeoSearchSolr.php
@@ -9,6 +9,8 @@
* @param ApiPageSet $resultPageSet
*/
protected function run( $resultPageSet = null ) {
+ global $wgDefaultGlobe;
+
wfProfileIn( __METHOD__ );
parent::run( $resultPageSet );
@@ -87,7 +89,10 @@
$vals['primary'] = '';
}
foreach( $params['prop'] as $prop ) {
- $vals[$prop] = $doc->$prop;
+ // Don't output default globe
+ if ( !( $prop === 'globe' &&
$doc->$prop === $wgDefaultGlobe ) ) {
+ $vals[$prop] =
$doc->$prop;
+ }
}
$fit = $result->addValue( array(
'query', $this->getModuleName() ), null, $vals );
if ( !$fit ) {
--
To view, visit https://gerrit.wikimedia.org/r/47874
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Iad81cbf17c5987260b14c0fd18ec9421ccb87f80
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/extensions/GeoData
Gerrit-Branch: master
Gerrit-Owner: MaxSem <[email protected]>
Gerrit-Reviewer: MaxSem <[email protected]>
Gerrit-Reviewer: awjrichards <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits