From 983545c362921cd1a60b5f00d1d0088c51072cdc Mon Sep 17 00:00:00 2001 From: Yuri Astrakhan Date: Mon, 14 Jan 2013 21:19:16 -0500 Subject: [PATCH] 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 --- RELEASE-NOTES-1.21 | 3 +++ includes/api/ApiQueryAllCategories.php | 11 +-------- includes/api/ApiQueryAllImages.php | 6 +---- includes/api/ApiQueryAllLinks.php | 9 ++------ includes/api/ApiQueryAllPages.php | 6 +---- includes/api/ApiQueryBacklinks.php | 15 ++++--------- includes/api/ApiQueryBase.php | 26 +++++++++++++++++++++- includes/api/ApiQueryCategories.php | 5 +---- includes/api/ApiQueryCategoryMembers.php | 7 +----- includes/api/ApiQueryDeletedrevs.php | 6 ++--- includes/api/ApiQueryDuplicateFiles.php | 11 +-------- includes/api/ApiQueryFilearchive.php | 6 +---- includes/api/ApiQueryIWBacklinks.php | 6 +---- includes/api/ApiQueryIWLinks.php | 6 +---- includes/api/ApiQueryImageInfo.php | 5 +---- includes/api/ApiQueryImages.php | 11 +-------- includes/api/ApiQueryInfo.php | 11 +-------- includes/api/ApiQueryLangBacklinks.php | 6 +---- includes/api/ApiQueryLangLinks.php | 6 +---- includes/api/ApiQueryLinks.php | 5 +---- includes/api/ApiQueryRevisions.php | 5 +---- includes/api/ApiQueryUserContributions.php | 5 +---- includes/api/ApiQueryWatchlistRaw.php | 6 ++--- 23 files changed, 55 insertions(+), 128 deletions(-) diff --git a/RELEASE-NOTES-1.21 b/RELEASE-NOTES-1.21 index b8f3ba6325..e2c5d5c226 100644 --- a/RELEASE-NOTES-1.21 +++ b/RELEASE-NOTES-1.21 @@ -174,6 +174,9 @@ production. * BREAKING CHANGE: list=logevents output format changed for details of some log types. Specifically, details that were formerly reported under a key like "4::foo" will now be reported under a key of simply "foo". +* BREAKING CHANGE: '??_badcontinue' error code was changed to '??badcontinue' + for all query modules. +* ApiQueryBase adds 'badcontinue' error code if module has 'continue' parameter. === Languages updated in 1.21 === diff --git a/includes/api/ApiQueryAllCategories.php b/includes/api/ApiQueryAllCategories.php index c2beaec6a7..6ada4aa716 100644 --- a/includes/api/ApiQueryAllCategories.php +++ b/includes/api/ApiQueryAllCategories.php @@ -60,10 +60,7 @@ class ApiQueryAllCategories extends ApiQueryGeneratorBase { if ( !is_null( $params['continue'] ) ) { $cont = explode( '|', $params['continue'] ); - if ( count( $cont ) != 1 ) { - $this->dieUsage( "Invalid continue param. You should pass the " . - "original value returned by the previous query", "_badcontinue" ); - } + $this->dieContinueUsageIf( count( $cont ) != 1 ); $op = $params['dir'] == 'descending' ? '<' : '>'; $cont_from = $db->addQuotes( $cont[0] ); $this->addWhere( "cat_title $op= $cont_from" ); @@ -224,12 +221,6 @@ class ApiQueryAllCategories extends ApiQueryGeneratorBase { return 'Enumerate all categories'; } - public function getPossibleErrors() { - return array_merge( parent::getPossibleErrors(), array( - array( 'code' => '_badcontinue', 'info' => 'Invalid continue param. You should pass the original value returned by the previous query' ), - ) ); - } - public function getExamples() { return array( 'api.php?action=query&list=allcategories&acprop=size', diff --git a/includes/api/ApiQueryAllImages.php b/includes/api/ApiQueryAllImages.php index 2319263dcf..c78f0f3572 100644 --- a/includes/api/ApiQueryAllImages.php +++ b/includes/api/ApiQueryAllImages.php @@ -113,10 +113,7 @@ class ApiQueryAllImages extends ApiQueryGeneratorBase { // Pagination if ( !is_null( $params['continue'] ) ) { $cont = explode( '|', $params['continue'] ); - if ( count( $cont ) != 1 ) { - $this->dieUsage( 'Invalid continue param. You should pass the ' . - 'original value returned by the previous query', '_badcontinue' ); - } + $this->dieContinueUsageIf( count( $cont ) != 1 ); $op = ( $ascendingOrder ? '>' : '<' ); $continueFrom = $db->addQuotes( $cont[0] ); $this->addWhere( "img_name $op= $continueFrom" ); @@ -385,7 +382,6 @@ class ApiQueryAllImages extends ApiQueryGeneratorBase { array( 'code' => 'mimesearchdisabled', 'info' => 'MIME search disabled in Miser Mode' ), array( 'code' => 'invalidsha1hash', 'info' => 'The SHA1 hash provided is not valid' ), array( 'code' => 'invalidsha1base36hash', 'info' => 'The SHA1Base36 hash provided is not valid' ), - array( 'code' => '_badcontinue', 'info' => 'Invalid continue param. You should pass the original value returned by the previous query' ), ) ); } diff --git a/includes/api/ApiQueryAllLinks.php b/includes/api/ApiQueryAllLinks.php index 3b478b081a..620a394af3 100644 --- a/includes/api/ApiQueryAllLinks.php +++ b/includes/api/ApiQueryAllLinks.php @@ -104,15 +104,11 @@ class ApiQueryAllLinks extends ApiQueryGeneratorBase { $continueArr = explode( '|', $params['continue'] ); $op = $params['dir'] == 'descending' ? '<' : '>'; if ( $params['unique'] ) { - if ( count( $continueArr ) != 1 ) { - $this->dieUsage( 'Invalid continue parameter', 'badcontinue' ); - } + $this->dieContinueUsageIf( count( $continueArr ) != 1 ); $continueTitle = $db->addQuotes( $continueArr[0] ); $this->addWhere( "{$pfx}title $op= $continueTitle" ); } else { - if ( count( $continueArr ) != 2 ) { - $this->dieUsage( 'Invalid continue parameter', 'badcontinue' ); - } + $this->dieContinueUsageIf( count( $continueArr ) != 2 ); $continueTitle = $db->addQuotes( $continueArr[0] ); $continueFrom = intval( $continueArr[1] ); $this->addWhere( @@ -279,7 +275,6 @@ class ApiQueryAllLinks extends ApiQueryGeneratorBase { $link = $this->descriptionLink; return array_merge( parent::getPossibleErrors(), array( array( 'code' => 'params', 'info' => "{$m} cannot return corresponding page ids in unique {$link}s mode" ), - array( 'code' => 'badcontinue', 'info' => 'Invalid continue parameter' ), ) ); } diff --git a/includes/api/ApiQueryAllPages.php b/includes/api/ApiQueryAllPages.php index a5abae76ab..b180572bf8 100644 --- a/includes/api/ApiQueryAllPages.php +++ b/includes/api/ApiQueryAllPages.php @@ -69,10 +69,7 @@ class ApiQueryAllPages extends ApiQueryGeneratorBase { if ( !is_null( $params['continue'] ) ) { $cont = explode( '|', $params['continue'] ); - if ( count( $cont ) != 1 ) { - $this->dieUsage( "Invalid continue param. You should pass the " . - "original value returned by the previous query", "_badcontinue" ); - } + $this->dieContinueUsageIf( count( $cont ) != 1 ); $op = $params['dir'] == 'descending' ? '<' : '>'; $cont_from = $db->addQuotes( $cont[0] ); $this->addWhere( "page_title $op= $cont_from" ); @@ -336,7 +333,6 @@ class ApiQueryAllPages extends ApiQueryGeneratorBase { return array_merge( parent::getPossibleErrors(), array( array( 'code' => 'params', 'info' => 'Use "gapfilterredir=nonredirects" option instead of "redirects" when using allpages as a generator' ), array( 'code' => 'params', 'info' => 'prlevel may not be used without prtype' ), - array( 'code' => '_badcontinue', 'info' => 'Invalid continue param. You should pass the original value returned by the previous query' ), ) ); } diff --git a/includes/api/ApiQueryBacklinks.php b/includes/api/ApiQueryBacklinks.php index 6f45726b38..bf918ddde2 100644 --- a/includes/api/ApiQueryBacklinks.php +++ b/includes/api/ApiQueryBacklinks.php @@ -406,20 +406,14 @@ class ApiQueryBacklinks extends ApiQueryGeneratorBase { // null stuff out now so we know what's set and what isn't $this->rootTitle = $this->contID = $this->redirID = null; $rootNs = intval( $continueList[0] ); - if ( $rootNs === 0 && $continueList[0] !== '0' ) { - // Illegal continue parameter - $this->dieUsage( 'Invalid continue param. You should pass the original value returned by the previous query', '_badcontinue' ); - } + $this->dieContinueUsageIf( $rootNs === 0 && $continueList[0] !== '0' ); + $this->rootTitle = Title::makeTitleSafe( $rootNs, $continueList[1] ); + $this->dieContinueUsageIf( !$this->rootTitle ); - if ( !$this->rootTitle ) { - $this->dieUsage( 'Invalid continue param. You should pass the original value returned by the previous query', '_badcontinue' ); - } $contID = intval( $continueList[2] ); + $this->dieContinueUsageIf( $contID === 0 && $continueList[2] !== '0' ); - if ( $contID === 0 && $continueList[2] !== '0' ) { - $this->dieUsage( 'Invalid continue param. You should pass the original value returned by the previous query', '_badcontinue' ); - } $this->contID = $contID; $id2 = isset( $continueList[3] ) ? $continueList[3] : null; $redirID = intval( $id2 ); @@ -535,7 +529,6 @@ class ApiQueryBacklinks extends ApiQueryGeneratorBase { $this->getTitleOrPageIdErrorMessage(), array( array( 'code' => 'bad_image_title', 'info' => "The title for {$this->getModuleName()} query must be an image" ), - array( 'code' => '_badcontinue', 'info' => 'Invalid continue param. You should pass the original value returned by the previous query' ), ) ); } diff --git a/includes/api/ApiQueryBase.php b/includes/api/ApiQueryBase.php index 5f4d9f9ce7..e36109a2d3 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; } /** diff --git a/includes/api/ApiQueryCategories.php b/includes/api/ApiQueryCategories.php index 309c2ce90d..f05bb262de 100644 --- a/includes/api/ApiQueryCategories.php +++ b/includes/api/ApiQueryCategories.php @@ -85,10 +85,7 @@ class ApiQueryCategories extends ApiQueryGeneratorBase { if ( !is_null( $params['continue'] ) ) { $cont = explode( '|', $params['continue'] ); - if ( count( $cont ) != 2 ) { - $this->dieUsage( "Invalid continue param. You should pass the " . - "original value returned by the previous query", "_badcontinue" ); - } + $this->dieContinueUsageIf( count( $cont ) != 2 ); $op = $params['dir'] == 'descending' ? '<' : '>'; $clfrom = intval( $cont[0] ); $clto = $this->getDB()->addQuotes( $cont[1] ); diff --git a/includes/api/ApiQueryCategoryMembers.php b/includes/api/ApiQueryCategoryMembers.php index a07b049aa4..ca24f2b822 100644 --- a/includes/api/ApiQueryCategoryMembers.php +++ b/includes/api/ApiQueryCategoryMembers.php @@ -106,11 +106,7 @@ class ApiQueryCategoryMembers extends ApiQueryGeneratorBase { } else { if ( $params['continue'] ) { $cont = explode( '|', $params['continue'], 3 ); - if ( count( $cont ) != 3 ) { - $this->dieUsage( 'Invalid continue param. You should pass the original value returned '. - 'by the previous query', '_badcontinue' - ); - } + $this->dieContinueUsageIf( count( $cont ) != 3 ); // Remove the types to skip from $queryTypes $contTypeIndex = array_search( $cont[0], $queryTypes ); @@ -403,7 +399,6 @@ class ApiQueryCategoryMembers extends ApiQueryGeneratorBase { $this->getTitleOrPageIdErrorMessage(), array( array( 'code' => 'invalidcategory', 'info' => 'The category name you entered is not valid' ), - array( 'code' => 'badcontinue', 'info' => 'Invalid continue param. You should pass the original value returned by the previous query' ), ) ); } diff --git a/includes/api/ApiQueryDeletedrevs.php b/includes/api/ApiQueryDeletedrevs.php index 8903e4686f..9eab651f4d 100644 --- a/includes/api/ApiQueryDeletedrevs.php +++ b/includes/api/ApiQueryDeletedrevs.php @@ -160,10 +160,9 @@ class ApiQueryDeletedrevs extends ApiQueryBase { if ( !is_null( $params['continue'] ) && ( $mode == 'all' || $mode == 'revs' ) ) { $cont = explode( '|', $params['continue'] ); - if ( count( $cont ) != 3 ) { - $this->dieUsage( 'Invalid continue param. You should pass the original value returned by the previous query', 'badcontinue' ); - } + $this->dieContinueUsageIf( count( $cont ) != 3 ); $ns = intval( $cont[0] ); + $this->dieContinueUsageIf( strval( $ns ) !== $cont[0] ); $title = $db->addQuotes( $cont[1] ); $ts = $db->addQuotes( $db->timestamp( $cont[2] ) ); $op = ( $dir == 'newer' ? '>' : '<' ); @@ -397,7 +396,6 @@ class ApiQueryDeletedrevs extends ApiQueryBase { array( 'code' => 'permissiondenied', 'info' => 'You don\'t have permission to view deleted revision information' ), array( 'code' => 'badparams', 'info' => 'user and excludeuser cannot be used together' ), array( 'code' => 'permissiondenied', 'info' => 'You don\'t have permission to view deleted revision content' ), - array( 'code' => 'badcontinue', 'info' => 'Invalid continue param. You should pass the original value returned by the previous query' ), array( 'code' => 'badparams', 'info' => "The 'from' parameter cannot be used in modes 1 or 2" ), array( 'code' => 'badparams', 'info' => "The 'to' parameter cannot be used in modes 1 or 2" ), array( 'code' => 'badparams', 'info' => "The 'prefix' parameter cannot be used in modes 1 or 2" ), diff --git a/includes/api/ApiQueryDuplicateFiles.php b/includes/api/ApiQueryDuplicateFiles.php index f088062cb9..d4a486a999 100644 --- a/includes/api/ApiQueryDuplicateFiles.php +++ b/includes/api/ApiQueryDuplicateFiles.php @@ -66,10 +66,7 @@ class ApiQueryDuplicateFiles extends ApiQueryGeneratorBase { $skipUntilThisDup = false; if ( isset( $params['continue'] ) ) { $cont = explode( '|', $params['continue'] ); - if ( count( $cont ) != 2 ) { - $this->dieUsage( 'Invalid continue param. You should pass the ' . - 'original value returned by the previous query', '_badcontinue' ); - } + $this->dieContinueUsageIf( count( $cont ) != 2 ); $fromImage = $cont[0]; $skipUntilThisDup = $cont[1]; // Filter out any images before $fromImage @@ -204,12 +201,6 @@ class ApiQueryDuplicateFiles extends ApiQueryGeneratorBase { return 'List all files that are duplicates of the given file(s) based on hash values'; } - public function getPossibleErrors() { - return array_merge( parent::getPossibleErrors(), array( - array( 'code' => '_badcontinue', 'info' => 'Invalid continue param. You should pass the original value returned by the previous query' ), - ) ); - } - public function getExamples() { return array( 'api.php?action=query&titles=File:Albert_Einstein_Head.jpg&prop=duplicatefiles', diff --git a/includes/api/ApiQueryFilearchive.php b/includes/api/ApiQueryFilearchive.php index 7ec47fa91f..fcffc4d418 100644 --- a/includes/api/ApiQueryFilearchive.php +++ b/includes/api/ApiQueryFilearchive.php @@ -77,10 +77,7 @@ class ApiQueryFilearchive extends ApiQueryBase { if ( !is_null( $params['continue'] ) ) { $cont = explode( '|', $params['continue'] ); - if ( count( $cont ) != 1 ) { - $this->dieUsage( "Invalid continue param. You should pass the " . - "original value returned by the previous query", "_badcontinue" ); - } + $this->dieContinueUsageIf( count( $cont ) != 1 ); $op = $params['dir'] == 'descending' ? '<' : '>'; $cont_from = $db->addQuotes( $cont[0] ); $this->addWhere( "fa_name $op= $cont_from" ); @@ -366,7 +363,6 @@ class ApiQueryFilearchive extends ApiQueryBase { array( 'code' => 'hashsearchdisabled', 'info' => 'Search by hash disabled in Miser Mode' ), array( 'code' => 'invalidsha1hash', 'info' => 'The SHA1 hash provided is not valid' ), array( 'code' => 'invalidsha1base36hash', 'info' => 'The SHA1Base36 hash provided is not valid' ), - array( 'code' => '_badcontinue', 'info' => 'Invalid continue param. You should pass the original value returned by the previous query' ), ) ); } diff --git a/includes/api/ApiQueryIWBacklinks.php b/includes/api/ApiQueryIWBacklinks.php index c5012f085d..283115d80b 100644 --- a/includes/api/ApiQueryIWBacklinks.php +++ b/includes/api/ApiQueryIWBacklinks.php @@ -56,10 +56,7 @@ class ApiQueryIWBacklinks extends ApiQueryGeneratorBase { if ( !is_null( $params['continue'] ) ) { $cont = explode( '|', $params['continue'] ); - if ( count( $cont ) != 3 ) { - $this->dieUsage( 'Invalid continue param. You should pass the ' . - 'original value returned by the previous query', '_badcontinue' ); - } + $this->dieContinueUsageIf( count( $cont ) != 3 ); $db = $this->getDB(); $op = $params['dir'] == 'descending' ? '<' : '>'; @@ -233,7 +230,6 @@ class ApiQueryIWBacklinks extends ApiQueryGeneratorBase { public function getPossibleErrors() { return array_merge( parent::getPossibleErrors(), array( array( 'missingparam', 'prefix' ), - array( 'code' => '_badcontinue', 'info' => 'Invalid continue param. You should pass the original value returned by the previous query' ), ) ); } diff --git a/includes/api/ApiQueryIWLinks.php b/includes/api/ApiQueryIWLinks.php index 30c7f5a801..8e8a075699 100644 --- a/includes/api/ApiQueryIWLinks.php +++ b/includes/api/ApiQueryIWLinks.php @@ -58,10 +58,7 @@ class ApiQueryIWLinks extends ApiQueryBase { if ( !is_null( $params['continue'] ) ) { $cont = explode( '|', $params['continue'] ); - if ( count( $cont ) != 3 ) { - $this->dieUsage( 'Invalid continue param. You should pass the ' . - 'original value returned by the previous query', '_badcontinue' ); - } + $this->dieContinueUsageIf( count( $cont ) != 3 ); $op = $params['dir'] == 'descending' ? '<' : '>'; $db = $this->getDB(); $iwlfrom = intval( $cont[0] ); @@ -187,7 +184,6 @@ class ApiQueryIWLinks extends ApiQueryBase { public function getPossibleErrors() { return array_merge( parent::getPossibleErrors(), array( array( 'missingparam', 'prefix' ), - array( 'code' => '_badcontinue', 'info' => 'Invalid continue param. You should pass the original value returned by the previous query' ), ) ); } diff --git a/includes/api/ApiQueryImageInfo.php b/includes/api/ApiQueryImageInfo.php index 0a0b5ddb0a..88c41a8a1d 100644 --- a/includes/api/ApiQueryImageInfo.php +++ b/includes/api/ApiQueryImageInfo.php @@ -56,10 +56,7 @@ class ApiQueryImageInfo extends ApiQueryBase { if ( !is_null( $params['continue'] ) ) { $skip = true; $cont = explode( '|', $params['continue'] ); - if ( count( $cont ) != 2 ) { - $this->dieUsage( 'Invalid continue param. You should pass the original ' . - 'value returned by the previous query', '_badcontinue' ); - } + $this->dieContinueUsageIf( count( $cont ) != 2 ); $fromTitle = strval( $cont[0] ); $fromTimestamp = $cont[1]; // Filter out any titles before $fromTitle diff --git a/includes/api/ApiQueryImages.php b/includes/api/ApiQueryImages.php index 6052a75f45..16d54aad06 100644 --- a/includes/api/ApiQueryImages.php +++ b/includes/api/ApiQueryImages.php @@ -62,10 +62,7 @@ class ApiQueryImages extends ApiQueryGeneratorBase { $this->addWhereFld( 'il_from', array_keys( $this->getPageSet()->getGoodTitles() ) ); if ( !is_null( $params['continue'] ) ) { $cont = explode( '|', $params['continue'] ); - if ( count( $cont ) != 2 ) { - $this->dieUsage( 'Invalid continue param. You should pass the ' . - 'original value returned by the previous query', '_badcontinue' ); - } + $this->dieContinueUsageIf( count( $cont ) != 2 ); $op = $params['dir'] == 'descending' ? '<' : '>'; $ilfrom = intval( $cont[0] ); $ilto = $this->getDB()->addQuotes( $cont[1] ); @@ -185,12 +182,6 @@ class ApiQueryImages extends ApiQueryGeneratorBase { return 'Returns all images contained on the given page(s)'; } - public function getPossibleErrors() { - return array_merge( parent::getPossibleErrors(), array( - array( 'code' => '_badcontinue', 'info' => 'Invalid continue param. You should pass the original value returned by the previous query' ), - ) ); - } - public function getExamples() { return array( 'api.php?action=query&prop=images&titles=Main%20Page' => 'Get a list of images used in the [[Main Page]]', diff --git a/includes/api/ApiQueryInfo.php b/includes/api/ApiQueryInfo.php index dd1326b4f0..efbd731fc2 100644 --- a/includes/api/ApiQueryInfo.php +++ b/includes/api/ApiQueryInfo.php @@ -268,10 +268,7 @@ class ApiQueryInfo extends ApiQueryBase { // Throw away any titles we're gonna skip so they don't // clutter queries $cont = explode( '|', $this->params['continue'] ); - if ( count( $cont ) != 2 ) { - $this->dieUsage( 'Invalid continue param. You should pass the original ' . - 'value returned by the previous query', '_badcontinue' ); - } + $this->dieContinueUsageIf( count( $cont ) != 2 ); $conttitle = Title::makeTitleSafe( $cont[0], $cont[1] ); foreach ( $this->everything as $pageid => $title ) { if ( Title::compare( $title, $conttitle ) >= 0 ) { @@ -809,12 +806,6 @@ class ApiQueryInfo extends ApiQueryBase { return 'Get basic page information such as namespace, title, last touched date, ...'; } - public function getPossibleErrors() { - return array_merge( parent::getPossibleErrors(), array( - array( 'code' => '_badcontinue', 'info' => 'Invalid continue param. You should pass the original value returned by the previous query' ), - ) ); - } - public function getExamples() { return array( 'api.php?action=query&prop=info&titles=Main%20Page', diff --git a/includes/api/ApiQueryLangBacklinks.php b/includes/api/ApiQueryLangBacklinks.php index 3920407b91..d6346d3ff4 100644 --- a/includes/api/ApiQueryLangBacklinks.php +++ b/includes/api/ApiQueryLangBacklinks.php @@ -56,10 +56,7 @@ class ApiQueryLangBacklinks extends ApiQueryGeneratorBase { if ( !is_null( $params['continue'] ) ) { $cont = explode( '|', $params['continue'] ); - if ( count( $cont ) != 3 ) { - $this->dieUsage( 'Invalid continue param. You should pass the ' . - 'original value returned by the previous query', '_badcontinue' ); - } + $this->dieContinueUsageIf( count( $cont ) != 3 ); $db = $this->getDB(); $op = $params['dir'] == 'descending' ? '<' : '>'; @@ -233,7 +230,6 @@ class ApiQueryLangBacklinks extends ApiQueryGeneratorBase { public function getPossibleErrors() { return array_merge( parent::getPossibleErrors(), array( array( 'missingparam', 'lang' ), - array( 'code' => '_badcontinue', 'info' => 'Invalid continue param. You should pass the original value returned by the previous query' ), ) ); } diff --git a/includes/api/ApiQueryLangLinks.php b/includes/api/ApiQueryLangLinks.php index 3109a09086..9c54cfa285 100644 --- a/includes/api/ApiQueryLangLinks.php +++ b/includes/api/ApiQueryLangLinks.php @@ -56,10 +56,7 @@ class ApiQueryLangLinks extends ApiQueryBase { $this->addWhereFld( 'll_from', array_keys( $this->getPageSet()->getGoodTitles() ) ); if ( !is_null( $params['continue'] ) ) { $cont = explode( '|', $params['continue'] ); - if ( count( $cont ) != 2 ) { - $this->dieUsage( 'Invalid continue param. You should pass the ' . - 'original value returned by the previous query', '_badcontinue' ); - } + $this->dieContinueUsageIf( count( $cont ) != 2 ); $op = $params['dir'] == 'descending' ? '<' : '>'; $llfrom = intval( $cont[0] ); $lllang = $this->getDB()->addQuotes( $cont[1] ); @@ -179,7 +176,6 @@ class ApiQueryLangLinks extends ApiQueryBase { public function getPossibleErrors() { return array_merge( parent::getPossibleErrors(), array( array( 'missingparam', 'lang' ), - array( 'code' => '_badcontinue', 'info' => 'Invalid continue param. You should pass the original value returned by the previous query' ), ) ); } diff --git a/includes/api/ApiQueryLinks.php b/includes/api/ApiQueryLinks.php index 9e4b7ebb36..54ee57c158 100644 --- a/includes/api/ApiQueryLinks.php +++ b/includes/api/ApiQueryLinks.php @@ -112,10 +112,7 @@ class ApiQueryLinks extends ApiQueryGeneratorBase { if ( !is_null( $params['continue'] ) ) { $cont = explode( '|', $params['continue'] ); - if ( count( $cont ) != 3 ) { - $this->dieUsage( 'Invalid continue param. You should pass the ' . - 'original value returned by the previous query', '_badcontinue' ); - } + $this->dieContinueUsageIf( count( $cont ) != 3 ); $op = $params['dir'] == 'descending' ? '<' : '>'; $plfrom = intval( $cont[0] ); $plns = intval( $cont[1] ); diff --git a/includes/api/ApiQueryRevisions.php b/includes/api/ApiQueryRevisions.php index e161f30e1a..ecf47a9bb4 100644 --- a/includes/api/ApiQueryRevisions.php +++ b/includes/api/ApiQueryRevisions.php @@ -338,10 +338,7 @@ class ApiQueryRevisions extends ApiQueryBase { if ( !is_null( $params['continue'] ) ) { $cont = explode( '|', $params['continue'] ); - if ( count( $cont ) != 2 ) { - $this->dieUsage( 'Invalid continue param. You should pass the original ' . - 'value returned by the previous query', '_badcontinue' ); - } + $this->dieContinueUsageIf( count( $cont ) != 2 ); $pageid = intval( $cont[0] ); $revid = intval( $cont[1] ); $this->addWhere( diff --git a/includes/api/ApiQueryUserContributions.php b/includes/api/ApiQueryUserContributions.php index f30b1325e1..96fea1a8e8 100644 --- a/includes/api/ApiQueryUserContributions.php +++ b/includes/api/ApiQueryUserContributions.php @@ -160,10 +160,7 @@ class ApiQueryContributions extends ApiQueryBase { // Handle continue parameter if ( $this->multiUserMode && !is_null( $this->params['continue'] ) ) { $continue = explode( '|', $this->params['continue'] ); - if ( count( $continue ) != 2 ) { - $this->dieUsage( 'Invalid continue param. You should pass the original ' . - 'value returned by the previous query', '_badcontinue' ); - } + $this->dieContinueUsageIf( count( $continue ) != 2 ); $db = $this->getDB(); $encUser = $db->addQuotes( $continue[0] ); $encTS = $db->addQuotes( $db->timestamp( $continue[1] ) ); diff --git a/includes/api/ApiQueryWatchlistRaw.php b/includes/api/ApiQueryWatchlistRaw.php index 6b24aef32e..27b6f747f7 100644 --- a/includes/api/ApiQueryWatchlistRaw.php +++ b/includes/api/ApiQueryWatchlistRaw.php @@ -71,11 +71,9 @@ class ApiQueryWatchlistRaw extends ApiQueryGeneratorBase { if ( isset( $params['continue'] ) ) { $cont = explode( '|', $params['continue'] ); - if ( count( $cont ) != 2 ) { - $this->dieUsage( "Invalid continue param. You should pass the " . - "original value returned by the previous query", "_badcontinue" ); - } + $this->dieContinueUsageIf( count( $cont ) != 2 ); $ns = intval( $cont[0] ); + $this->dieContinueUsageIf( strval( $ns ) !== $cont[0] ); $title = $this->getDB()->addQuotes( $cont[1] ); $op = $params['dir'] == 'ascending' ? '>' : '<'; $this->addWhere( -- 2.20.1