jenkins-bot has submitted this change and it was merged. Change subject: Don't index non-Earth coordinates ......................................................................
Don't index non-Earth coordinates This was never supposed to happen, but was somehow missed. Search API explicitly doesn't permit such searches anyway. Bug: T136559 Change-Id: If9be410d7fdccdf5f3fdf2020f07e442eda6398a --- M includes/Hooks.php 1 file changed, 24 insertions(+), 6 deletions(-) Approvals: EBernhardson: Looks good to me, approved jenkins-bot: Verified diff --git a/includes/Hooks.php b/includes/Hooks.php index ef527eb..03fc448 100644 --- a/includes/Hooks.php +++ b/includes/Hooks.php @@ -16,6 +16,10 @@ use User; use WikiPage; +/** + * Hook handlers + * @todo: tests + */ class Hooks { /** * LoadExtensionSchemaUpdates hook handler @@ -302,17 +306,31 @@ $coords = []; /** @var Coord $coord */ foreach ( $parserOutput->geoData->getAll() as $coord ) { - $arr = $coord->getAsArray(); - $arr['coord'] = [ 'lat' => $coord->lat, 'lon' => $coord->lon ]; - unset( $arr['id'] ); - unset( $arr['lat'] ); - unset( $arr['lon'] ); - $coords[] = $arr; + if ( $coord->globe !== 'earth' ) { + continue; + } + $coords[] = self::coordToElastic( $coord ); } $doc->set( 'coordinates', $coords ); } /** + * Transforms coordinates into an array for insertion onto Elasticsearch + * + * @param Coord $coord + * @return array + */ + public static function coordToElastic( Coord $coord ) { + $result = $coord->getAsArray(); + $result['coord'] = [ 'lat' => $coord->lat, 'lon' => $coord->lon ]; + unset( $result['id'] ); + unset( $result['lat'] ); + unset( $result['lon'] ); + + return $result; + } + + /** * Add to the tables cloned for parser testing * @see https://www.mediawiki.org/wiki/Manual:Hooks/ParserTestTables * -- To view, visit https://gerrit.wikimedia.org/r/292026 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: If9be410d7fdccdf5f3fdf2020f07e442eda6398a Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/GeoData Gerrit-Branch: master Gerrit-Owner: MaxSem <maxsem.w...@gmail.com> Gerrit-Reviewer: DCausse <dcau...@wikimedia.org> Gerrit-Reviewer: EBernhardson <ebernhard...@wikimedia.org> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits