From 983545c362921cd1a60b5f00d1d0088c51072cdc Mon Sep 17 00:00:00 2001 From: Yuri Astrakhan Date: Mon, 14 Jan 2013 21:19:16 -0500 Subject: API Cleanup: renamed '_badcontinue'->'badcontinue', one die() * If a query module has 'continue' parameter, it will auto-report that it has 'badcontinue' error. * Added APIQueryBase::DieUsageContinueIf( $condition ) that shows correct badcontinue error if $condition is true. Change-Id: I9c48bda6de0cde3c117ad24460bddf6980279633 --- includes/api/ApiQueryBase.php | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) (limited to 'includes/api/ApiQueryBase.php') diff --git a/includes/api/ApiQueryBase.php b/includes/api/ApiQueryBase.php index 5f4d9f9ce7b4..e36109a2d3d7 100644 --- a/includes/api/ApiQueryBase.php +++ b/includes/api/ApiQueryBase.php @@ -374,6 +374,19 @@ abstract class ApiQueryBase extends ApiBase { $result->enableSizeCheck(); } + /** + * Die with the $prefix.'badcontinue' error. This call is common enough to make it into the base method. + * @param $condition boolean will only die if this value is true + * @since 1.21 + */ + protected function dieContinueUsageIf( $condition ) { + if ( $condition ) { + $this->dieUsage( + 'Invalid continue param. You should pass the original value returned by the previous query', + 'badcontinue' ); + } + } + /** * Get the Query database connection (read-only) * @return DatabaseBase @@ -549,10 +562,21 @@ abstract class ApiQueryBase extends ApiBase { * @return array */ public function getPossibleErrors() { - return array_merge( parent::getPossibleErrors(), array( + $errors = parent::getPossibleErrors(); + $errors = array_merge( $errors, array( array( 'invalidtitle', 'title' ), array( 'invalidtitle', 'key' ), ) ); + $params = $this->getFinalParams(); + if ( array_key_exists( 'continue', $params ) ) { + $errors = array_merge( $errors, array( + array( + 'code' => 'badcontinue', + 'info' => 'Invalid continue param. You should pass the original value returned by the previous query' + ), + ) ); + } + return $errors; } /** -- cgit v1.2.3