API Cleanup: renamed '_badcontinue'->'badcontinue', one die()
authorYuri Astrakhan <yuriastrakhan@gmail.com>
Tue, 15 Jan 2013 02:19:16 +0000 (21:19 -0500)
committerYuri Astrakhan <yuriastrakhan@gmail.com>
Tue, 15 Jan 2013 02:19:16 +0000 (21:19 -0500)
* 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

23 files changed:
RELEASE-NOTES-1.21
includes/api/ApiQueryAllCategories.php
includes/api/ApiQueryAllImages.php
includes/api/ApiQueryAllLinks.php
includes/api/ApiQueryAllPages.php
includes/api/ApiQueryBacklinks.php
includes/api/ApiQueryBase.php
includes/api/ApiQueryCategories.php
includes/api/ApiQueryCategoryMembers.php
includes/api/ApiQueryDeletedrevs.php
includes/api/ApiQueryDuplicateFiles.php
includes/api/ApiQueryFilearchive.php
includes/api/ApiQueryIWBacklinks.php
includes/api/ApiQueryIWLinks.php
includes/api/ApiQueryImageInfo.php
includes/api/ApiQueryImages.php
includes/api/ApiQueryInfo.php
includes/api/ApiQueryLangBacklinks.php
includes/api/ApiQueryLangLinks.php
includes/api/ApiQueryLinks.php
includes/api/ApiQueryRevisions.php
includes/api/ApiQueryUserContributions.php
includes/api/ApiQueryWatchlistRaw.php

index b8f3ba6..e2c5d5c 100644 (file)
@@ -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 ===
 
index c2beaec..6ada4aa 100644 (file)
@@ -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',
index 2319263..c78f0f3 100644 (file)
@@ -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' ),
                ) );
        }
 
index 3b478b0..620a394 100644 (file)
@@ -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' ),
                ) );
        }
 
index a5abae7..b180572 100644 (file)
@@ -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' ),
                ) );
        }
 
index 6f45726..bf918dd 100644 (file)
@@ -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' ),
                        )
                );
        }
index 5f4d9f9..e36109a 100644 (file)
@@ -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;
        }
 
        /**
index 309c2ce..f05bb26 100644 (file)
@@ -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] );
index a07b049..ca24f2b 100644 (file)
@@ -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' ),
                        )
                );
        }
index 8903e46..9eab651 100644 (file)
@@ -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" ),
index f088062..d4a486a 100644 (file)
@@ -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',
index 7ec47fa..fcffc4d 100644 (file)
@@ -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' ),
                ) );
        }
 
index c5012f0..283115d 100644 (file)
@@ -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' ),
                ) );
        }
 
index 30c7f5a..8e8a075 100644 (file)
@@ -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' ),
                ) );
        }
 
index 0a0b5dd..88c41a8 100644 (file)
@@ -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
index 6052a75..16d54aa 100644 (file)
@@ -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]]',
index dd1326b..efbd731 100644 (file)
@@ -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',
index 3920407..d6346d3 100644 (file)
@@ -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' ),
                ) );
        }
 
index 3109a09..9c54cfa 100644 (file)
@@ -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' ),
                ) );
        }
 
index 9e4b7eb..54ee57c 100644 (file)
@@ -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] );
index e161f30..ecf47a9 100644 (file)
@@ -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(
index f30b132..96fea1a 100644 (file)
@@ -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] ) );
index 6b24aef..27b6f74 100644 (file)
@@ -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(