MaxSem has uploaded a new change for review. (
https://gerrit.wikimedia.org/r/345876 )
Change subject: Remove old API b/c code
......................................................................
Remove old API b/c code
Change-Id: Ibc962c1ebf0fcec53975c904d33e5b7395d44674
---
M includes/api/ApiQueryCoordinates.php
M includes/api/ApiQueryGeoSearch.php
2 files changed, 18 insertions(+), 57 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/GeoData
refs/changes/76/345876/1
diff --git a/includes/api/ApiQueryCoordinates.php
b/includes/api/ApiQueryCoordinates.php
index ebdcca1..345b301 100644
--- a/includes/api/ApiQueryCoordinates.php
+++ b/includes/api/ApiQueryCoordinates.php
@@ -98,42 +98,27 @@
if ( $params['distancefrompoint'] !== null ) {
$arr = explode( '|', $params['distancefrompoint'] );
if ( count( $arr ) != 2 ||
!$globe->coordinatesAreValid( $arr[0], $arr[1] ) ) {
- if ( is_callable( [ $this, 'dieWithError' ] ) )
{
- $this->dieWithError(
'apierror-geodata-badcoord', 'invalid-coord' );
- } else {
- $this->dieUsage( 'Invalid coordinate
provided', '_invalid-coord' );
- }
+ $this->dieWithError(
'apierror-geodata-badcoord', 'invalid-coord' );
}
return new Coord( $arr[0], $arr[1], 'earth' );
}
if ( $params['distancefrompage'] !== null ) {
$title = Title::newFromText(
$params['distancefrompage'] );
if ( !$title ) {
- if ( is_callable( [ $this, 'dieWithError' ] ) )
{
- $this->dieWithError(
- [ 'apierror-invalidtitle',
wfEscapeWikiText( $params['distancefrompage'] ) ]
- );
- } else {
- $this->dieUsage( "Page
``{$params['distancefrompage']}'' does not exist", '_invalid-page' );
- }
+ $this->dieWithError( [
+ 'apierror-invalidtitle',
+ wfEscapeWikiText(
$params['distancefrompage'] )
+ ] );
}
$coord = GeoData::getPageCoordinates( $title );
if ( !$coord ) {
- if ( is_callable( [ $this, 'dieWithError' ] ) )
{
- $this->dieWithError(
- [
'apierror-geodata-noprimarycoord', wfEscapeWikiText( $title->getPrefixedText()
) ],
- 'no-coordinates'
- );
- } else {
- $this->dieUsage( "Page
``{$params['distancefrompage']}'' has no primary coordinates",
'_no-coordinates' );
- }
+ $this->dieWithError(
+ [ 'apierror-geodata-noprimarycoord',
wfEscapeWikiText( $title->getPrefixedText() ) ],
+ 'no-coordinates'
+ );
}
if ( $coord->globe != 'earth' ) {
- if ( is_callable( [ $this, 'dieWithError' ] ) )
{
- $this->dieWithError(
'apierror-geodata-notonearth', 'notonearth' );
- } else {
- $this->dieUsage( "This page's
coordinates are not on Earth", '_notonearth' );
- }
+ $this->dieWithError(
'apierror-geodata-notonearth', 'notonearth' );
}
return $coord;
}
diff --git a/includes/api/ApiQueryGeoSearch.php
b/includes/api/ApiQueryGeoSearch.php
index 422ae52..549bb1b 100644
--- a/includes/api/ApiQueryGeoSearch.php
+++ b/includes/api/ApiQueryGeoSearch.php
@@ -59,22 +59,14 @@
|| !$globe->coordinatesAreValid( $parts[2], $parts[3] )
|| $vals[0] <= $vals[2]
) {
- if ( is_callable( [ $this, 'dieWithError' ] ) ) {
- $this->dieWithError(
'apierror-geodata-invalidbox', 'invalid-bbox' );
- } else {
- $this->dieUsage( 'Invalid bounding box',
'_invalid-bbox' );
- }
+ $this->dieWithError( 'apierror-geodata-invalidbox',
'invalid-bbox' );
}
$bbox = new BoundingBox( $vals[0], $vals[1], $vals[2], $vals[3]
);
$area = $bbox->area();
if ( $area > $wgMaxGeoSearchRadius * $wgMaxGeoSearchRadius * 4
|| $area < 100
) {
- if ( is_callable( [ $this, 'dieWithError' ] ) ) {
- $this->dieWithError(
'apierror-geodata-boxtoobig', 'toobig' );
- } else {
- $this->dieUsage( 'Bounding box is too big',
'_toobig' );
- }
+ $this->dieWithError( 'apierror-geodata-boxtoobig',
'toobig' );
}
return $bbox;
@@ -91,38 +83,22 @@
if ( isset( $params['coord'] ) ) {
$arr = explode( '|', $params['coord'] );
if ( count( $arr ) != 2 ||
!$globe->coordinatesAreValid( $arr[0], $arr[1] ) ) {
- if ( is_callable( [ $this, 'dieWithError' ] ) )
{
- $this->dieWithError(
'apierror-geodata-badcoord', 'invalid-coord' );
- } else {
- $this->dieUsage( 'Invalid coordinate
provided', '_invalid-coord' );
- }
+ $this->dieWithError(
'apierror-geodata-badcoord', 'invalid-coord' );
}
$this->coord = new Coord( floatval( $arr[0] ),
floatval( $arr[1] ), $params['globe'] );
} elseif ( isset( $params['page'] ) ) {
$t = Title::newFromText( $params['page'] );
if ( !$t || !$t->canExist() ) {
- if ( is_callable( [ $this, 'dieWithError' ] ) )
{
- $this->dieWithError( [
'apierror-invalidtitle', wfEscapeWikiText( $params['page'] ) ] );
- } else {
- $this->dieUsage( "Invalid page title
``{$params['page']}'' provided", '_invalid-page' );
- }
+ $this->dieWithError( [ 'apierror-invalidtitle',
wfEscapeWikiText( $params['page'] ) ] );
}
if ( !$t->exists() ) {
- if ( is_callable( [ $this, 'dieWithError' ] ) )
{
- $this->dieWithError(
- [
'apierror-missingtitle-byname', wfEscapeWikiText( $t->getPrefixedText() ) ],
'missingtitle'
- );
- } else {
- $this->dieUsage( "Page
``{$params['page']}'' does not exist", '_nonexistent-page' );
- }
+ $this->dieWithError(
+ [ 'apierror-missingtitle-byname',
wfEscapeWikiText( $t->getPrefixedText() ) ], 'missingtitle'
+ );
}
$this->coord = GeoData::getPageCoordinates( $t );
if ( !$this->coord ) {
- if ( is_callable( [ $this, 'dieWithError' ] ) )
{
- $this->dieWithError(
'apierror-geodata-nocoord', 'no-coordinates' );
- } else {
- $this->dieUsage( 'Page coordinates
unknown', '_no-coordinates' );
- }
+ $this->dieWithError(
'apierror-geodata-nocoord', 'no-coordinates' );
}
$this->idToExclude = $t->getArticleID();
} elseif ( isset( $params['bbox'] ) ) {
--
To view, visit https://gerrit.wikimedia.org/r/345876
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ibc962c1ebf0fcec53975c904d33e5b7395d44674
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/GeoData
Gerrit-Branch: master
Gerrit-Owner: MaxSem <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits