Avoid mangling fields in API continuation parameters

API continuation parameters encode sufficient state for a subsequent
query to continue where the previous one left off; this may sometimes
include page titles, with or without the namespace. Given that these
page titles are already in the exact format required for the next
request's SQL query, it is not necessary to "normalize" them in any way.
And if normalization does more than just change spaces to underscores or
vice versa (e.g. it canonicalizes namespace aliases or capitalizes the
first letter of the title), it can be actively harmful: see bug 36987
and bug 29290.

Note this patch involves a breaking API change: the values for the
"continue" parameter of various modules have been changed, and some
modules will now return "continue" as the continuation parameter instead
of reusing "from".

Note this patch also corrects a minor logic bug in ApiQueryAllLinks,
changing ">" to ">=". The line is being changed anyway, so I didn't
bother doing a separate changeset.

Change-Id: I459232e919d20f89f6de9d20640fd48c8fd5781c
This commit is contained in:
Brad Jorsch 2012-05-21 13:07:37 -04:00 committed by Catrope
parent 9386781706
commit 2b3f4d821c
15 changed files with 121 additions and 67 deletions

View file

@ -192,6 +192,8 @@ upgrade PHP if you have not done so prior to upgrading MediaWiki.
* API meta=siteinfo can now return the list of known variable IDs.
* (bug 30836) siteinfo prop=specialpagealiases will no longer return nonexistent special pages.
* (bug 35980) list=deletedrevs now honors drdir correctly in "all" mode (mode #3).
* (bug 29290) API avoids mangling fields in continuation parameters
* (bug 36987) API avoids mangling fields in continuation parameters
=== Languages updated in 1.20 ===

View file

@ -59,6 +59,17 @@ class ApiQueryAllCategories extends ApiQueryGeneratorBase {
$this->addFields( 'cat_title' );
$this->addWhere( 'cat_pages > 0' );
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" );
}
$op = $params['dir'] == 'descending' ? '<' : '>';
$cont_from = $db->addQuotes( $cont[0] );
$this->addWhere( "cat_title $op= $cont_from" );
}
$dir = ( $params['dir'] == 'descending' ? 'older' : 'newer' );
$from = ( is_null( $params['from'] ) ? null : $this->titlePartToKey( $params['from'] ) );
$to = ( is_null( $params['to'] ) ? null : $this->titlePartToKey( $params['to'] ) );
@ -105,8 +116,7 @@ class ApiQueryAllCategories extends ApiQueryGeneratorBase {
foreach ( $res as $row ) {
if ( ++ $count > $params['limit'] ) {
// We've reached the one extra which shows that there are additional cats to be had. Stop here...
// TODO: Security issue - if the user has no right to view next title, it will still be shown
$this->setContinueEnumParameter( 'from', $this->keyToTitle( $row->cat_title ) );
$this->setContinueEnumParameter( 'continue', $row->cat_title );
break;
}
@ -128,7 +138,7 @@ class ApiQueryAllCategories extends ApiQueryGeneratorBase {
}
$fit = $result->addValue( array( 'query', $this->getModuleName() ), null, $item );
if ( !$fit ) {
$this->setContinueEnumParameter( 'from', $this->keyToTitle( $row->cat_title ) );
$this->setContinueEnumParameter( 'continue', $row->cat_title );
break;
}
}
@ -144,6 +154,7 @@ class ApiQueryAllCategories extends ApiQueryGeneratorBase {
public function getAllowedParams() {
return array(
'from' => null,
'continue' => null,
'to' => null,
'prefix' => null,
'dir' => array(
@ -179,6 +190,7 @@ class ApiQueryAllCategories extends ApiQueryGeneratorBase {
public function getParamDescription() {
return array(
'from' => 'The category to start enumerating from',
'continue' => 'When more results are available, use this to continue',
'to' => 'The category to stop enumerating at',
'prefix' => 'Search for all category titles that begin with this value',
'dir' => 'Direction to sort in',
@ -214,6 +226,12 @@ 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',

View file

@ -85,6 +85,17 @@ class ApiQueryAllImages extends ApiQueryGeneratorBase {
$params = $this->extractRequestParams();
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" );
}
$op = $params['dir'] == 'descending' ? '<' : '>';
$cont_from = $db->addQuotes( $cont[0] );
$this->addWhere( "img_name $op= $cont_from" );
}
// Image filters
$dir = ( $params['dir'] == 'descending' ? 'older' : 'newer' );
$from = ( is_null( $params['from'] ) ? null : $this->titlePartToKey( $params['from'] ) );
@ -148,8 +159,7 @@ class ApiQueryAllImages extends ApiQueryGeneratorBase {
foreach ( $res as $row ) {
if ( ++ $count > $limit ) {
// We've reached the one extra which shows that there are additional pages to be had. Stop here...
// TODO: Security issue - if the user has no right to view next title, it will still be shown
$this->setContinueEnumParameter( 'from', $this->keyToTitle( $row->img_name ) );
$this->setContinueEnumParameter( 'continue', $row->img_name );
break;
}
@ -161,7 +171,7 @@ class ApiQueryAllImages extends ApiQueryGeneratorBase {
$fit = $result->addValue( array( 'query', $this->getModuleName() ), null, $info );
if ( !$fit ) {
$this->setContinueEnumParameter( 'from', $this->keyToTitle( $row->img_name ) );
$this->setContinueEnumParameter( 'continue', $row->img_name );
break;
}
} else {
@ -179,6 +189,7 @@ class ApiQueryAllImages extends ApiQueryGeneratorBase {
public function getAllowedParams() {
return array (
'from' => null,
'continue' => null,
'to' => null,
'prefix' => null,
'minsize' => array(
@ -215,6 +226,7 @@ class ApiQueryAllImages extends ApiQueryGeneratorBase {
public function getParamDescription() {
return array(
'from' => 'The image title to start enumerating from',
'continue' => 'When more results are available, use this to continue',
'to' => 'The image title to stop enumerating at',
'prefix' => 'Search for all image titles that begin with this value',
'dir' => 'The direction in which to list',
@ -254,6 +266,7 @@ 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' ),
) );
}

View file

@ -77,17 +77,25 @@ class ApiQueryAllLinks extends ApiQueryGeneratorBase {
}
if ( !is_null( $params['continue'] ) ) {
$continueArr = explode( '|', $params['continue'] );
if ( count( $continueArr ) != 2 ) {
$this->dieUsage( 'Invalid continue parameter', 'badcontinue' );
}
$op = $params['dir'] == 'descending' ? '<' : '>';
$continueTitle = $db->addQuotes( $this->titleToKey( $continueArr[0] ) );
$continueFrom = intval( $continueArr[1] );
$this->addWhere(
"pl_title $op $continueTitle OR " .
"(pl_title = $continueTitle AND " .
"pl_from $op= $continueFrom)"
);
if ( $params['unique'] ) {
if ( count( $continueArr ) != 1 ) {
$this->dieUsage( 'Invalid continue parameter', 'badcontinue' );
}
$continueTitle = $db->addQuotes( $continueArr[0] );
$this->addWhere( "pl_title $op= $continueTitle" );
} else {
if ( count( $continueArr ) != 2 ) {
$this->dieUsage( 'Invalid continue parameter', 'badcontinue' );
}
$continueTitle = $db->addQuotes( $continueArr[0] );
$continueFrom = intval( $continueArr[1] );
$this->addWhere(
"pl_title $op $continueTitle OR " .
"(pl_title = $continueTitle AND " .
"pl_from $op= $continueFrom)"
);
}
}
$from = ( is_null( $params['from'] ) ? null : $this->titlePartToKey( $params['from'] ) );
@ -121,11 +129,10 @@ class ApiQueryAllLinks extends ApiQueryGeneratorBase {
foreach ( $res as $row ) {
if ( ++ $count > $limit ) {
// We've reached the one extra which shows that there are additional pages to be had. Stop here...
// TODO: Security issue - if the user has no right to view next title, it will still be shown
if ( $params['unique'] ) {
$this->setContinueEnumParameter( 'from', $this->keyToTitle( $row->pl_title ) );
$this->setContinueEnumParameter( 'continue', $row->pl_title );
} else {
$this->setContinueEnumParameter( 'continue', $this->keyToTitle( $row->pl_title ) . "|" . $row->pl_from );
$this->setContinueEnumParameter( 'continue', $row->pl_title . "|" . $row->pl_from );
}
break;
}
@ -142,9 +149,9 @@ class ApiQueryAllLinks extends ApiQueryGeneratorBase {
$fit = $result->addValue( array( 'query', $this->getModuleName() ), null, $vals );
if ( !$fit ) {
if ( $params['unique'] ) {
$this->setContinueEnumParameter( 'from', $this->keyToTitle( $row->pl_title ) );
$this->setContinueEnumParameter( 'continue', $row->pl_title );
} else {
$this->setContinueEnumParameter( 'continue', $this->keyToTitle( $row->pl_title ) . "|" . $row->pl_from );
$this->setContinueEnumParameter( 'continue', $row->pl_title . "|" . $row->pl_from );
}
break;
}

View file

@ -67,6 +67,17 @@ class ApiQueryAllPages extends ApiQueryGeneratorBase {
// Page filters
$this->addTables( 'page' );
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" );
}
$op = $params['dir'] == 'descending' ? '<' : '>';
$cont_from = $db->addQuotes( $cont[0] );
$this->addWhere( "page_title $op= $cont_from" );
}
if ( $params['filterredir'] == 'redirects' ) {
$this->addWhereFld( 'page_is_redirect', 1 );
} elseif ( $params['filterredir'] == 'nonredirects' ) {
@ -180,8 +191,7 @@ class ApiQueryAllPages extends ApiQueryGeneratorBase {
foreach ( $res as $row ) {
if ( ++ $count > $limit ) {
// We've reached the one extra which shows that there are additional pages to be had. Stop here...
// TODO: Security issue - if the user has no right to view next title, it will still be shown
$this->setContinueEnumParameter( 'from', $this->keyToTitle( $row->page_title ) );
$this->setContinueEnumParameter( 'continue', $row->page_title );
break;
}
@ -194,7 +204,7 @@ class ApiQueryAllPages extends ApiQueryGeneratorBase {
);
$fit = $result->addValue( array( 'query', $this->getModuleName() ), null, $vals );
if ( !$fit ) {
$this->setContinueEnumParameter( 'from', $this->keyToTitle( $row->page_title ) );
$this->setContinueEnumParameter( 'continue', $row->page_title );
break;
}
} else {
@ -212,6 +222,7 @@ class ApiQueryAllPages extends ApiQueryGeneratorBase {
return array(
'from' => null,
'continue' => null,
'to' => null,
'prefix' => null,
'namespace' => array(
@ -285,6 +296,7 @@ class ApiQueryAllPages extends ApiQueryGeneratorBase {
$p = $this->getModulePrefix();
return array(
'from' => 'The page title to start enumerating from',
'continue' => 'When more results are available, use this to continue',
'to' => 'The page title to stop enumerating at',
'prefix' => 'Search for all page titles that begin with this value',
'namespace' => 'The namespace to enumerate',
@ -324,6 +336,7 @@ 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' ),
) );
}

View file

@ -91,7 +91,7 @@ class ApiQueryCategories extends ApiQueryGeneratorBase {
}
$op = $params['dir'] == 'descending' ? '<' : '>';
$clfrom = intval( $cont[0] );
$clto = $this->getDB()->addQuotes( $this->titleToKey( $cont[1] ) );
$clto = $this->getDB()->addQuotes( $cont[1] );
$this->addWhere(
"cl_from $op $clfrom OR " .
"(cl_from = $clfrom AND " .
@ -143,8 +143,7 @@ class ApiQueryCategories extends ApiQueryGeneratorBase {
if ( ++$count > $params['limit'] ) {
// We've reached the one extra which shows that
// there are additional pages to be had. Stop here...
$this->setContinueEnumParameter( 'continue', $row->cl_from .
'|' . $this->keyToTitle( $row->cl_to ) );
$this->setContinueEnumParameter( 'continue', $row->cl_from . '|' . $row->cl_to );
break;
}
@ -164,8 +163,7 @@ class ApiQueryCategories extends ApiQueryGeneratorBase {
$fit = $this->addPageSubItem( $row->cl_from, $vals );
if ( !$fit ) {
$this->setContinueEnumParameter( 'continue', $row->cl_from .
'|' . $this->keyToTitle( $row->cl_to ) );
$this->setContinueEnumParameter( 'continue', $row->cl_from . '|' . $row->cl_to );
break;
}
}
@ -175,8 +173,7 @@ class ApiQueryCategories extends ApiQueryGeneratorBase {
if ( ++$count > $params['limit'] ) {
// We've reached the one extra which shows that
// there are additional pages to be had. Stop here...
$this->setContinueEnumParameter( 'continue', $row->cl_from .
'|' . $this->keyToTitle( $row->cl_to ) );
$this->setContinueEnumParameter( 'continue', $row->cl_from . '|' . $row->cl_to );
break;
}

View file

@ -164,7 +164,7 @@ class ApiQueryDeletedrevs extends ApiQueryBase {
$this->dieUsage( 'Invalid continue param. You should pass the original value returned by the previous query', 'badcontinue' );
}
$ns = intval( $cont[0] );
$title = $db->addQuotes( $this->titleToKey( $cont[1] ) );
$title = $db->addQuotes( $cont[1] );
$ts = $db->addQuotes( $db->timestamp( $cont[2] ) );
$op = ( $dir == 'newer' ? '>' : '<' );
$this->addWhere( "ar_namespace $op $ns OR " .
@ -203,7 +203,7 @@ class ApiQueryDeletedrevs extends ApiQueryBase {
// We've had enough
if ( $mode == 'all' || $mode == 'revs' ) {
$this->setContinueEnumParameter( 'continue', intval( $row->ar_namespace ) . '|' .
$this->keyToTitle( $row->ar_title ) . '|' . $row->ar_timestamp );
$row->ar_title . '|' . $row->ar_timestamp );
} else {
$this->setContinueEnumParameter( 'start', wfTimestamp( TS_ISO_8601, $row->ar_timestamp ) );
}
@ -269,7 +269,7 @@ class ApiQueryDeletedrevs extends ApiQueryBase {
if ( !$fit ) {
if ( $mode == 'all' || $mode == 'revs' ) {
$this->setContinueEnumParameter( 'continue', intval( $row->ar_namespace ) . '|' .
$this->keyToTitle( $row->ar_title ) . '|' . $row->ar_timestamp );
$row->ar_title . '|' . $row->ar_timestamp );
} else {
$this->setContinueEnumParameter( 'start', wfTimestamp( TS_ISO_8601, $row->ar_timestamp ) );
}

View file

@ -82,8 +82,8 @@ class ApiQueryDuplicateFiles extends ApiQueryGeneratorBase {
}
$op = $params['dir'] == 'descending' ? '<' : '>';
$db = $this->getDB();
$orig = $db->addQuotes( $this->titleTokey( $cont[0] ) );
$dup = $db->addQuotes( $this->titleToKey( $cont[1] ) );
$orig = $db->addQuotes( $cont[0] );
$dup = $db->addQuotes( $cont[1] );
$this->addWhere(
"i1.img_name $op $orig OR " .
"(i1.img_name = $orig AND " .
@ -110,9 +110,7 @@ class ApiQueryDuplicateFiles extends ApiQueryGeneratorBase {
if ( ++$count > $params['limit'] ) {
// We've reached the one extra which shows that
// there are additional pages to be had. Stop here...
$this->setContinueEnumParameter( 'continue',
$this->keyToTitle( $row->orig_name ) . '|' .
$this->keyToTitle( $row->dup_name ) );
$this->setContinueEnumParameter( 'continue', $row->orig_name . '|' . $row->dup_name );
break;
}
if ( !is_null( $resultPageSet ) ) {
@ -125,9 +123,7 @@ class ApiQueryDuplicateFiles extends ApiQueryGeneratorBase {
);
$fit = $this->addPageSubItem( $images[$row->orig_name], $r );
if ( !$fit ) {
$this->setContinueEnumParameter( 'continue',
$this->keyToTitle( $row->orig_name ) . '|' .
$this->keyToTitle( $row->dup_name ) );
$this->setContinueEnumParameter( 'continue', $row->orig_name . '|' . $row->dup_name );
break;
}
}

View file

@ -73,9 +73,23 @@ class ApiQueryFilearchive extends ApiQueryBase {
$this->addFieldsIf( 'fa_metadata', $fld_metadata );
$this->addFieldsIf( 'fa_bits', $fld_bitdepth );
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" );
}
$op = $params['dir'] == 'descending' ? '<' : '>';
$cont_from = $db->addQuotes( $cont[0] );
$this->addWhere( "fa_name $op= $cont_from" );
}
// Image filters
$dir = ( $params['dir'] == 'descending' ? 'older' : 'newer' );
$from = ( is_null( $params['from'] ) ? null : $this->titlePartToKey( $params['from'] ) );
if ( !is_null( $params['continue'] ) ) {
$from = $params['continue'];
}
$to = ( is_null( $params['to'] ) ? null : $this->titlePartToKey( $params['to'] ) );
$this->addWhereRange( 'fa_name', $dir, $from, $to );
if ( isset( $params['prefix'] ) ) {
@ -129,8 +143,7 @@ class ApiQueryFilearchive extends ApiQueryBase {
foreach ( $res as $row ) {
if ( ++$count > $limit ) {
// We've reached the one extra which shows that there are additional pages to be had. Stop here...
// TODO: Security issue - if the user has no right to view next title, it will still be shown
$this->setContinueEnumParameter( 'from', $this->keyToTitle( $row->fa_name ) );
$this->setContinueEnumParameter( 'continue', $row->fa_name );
break;
}
@ -199,7 +212,7 @@ class ApiQueryFilearchive extends ApiQueryBase {
$fit = $result->addValue( array( 'query', $this->getModuleName() ), null, $file );
if ( !$fit ) {
$this->setContinueEnumParameter( 'from', $this->keyToTitle( $row->fa_name ) );
$this->setContinueEnumParameter( 'continue', $row->fa_name );
break;
}
}
@ -210,6 +223,7 @@ class ApiQueryFilearchive extends ApiQueryBase {
public function getAllowedParams() {
return array (
'from' => null,
'continue' => null,
'to' => null,
'prefix' => null,
'limit' => array(
@ -251,6 +265,7 @@ class ApiQueryFilearchive extends ApiQueryBase {
public function getParamDescription() {
return array(
'from' => 'The image title to start enumerating from',
'continue' => 'When more results are available, use this to continue',
'to' => 'The image title to stop enumerating at',
'prefix' => 'Search for all image titles that begin with this value',
'dir' => 'The direction in which to list',
@ -345,6 +360,7 @@ 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' ),
) );
}

View file

@ -64,7 +64,7 @@ class ApiQueryIWBacklinks extends ApiQueryGeneratorBase {
$db = $this->getDB();
$op = $params['dir'] == 'descending' ? '<' : '>';
$prefix = $db->addQuotes( $cont[0] );
$title = $db->addQuotes( $this->titleToKey( $cont[1] ) );
$title = $db->addQuotes( $cont[1] );
$from = intval( $cont[2] );
$this->addWhere(
"iwl_prefix $op $prefix OR " .

View file

@ -66,7 +66,7 @@ class ApiQueryIWLinks extends ApiQueryBase {
$db = $this->getDB();
$iwlfrom = intval( $cont[0] );
$iwlprefix = $db->addQuotes( $cont[1] );
$iwltitle = $db->addQuotes( $this->titleToKey( $cont[2] ) );
$iwltitle = $db->addQuotes( $cont[2] );
$this->addWhere(
"iwl_from $op $iwlfrom OR " .
"(iwl_from = $iwlfrom AND " .

View file

@ -68,7 +68,7 @@ class ApiQueryImages extends ApiQueryGeneratorBase {
}
$op = $params['dir'] == 'descending' ? '<' : '>';
$ilfrom = intval( $cont[0] );
$ilto = $this->getDB()->addQuotes( $this->titleToKey( $cont[1] ) );
$ilto = $this->getDB()->addQuotes( $cont[1] );
$this->addWhere(
"il_from $op $ilfrom OR " .
"(il_from = $ilfrom AND " .
@ -109,16 +109,14 @@ class ApiQueryImages extends ApiQueryGeneratorBase {
if ( ++$count > $params['limit'] ) {
// We've reached the one extra which shows that
// there are additional pages to be had. Stop here...
$this->setContinueEnumParameter( 'continue', $row->il_from .
'|' . $this->keyToTitle( $row->il_to ) );
$this->setContinueEnumParameter( 'continue', $row->il_from . '|' . $row->il_to );
break;
}
$vals = array();
ApiQueryBase::addTitleInfo( $vals, Title::makeTitle( NS_FILE, $row->il_to ) );
$fit = $this->addPageSubItem( $row->il_from, $vals );
if ( !$fit ) {
$this->setContinueEnumParameter( 'continue', $row->il_from .
'|' . $this->keyToTitle( $row->il_to ) );
$this->setContinueEnumParameter( 'continue', $row->il_from . '|' . $row->il_to );
break;
}
}
@ -129,8 +127,7 @@ class ApiQueryImages extends ApiQueryGeneratorBase {
if ( ++$count > $params['limit'] ) {
// We've reached the one extra which shows that
// there are additional pages to be had. Stop here...
$this->setContinueEnumParameter( 'continue', $row->il_from .
'|' . $this->keyToTitle( $row->il_to ) );
$this->setContinueEnumParameter( 'continue', $row->il_from . '|' . $row->il_to );
break;
}
$titles[] = Title::makeTitle( NS_FILE, $row->il_to );

View file

@ -64,7 +64,7 @@ class ApiQueryLangBacklinks extends ApiQueryGeneratorBase {
$db = $this->getDB();
$op = $params['dir'] == 'descending' ? '<' : '>';
$prefix = $db->addQuotes( $cont[0] );
$title = $db->addQuotes( $this->titleToKey( $cont[1] ) );
$title = $db->addQuotes( $cont[1] );
$from = intval( $cont[2] );
$this->addWhere(
"ll_lang $op $prefix OR " .

View file

@ -119,7 +119,7 @@ class ApiQueryLinks extends ApiQueryGeneratorBase {
$op = $params['dir'] == 'descending' ? '<' : '>';
$plfrom = intval( $cont[0] );
$plns = intval( $cont[1] );
$pltitle = $this->getDB()->addQuotes( $this->titleToKey( $cont[2] ) );
$pltitle = $this->getDB()->addQuotes( $cont[2] );
$this->addWhere(
"{$this->prefix}_from $op $plfrom OR " .
"({$this->prefix}_from = $plfrom AND " .
@ -157,8 +157,7 @@ class ApiQueryLinks extends ApiQueryGeneratorBase {
// We've reached the one extra which shows that
// there are additional pages to be had. Stop here...
$this->setContinueEnumParameter( 'continue',
"{$row->pl_from}|{$row->pl_namespace}|" .
$this->keyToTitle( $row->pl_title ) );
"{$row->pl_from}|{$row->pl_namespace}|{$row->pl_title}" );
break;
}
$vals = array();
@ -166,8 +165,7 @@ class ApiQueryLinks extends ApiQueryGeneratorBase {
$fit = $this->addPageSubItem( $row->pl_from, $vals );
if ( !$fit ) {
$this->setContinueEnumParameter( 'continue',
"{$row->pl_from}|{$row->pl_namespace}|" .
$this->keyToTitle( $row->pl_title ) );
"{$row->pl_from}|{$row->pl_namespace}|{$row->pl_title}" );
break;
}
}
@ -179,8 +177,7 @@ class ApiQueryLinks extends ApiQueryGeneratorBase {
// We've reached the one extra which shows that
// there are additional pages to be had. Stop here...
$this->setContinueEnumParameter( 'continue',
"{$row->pl_from}|{$row->pl_namespace}|" .
$this->keyToTitle( $row->pl_title ) );
"{$row->pl_from}|{$row->pl_namespace}|{$row->pl_title}" );
break;
}
$titles[] = Title::makeTitle( $row->pl_namespace, $row->pl_title );

View file

@ -76,7 +76,7 @@ class ApiQueryWatchlistRaw extends ApiQueryGeneratorBase {
"original value returned by the previous query", "_badcontinue" );
}
$ns = intval( $cont[0] );
$title = $this->getDB()->addQuotes( $this->titleToKey( $cont[1] ) );
$title = $this->getDB()->addQuotes( $cont[1] );
$op = $params['dir'] == 'ascending' ? '>' : '<';
$this->addWhere(
"wl_namespace $op $ns OR " .
@ -103,8 +103,7 @@ class ApiQueryWatchlistRaw extends ApiQueryGeneratorBase {
foreach ( $res as $row ) {
if ( ++$count > $params['limit'] ) {
// We've reached the one extra which shows that there are additional pages to be had. Stop here...
$this->setContinueEnumParameter( 'continue', $row->wl_namespace . '|' .
$this->keyToTitle( $row->wl_title ) );
$this->setContinueEnumParameter( 'continue', $row->wl_namespace . '|' . $row->wl_title );
break;
}
$t = Title::makeTitle( $row->wl_namespace, $row->wl_title );
@ -118,8 +117,7 @@ class ApiQueryWatchlistRaw extends ApiQueryGeneratorBase {
}
$fit = $this->getResult()->addValue( $this->getModuleName(), null, $vals );
if ( !$fit ) {
$this->setContinueEnumParameter( 'continue', $row->wl_namespace . '|' .
$this->keyToTitle( $row->wl_title ) );
$this->setContinueEnumParameter( 'continue', $row->wl_namespace . '|' . $row->wl_title );
break;
}
} else {