From 2b3f4d821cd41fe3002e1cce15169d5b5700f7d8 Mon Sep 17 00:00:00 2001 From: Brad Jorsch Date: Mon, 21 May 2012 13:07:37 -0400 Subject: [PATCH] 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 --- RELEASE-NOTES-1.20 | 2 ++ includes/api/ApiQueryAllCategories.php | 24 ++++++++++++++-- includes/api/ApiQueryAllImages.php | 19 +++++++++++-- includes/api/ApiQueryAllLinks.php | 37 +++++++++++++++---------- includes/api/ApiQueryAllPages.php | 19 +++++++++++-- includes/api/ApiQueryCategories.php | 11 +++----- includes/api/ApiQueryDeletedrevs.php | 6 ++-- includes/api/ApiQueryDuplicateFiles.php | 12 +++----- includes/api/ApiQueryFilearchive.php | 22 +++++++++++++-- includes/api/ApiQueryIWBacklinks.php | 2 +- includes/api/ApiQueryIWLinks.php | 2 +- includes/api/ApiQueryImages.php | 11 +++----- includes/api/ApiQueryLangBacklinks.php | 2 +- includes/api/ApiQueryLinks.php | 11 +++----- includes/api/ApiQueryWatchlistRaw.php | 8 ++---- 15 files changed, 121 insertions(+), 67 deletions(-) diff --git a/RELEASE-NOTES-1.20 b/RELEASE-NOTES-1.20 index fdbc3ebbb0..37d4411337 100644 --- a/RELEASE-NOTES-1.20 +++ b/RELEASE-NOTES-1.20 @@ -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 === diff --git a/includes/api/ApiQueryAllCategories.php b/includes/api/ApiQueryAllCategories.php index a2fb5c364e..c81222ae33 100644 --- a/includes/api/ApiQueryAllCategories.php +++ b/includes/api/ApiQueryAllCategories.php @@ -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', diff --git a/includes/api/ApiQueryAllImages.php b/includes/api/ApiQueryAllImages.php index 4ab4d72ad7..995def1eed 100644 --- a/includes/api/ApiQueryAllImages.php +++ b/includes/api/ApiQueryAllImages.php @@ -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' ), ) ); } diff --git a/includes/api/ApiQueryAllLinks.php b/includes/api/ApiQueryAllLinks.php index 70b6656236..759b7a0e04 100644 --- a/includes/api/ApiQueryAllLinks.php +++ b/includes/api/ApiQueryAllLinks.php @@ -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; } diff --git a/includes/api/ApiQueryAllPages.php b/includes/api/ApiQueryAllPages.php index dec3d8a484..58fa4c75f8 100644 --- a/includes/api/ApiQueryAllPages.php +++ b/includes/api/ApiQueryAllPages.php @@ -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' ), ) ); } diff --git a/includes/api/ApiQueryCategories.php b/includes/api/ApiQueryCategories.php index 283eb13e8c..30901ab7df 100644 --- a/includes/api/ApiQueryCategories.php +++ b/includes/api/ApiQueryCategories.php @@ -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; } diff --git a/includes/api/ApiQueryDeletedrevs.php b/includes/api/ApiQueryDeletedrevs.php index df5e303a3f..449d24a0a2 100644 --- a/includes/api/ApiQueryDeletedrevs.php +++ b/includes/api/ApiQueryDeletedrevs.php @@ -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 ) ); } diff --git a/includes/api/ApiQueryDuplicateFiles.php b/includes/api/ApiQueryDuplicateFiles.php index 856d0fd78f..bc7a86f247 100644 --- a/includes/api/ApiQueryDuplicateFiles.php +++ b/includes/api/ApiQueryDuplicateFiles.php @@ -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; } } diff --git a/includes/api/ApiQueryFilearchive.php b/includes/api/ApiQueryFilearchive.php index 07d5b41082..eed9d7c8ed 100644 --- a/includes/api/ApiQueryFilearchive.php +++ b/includes/api/ApiQueryFilearchive.php @@ -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' ), ) ); } diff --git a/includes/api/ApiQueryIWBacklinks.php b/includes/api/ApiQueryIWBacklinks.php index 37f347d733..5361727aa8 100644 --- a/includes/api/ApiQueryIWBacklinks.php +++ b/includes/api/ApiQueryIWBacklinks.php @@ -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 " . diff --git a/includes/api/ApiQueryIWLinks.php b/includes/api/ApiQueryIWLinks.php index 7e69513b2f..9788e4eca5 100644 --- a/includes/api/ApiQueryIWLinks.php +++ b/includes/api/ApiQueryIWLinks.php @@ -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 " . diff --git a/includes/api/ApiQueryImages.php b/includes/api/ApiQueryImages.php index 3779123991..2ef6fa58f2 100644 --- a/includes/api/ApiQueryImages.php +++ b/includes/api/ApiQueryImages.php @@ -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 ); diff --git a/includes/api/ApiQueryLangBacklinks.php b/includes/api/ApiQueryLangBacklinks.php index c7639ee5f3..6248c35003 100644 --- a/includes/api/ApiQueryLangBacklinks.php +++ b/includes/api/ApiQueryLangBacklinks.php @@ -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 " . diff --git a/includes/api/ApiQueryLinks.php b/includes/api/ApiQueryLinks.php index 5cf9068247..aa2633dded 100644 --- a/includes/api/ApiQueryLinks.php +++ b/includes/api/ApiQueryLinks.php @@ -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 ); diff --git a/includes/api/ApiQueryWatchlistRaw.php b/includes/api/ApiQueryWatchlistRaw.php index 1b1eee06c4..38b17fcded 100644 --- a/includes/api/ApiQueryWatchlistRaw.php +++ b/includes/api/ApiQueryWatchlistRaw.php @@ -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 { -- 2.20.1