2006-10-25 17:16:37 +00:00
< ? php
/*
* Created on Oct 16 , 2006
*
* API for MediaWiki 1.8 +
*
2007-05-20 23:31:44 +00:00
* Copyright ( C ) 2006 Yuri Astrakhan < Firstname >< Lastname >@ gmail . com
2006-10-25 17:16:37 +00:00
*
* This program is free software ; you can redistribute it and / or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation ; either version 2 of the License , or
* ( at your option ) any later version .
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License along
* with this program ; if not , write to the Free Software Foundation , Inc . ,
* 59 Temple Place - Suite 330 , Boston , MA 02111 - 1307 , USA .
* http :// www . gnu . org / copyleft / gpl . html
*/
2010-01-11 15:55:52 +00:00
if ( ! defined ( 'MEDIAWIKI' ) ) {
2006-10-25 17:16:37 +00:00
// Eclipse helper - will be ignored in production
2010-02-24 13:34:11 +00:00
require_once ( " ApiQueryBase.php " );
2006-10-25 17:16:37 +00:00
}
2007-04-20 08:55:14 +00:00
/**
2008-07-10 14:28:09 +00:00
* This is a three - in - one module to query :
2007-05-20 23:31:44 +00:00
* * backlinks - links pointing to the given page ,
* * embeddedin - what pages transclude the given page within themselves ,
* * imageusage - what pages use the given image
2008-04-14 07:45:50 +00:00
*
WARNING: HUGE COMMIT
Doxygen documentation update:
* Changed alls @addtogroup to @ingroup. @addtogroup adds the comment to the group description, but doesn't add the file, class, function, ... to the group like @ingroup does. See for example http://svn.wikimedia.org/doc/group__SpecialPage.html where it's impossible to see related files, classes, ... that should belong to that group.
* Added @file to file description, it seems that it should be explicitely decalred for file descriptions, otherwise doxygen will think that the comment document the first class, variabled, function, ... that is in that file.
* Removed some empty comments
* Removed some ?>
Added following groups:
* ExternalStorage
* JobQueue
* MaintenanceLanguage
One more thing: there are still a lot of warnings when generating the doc.
2008-05-20 17:13:28 +00:00
* @ ingroup API
2007-04-20 08:55:14 +00:00
*/
2006-10-25 17:16:37 +00:00
class ApiQueryBacklinks extends ApiQueryGeneratorBase {
* API: BREAKING CHANGE: (bug 11430) Return fewer results than the limit in some cases to prevent running out of memory
* This means queries could possibly return fewer results than the limit and still set a query-continue
* Add iicontinue, rvcontinue, cicontinue, incontinue, amfrom to faciliate query-continue for these modules
* Implemented by blocking additions to the ApiResult object if they would make it too large
** Important things like query-continue values and warnings are exempt from this check
** RSS feeds and exported XML are also exempted (size-checking them would be too messy)
** Result size is checked against $wgAPIMaxResultSize, which defaults to 8 MB
For those who really care, per-file details follow:
ApiResult.php:
* Introduced ApiResult::$mSize which keeps track of the result size.
* Introduced ApiResult::size() which calculates an array's size
(which is the sum of the strlen()s of its elements).
* ApiResult::addValue() now checks that the result size stays below
$wgAPIMaxResultSize. If the item won't fit, it won't be added and addValue()
will return false. Callers should check the return value and set a
query-continue if it's false.
* Closed the back door that is ApiResult::getData(): callers can't manipulate
the data array directly anymore so they can't bypass the result size limit.
* Added ApiResult::setIndexedTagName_internal() which will call
setIndexedTagName() on an array already in the result. This is needed for the
'new' order of adding results, which means addValue()ing one result at a time
until you hit the limit or run out, then calling this function to set the tag
name.
* Added ApiResult::disableSizeCheck() and enableSizeCheck() which disable and
enable size checking in addValue(). This is used for stuff like query-continue
elements and warnings which shouldn't count towards the result size.
* Added ApiResult::unsetValue() which removes an element from the result and
decreases $mSize.
ApiBase.php:
* Like ApiResult::getData(), ApiBase::getResultData() no longer returns a
reference.
* Use ApiResult::disableSizeCheck() in ApiBase::setWarning()
ApiQueryBase.php:
* Added ApiQueryBase::addPageSubItem(), which adds page subitems one item
at a time.
* addPageSubItem() and addPageSubItems() now return whether the subitem
fit in the result.
* Use ApiResult::disableSizeCheck() in setContinueEnumParameter()
ApiMain.php:
* Use ApiResult::disableSizeCheck() in ApiMain::substituteResultWithError()
* Use getParameter() rather than $mRequest to obtain requestid
DefaultSettings.php:
* Added $wgAPIMaxResultSize, with a default value of 8 MB
ApiQuery*.php:
* Added results one at a time, and set a query-continue if the result is full.
ApiQueryLangLinks.php and friends:
* Migrated from addPageSubItems() to addPageSubItem(). This eliminates the
need for $lastId.
ApiQueryAllLinks.php, ApiQueryWatchlist.php, ApiQueryAllimages.php, ApiQuerySearch.php:
* Renamed $data to something more appropriate ($pageids, $ids or $titles)
ApiQuerySiteinfo.php:
* Abuse siprop as a query-continue parameter and set it to all props that
couldn't be processed.
ApiQueryRandom.php:
* Doesn't do continuations, because the result is supposed to be random.
* Be smart enough to not run the second query if the results of the first
didn't fit.
ApiQueryImageInfo.php, ApiQueryRevisions.php, ApiQueryCategoryInfo.php, ApiQueryInfo.php:
* Added continue parameter which basically skips the first so many items
ApiQueryBacklinks.php:
* Throw the result in a big array first and addValue() that one element at a time if necessary
** This is necessary because the results aren't retrieved in order
* Introduced $this->pageMap to map namespace and title to page ID
* Rewritten extractRowInfo() and extractRedirRowInfo() a little
* Declared all private member variables explicitly
ApiQueryDeletedrevs.php:
* Use a pagemap just like in Backlinks
* Introduce fake page IDs and keep track of them so we know where to add what
** This doesn't change the output format, because the fake page IDs start at 0 and are consecutive
ApiQueryAllmessages.php:
* Add amfrom to facilitate query-continue
ApiQueryUsers.php:
* Rewrite: put the getOtherUsersInfo() code in execute()
2009-02-05 14:30:59 +00:00
private $params , $rootTitle , $contRedirs , $contLevel , $contTitle , $contID , $redirID , $redirect ;
private $bl_ns , $bl_from , $bl_table , $bl_code , $bl_title , $bl_sort , $bl_fields , $hasNS ;
private $pageMap , $resultArr ;
2006-10-25 17:16:37 +00:00
2008-04-14 07:45:50 +00:00
// output element name, database column field prefix, database table
2010-02-24 13:34:11 +00:00
private $backlinksSettings = array (
'backlinks' => array (
2006-10-30 00:18:05 +00:00
'code' => 'bl' ,
'prefix' => 'pl' ,
'linktbl' => 'pagelinks'
),
2010-02-24 13:34:11 +00:00
'embeddedin' => array (
2006-10-30 00:18:05 +00:00
'code' => 'ei' ,
'prefix' => 'tl' ,
'linktbl' => 'templatelinks'
),
2010-02-24 13:34:11 +00:00
'imageusage' => array (
2007-05-14 05:28:06 +00:00
'code' => 'iu' ,
2006-10-30 00:18:05 +00:00
'prefix' => 'il' ,
'linktbl' => 'imagelinks'
)
);
2010-01-11 15:55:52 +00:00
public function __construct ( $query , $moduleName ) {
extract ( $this -> backlinksSettings [ $moduleName ] );
* API: BREAKING CHANGE: (bug 11430) Return fewer results than the limit in some cases to prevent running out of memory
* This means queries could possibly return fewer results than the limit and still set a query-continue
* Add iicontinue, rvcontinue, cicontinue, incontinue, amfrom to faciliate query-continue for these modules
* Implemented by blocking additions to the ApiResult object if they would make it too large
** Important things like query-continue values and warnings are exempt from this check
** RSS feeds and exported XML are also exempted (size-checking them would be too messy)
** Result size is checked against $wgAPIMaxResultSize, which defaults to 8 MB
For those who really care, per-file details follow:
ApiResult.php:
* Introduced ApiResult::$mSize which keeps track of the result size.
* Introduced ApiResult::size() which calculates an array's size
(which is the sum of the strlen()s of its elements).
* ApiResult::addValue() now checks that the result size stays below
$wgAPIMaxResultSize. If the item won't fit, it won't be added and addValue()
will return false. Callers should check the return value and set a
query-continue if it's false.
* Closed the back door that is ApiResult::getData(): callers can't manipulate
the data array directly anymore so they can't bypass the result size limit.
* Added ApiResult::setIndexedTagName_internal() which will call
setIndexedTagName() on an array already in the result. This is needed for the
'new' order of adding results, which means addValue()ing one result at a time
until you hit the limit or run out, then calling this function to set the tag
name.
* Added ApiResult::disableSizeCheck() and enableSizeCheck() which disable and
enable size checking in addValue(). This is used for stuff like query-continue
elements and warnings which shouldn't count towards the result size.
* Added ApiResult::unsetValue() which removes an element from the result and
decreases $mSize.
ApiBase.php:
* Like ApiResult::getData(), ApiBase::getResultData() no longer returns a
reference.
* Use ApiResult::disableSizeCheck() in ApiBase::setWarning()
ApiQueryBase.php:
* Added ApiQueryBase::addPageSubItem(), which adds page subitems one item
at a time.
* addPageSubItem() and addPageSubItems() now return whether the subitem
fit in the result.
* Use ApiResult::disableSizeCheck() in setContinueEnumParameter()
ApiMain.php:
* Use ApiResult::disableSizeCheck() in ApiMain::substituteResultWithError()
* Use getParameter() rather than $mRequest to obtain requestid
DefaultSettings.php:
* Added $wgAPIMaxResultSize, with a default value of 8 MB
ApiQuery*.php:
* Added results one at a time, and set a query-continue if the result is full.
ApiQueryLangLinks.php and friends:
* Migrated from addPageSubItems() to addPageSubItem(). This eliminates the
need for $lastId.
ApiQueryAllLinks.php, ApiQueryWatchlist.php, ApiQueryAllimages.php, ApiQuerySearch.php:
* Renamed $data to something more appropriate ($pageids, $ids or $titles)
ApiQuerySiteinfo.php:
* Abuse siprop as a query-continue parameter and set it to all props that
couldn't be processed.
ApiQueryRandom.php:
* Doesn't do continuations, because the result is supposed to be random.
* Be smart enough to not run the second query if the results of the first
didn't fit.
ApiQueryImageInfo.php, ApiQueryRevisions.php, ApiQueryCategoryInfo.php, ApiQueryInfo.php:
* Added continue parameter which basically skips the first so many items
ApiQueryBacklinks.php:
* Throw the result in a big array first and addValue() that one element at a time if necessary
** This is necessary because the results aren't retrieved in order
* Introduced $this->pageMap to map namespace and title to page ID
* Rewritten extractRowInfo() and extractRedirRowInfo() a little
* Declared all private member variables explicitly
ApiQueryDeletedrevs.php:
* Use a pagemap just like in Backlinks
* Introduce fake page IDs and keep track of them so we know where to add what
** This doesn't change the output format, because the fake page IDs start at 0 and are consecutive
ApiQueryAllmessages.php:
* Add amfrom to facilitate query-continue
ApiQueryUsers.php:
* Rewrite: put the getOtherUsersInfo() code in execute()
2009-02-05 14:30:59 +00:00
$this -> resultArr = array ();
2006-10-30 00:18:05 +00:00
2010-02-24 13:34:11 +00:00
parent :: __construct ( $query , $moduleName , $code );
2006-10-30 00:18:05 +00:00
$this -> bl_ns = $prefix . '_namespace' ;
$this -> bl_from = $prefix . '_from' ;
2008-02-25 14:32:57 +00:00
$this -> bl_table = $linktbl ;
2006-10-30 00:18:05 +00:00
$this -> bl_code = $code ;
2007-05-14 05:28:06 +00:00
$this -> hasNS = $moduleName !== 'imageusage' ;
2010-01-11 15:55:52 +00:00
if ( $this -> hasNS ) {
2006-10-30 00:18:05 +00:00
$this -> bl_title = $prefix . '_title' ;
$this -> bl_sort = " { $this -> bl_ns } , { $this -> bl_title } , { $this -> bl_from } " ;
2010-02-24 13:34:11 +00:00
$this -> bl_fields = array (
2006-10-30 00:18:05 +00:00
$this -> bl_ns ,
$this -> bl_title
);
} else {
$this -> bl_title = $prefix . '_to' ;
$this -> bl_sort = " { $this -> bl_title } , { $this -> bl_from } " ;
2010-02-24 13:34:11 +00:00
$this -> bl_fields = array (
2006-10-30 00:18:05 +00:00
$this -> bl_title
);
}
2006-10-25 17:16:37 +00:00
}
public function execute () {
$this -> run ();
}
2010-01-11 15:55:52 +00:00
public function executeGenerator ( $resultPageSet ) {
$this -> run ( $resultPageSet );
2006-10-25 17:16:37 +00:00
}
2008-04-14 07:45:50 +00:00
2010-01-11 15:55:52 +00:00
private function prepareFirstQuery ( $resultPageSet = null ) {
2008-02-25 14:32:57 +00:00
/* SELECT page_id , page_title , page_namespace , page_is_redirect
2008-05-10 10:49:26 +00:00
* FROM pagelinks , page WHERE pl_from = page_id
* AND pl_title = 'Foo' AND pl_namespace = 0
2008-02-25 14:32:57 +00:00
* LIMIT 11 ORDER BY pl_from
*/
2008-11-06 22:38:42 +00:00
$db = $this -> getDB ();
2010-01-11 15:55:52 +00:00
$this -> addTables ( array ( $this -> bl_table , 'page' ) );
$this -> addWhere ( " { $this -> bl_from } =page_id " );
2010-02-24 13:34:11 +00:00
if ( is_null ( $resultPageSet ) ) {
2010-01-11 15:55:52 +00:00
$this -> addFields ( array ( 'page_id' , 'page_title' , 'page_namespace' ) );
2010-02-24 13:34:11 +00:00
} else {
2010-01-11 15:55:52 +00:00
$this -> addFields ( $resultPageSet -> getPageTableFields () );
2010-02-24 13:34:11 +00:00
}
2010-01-23 22:47:49 +00:00
2010-01-11 15:55:52 +00:00
$this -> addFields ( 'page_is_redirect' );
$this -> addWhereFld ( $this -> bl_title , $this -> rootTitle -> getDBkey () );
2010-01-23 22:47:49 +00:00
2010-02-24 13:34:11 +00:00
if ( $this -> hasNS ) {
2010-01-11 15:55:52 +00:00
$this -> addWhereFld ( $this -> bl_ns , $this -> rootTitle -> getNamespace () );
2010-02-24 13:34:11 +00:00
}
2010-01-11 15:55:52 +00:00
$this -> addWhereFld ( 'page_namespace' , $this -> params [ 'namespace' ] );
2010-01-23 22:47:49 +00:00
2010-02-24 13:34:11 +00:00
if ( ! is_null ( $this -> contID ) ) {
2010-01-11 15:55:52 +00:00
$this -> addWhere ( " { $this -> bl_from } >= { $this -> contID } " );
2010-02-24 13:34:11 +00:00
}
2010-01-23 21:28:27 +00:00
2010-02-24 13:34:11 +00:00
if ( $this -> params [ 'filterredir' ] == 'redirects' ) {
2010-01-11 15:55:52 +00:00
$this -> addWhereFld ( 'page_is_redirect' , 1 );
2010-02-24 13:34:11 +00:00
} elseif ( $this -> params [ 'filterredir' ] == 'nonredirects' && ! $this -> redirect ) {
2010-01-31 21:21:46 +00:00
// bug 22245 - Check for !redirect, as filtering nonredirects, when getting what links to them is contradictory
$this -> addWhereFld ( 'page_is_redirect' , 0 );
2010-02-24 13:34:11 +00:00
}
2010-01-23 21:28:27 +00:00
2010-01-11 15:55:52 +00:00
$this -> addOption ( 'LIMIT' , $this -> params [ 'limit' ] + 1 );
$this -> addOption ( 'ORDER BY' , $this -> bl_from );
$this -> addOption ( 'STRAIGHT_JOIN' );
2008-02-25 14:32:57 +00:00
}
2008-04-14 07:45:50 +00:00
2010-01-11 15:55:52 +00:00
private function prepareSecondQuery ( $resultPageSet = null ) {
2008-02-25 14:32:57 +00:00
/* SELECT page_id , page_title , page_namespace , page_is_redirect , pl_title , pl_namespace
2008-11-28 11:36:04 +00:00
FROM pagelinks , page WHERE pl_from = page_id
AND ( pl_title = 'Foo' AND pl_namespace = 0 ) OR ( pl_title = 'Bar' AND pl_namespace = 1 )
ORDER BY pl_namespace , pl_title , pl_from LIMIT 11
2008-02-25 14:32:57 +00:00
*/
2008-11-06 22:38:42 +00:00
$db = $this -> getDB ();
2010-01-11 15:55:52 +00:00
$this -> addTables ( array ( 'page' , $this -> bl_table ) );
$this -> addWhere ( " { $this -> bl_from } =page_id " );
2010-01-23 22:47:49 +00:00
2010-02-24 13:34:11 +00:00
if ( is_null ( $resultPageSet ) ) {
2010-01-11 15:55:52 +00:00
$this -> addFields ( array ( 'page_id' , 'page_title' , 'page_namespace' , 'page_is_redirect' ) );
2010-02-24 13:34:11 +00:00
} else {
2010-01-11 15:55:52 +00:00
$this -> addFields ( $resultPageSet -> getPageTableFields () );
2010-02-24 13:34:11 +00:00
}
2010-01-23 22:47:49 +00:00
2010-01-11 15:55:52 +00:00
$this -> addFields ( $this -> bl_title );
2010-02-24 13:34:11 +00:00
if ( $this -> hasNS ) {
2010-01-11 15:55:52 +00:00
$this -> addFields ( $this -> bl_ns );
2010-02-24 13:34:11 +00:00
}
2010-01-23 22:47:49 +00:00
2009-01-24 13:10:30 +00:00
// We can't use LinkBatch here because $this->hasNS may be false
2009-01-24 13:00:43 +00:00
$titleWhere = array ();
2010-02-24 13:34:11 +00:00
foreach ( $this -> redirTitles as $t ) {
2010-01-11 15:55:52 +00:00
$titleWhere [] = " { $this -> bl_title } = " . $db -> addQuotes ( $t -> getDBkey () ) .
2010-02-24 13:34:11 +00:00
( $this -> hasNS ? " AND { $this -> bl_ns } = ' { $t -> getNamespace () } ' " : '' );
}
2010-01-11 15:55:52 +00:00
$this -> addWhere ( $db -> makeList ( $titleWhere , LIST_OR ) );
$this -> addWhereFld ( 'page_namespace' , $this -> params [ 'namespace' ] );
2010-01-23 22:47:49 +00:00
2010-02-24 13:34:11 +00:00
if ( ! is_null ( $this -> redirID ) ) {
2008-10-24 22:22:40 +00:00
$first = $this -> redirTitles [ 0 ];
2010-01-11 15:55:52 +00:00
$title = $db -> strencode ( $first -> getDBkey () );
2008-10-24 22:22:40 +00:00
$ns = $first -> getNamespace ();
$from = $this -> redirID ;
2010-02-24 13:34:11 +00:00
if ( $this -> hasNS ) {
2010-01-11 15:55:52 +00:00
$this -> addWhere ( " { $this -> bl_ns } > $ns OR " .
" ( { $this -> bl_ns } = $ns AND " .
" ( { $this -> bl_title } > ' $title ' OR " .
" ( { $this -> bl_title } = ' $title ' AND " .
" { $this -> bl_from } >= $from ))) " );
2010-02-24 13:34:11 +00:00
} else {
2010-01-11 15:55:52 +00:00
$this -> addWhere ( " { $this -> bl_title } > ' $title ' OR " .
" ( { $this -> bl_title } = ' $title ' AND " .
" { $this -> bl_from } >= $from ) " );
2010-02-24 13:34:11 +00:00
}
2008-10-24 22:22:40 +00:00
}
2010-02-24 13:34:11 +00:00
if ( $this -> params [ 'filterredir' ] == 'redirects' ) {
2010-01-11 15:55:52 +00:00
$this -> addWhereFld ( 'page_is_redirect' , 1 );
2010-02-24 13:34:11 +00:00
} elseif ( $this -> params [ 'filterredir' ] == 'nonredirects' ) {
2010-01-11 15:55:52 +00:00
$this -> addWhereFld ( 'page_is_redirect' , 0 );
2010-02-24 13:34:11 +00:00
}
2010-01-23 22:47:49 +00:00
2010-01-11 15:55:52 +00:00
$this -> addOption ( 'LIMIT' , $this -> params [ 'limit' ] + 1 );
$this -> addOption ( 'ORDER BY' , $this -> bl_sort );
$this -> addOption ( 'USE INDEX' , array ( 'page' => 'PRIMARY' ) );
2008-02-25 14:32:57 +00:00
}
2006-10-25 17:16:37 +00:00
2010-01-11 15:55:52 +00:00
private function run ( $resultPageSet = null ) {
$this -> params = $this -> extractRequestParams ( false );
$this -> redirect = isset ( $this -> params [ 'redirect' ] ) && $this -> params [ 'redirect' ];
$userMax = ( $this -> redirect ? ApiBase :: LIMIT_BIG1 / 2 : ApiBase :: LIMIT_BIG1 );
$botMax = ( $this -> redirect ? ApiBase :: LIMIT_BIG2 / 2 : ApiBase :: LIMIT_BIG2 );
if ( $this -> params [ 'limit' ] == 'max' ) {
2008-02-25 14:32:57 +00:00
$this -> params [ 'limit' ] = $this -> getMain () -> canApiHighLimits () ? $botMax : $userMax ;
$this -> getResult () -> addValue ( 'limits' , $this -> getModuleName (), $this -> params [ 'limit' ] );
2006-10-25 17:16:37 +00:00
}
2006-10-27 03:50:34 +00:00
2008-02-25 14:32:57 +00:00
$this -> processContinue ();
2010-01-11 15:55:52 +00:00
$this -> prepareFirstQuery ( $resultPageSet );
2008-02-25 14:32:57 +00:00
$db = $this -> getDB ();
2010-01-11 15:55:52 +00:00
$res = $this -> select ( __METHOD__ . '::firstQuery' );
2006-10-25 17:16:37 +00:00
$count = 0 ;
* API: BREAKING CHANGE: (bug 11430) Return fewer results than the limit in some cases to prevent running out of memory
* This means queries could possibly return fewer results than the limit and still set a query-continue
* Add iicontinue, rvcontinue, cicontinue, incontinue, amfrom to faciliate query-continue for these modules
* Implemented by blocking additions to the ApiResult object if they would make it too large
** Important things like query-continue values and warnings are exempt from this check
** RSS feeds and exported XML are also exempted (size-checking them would be too messy)
** Result size is checked against $wgAPIMaxResultSize, which defaults to 8 MB
For those who really care, per-file details follow:
ApiResult.php:
* Introduced ApiResult::$mSize which keeps track of the result size.
* Introduced ApiResult::size() which calculates an array's size
(which is the sum of the strlen()s of its elements).
* ApiResult::addValue() now checks that the result size stays below
$wgAPIMaxResultSize. If the item won't fit, it won't be added and addValue()
will return false. Callers should check the return value and set a
query-continue if it's false.
* Closed the back door that is ApiResult::getData(): callers can't manipulate
the data array directly anymore so they can't bypass the result size limit.
* Added ApiResult::setIndexedTagName_internal() which will call
setIndexedTagName() on an array already in the result. This is needed for the
'new' order of adding results, which means addValue()ing one result at a time
until you hit the limit or run out, then calling this function to set the tag
name.
* Added ApiResult::disableSizeCheck() and enableSizeCheck() which disable and
enable size checking in addValue(). This is used for stuff like query-continue
elements and warnings which shouldn't count towards the result size.
* Added ApiResult::unsetValue() which removes an element from the result and
decreases $mSize.
ApiBase.php:
* Like ApiResult::getData(), ApiBase::getResultData() no longer returns a
reference.
* Use ApiResult::disableSizeCheck() in ApiBase::setWarning()
ApiQueryBase.php:
* Added ApiQueryBase::addPageSubItem(), which adds page subitems one item
at a time.
* addPageSubItem() and addPageSubItems() now return whether the subitem
fit in the result.
* Use ApiResult::disableSizeCheck() in setContinueEnumParameter()
ApiMain.php:
* Use ApiResult::disableSizeCheck() in ApiMain::substituteResultWithError()
* Use getParameter() rather than $mRequest to obtain requestid
DefaultSettings.php:
* Added $wgAPIMaxResultSize, with a default value of 8 MB
ApiQuery*.php:
* Added results one at a time, and set a query-continue if the result is full.
ApiQueryLangLinks.php and friends:
* Migrated from addPageSubItems() to addPageSubItem(). This eliminates the
need for $lastId.
ApiQueryAllLinks.php, ApiQueryWatchlist.php, ApiQueryAllimages.php, ApiQuerySearch.php:
* Renamed $data to something more appropriate ($pageids, $ids or $titles)
ApiQuerySiteinfo.php:
* Abuse siprop as a query-continue parameter and set it to all props that
couldn't be processed.
ApiQueryRandom.php:
* Doesn't do continuations, because the result is supposed to be random.
* Be smart enough to not run the second query if the results of the first
didn't fit.
ApiQueryImageInfo.php, ApiQueryRevisions.php, ApiQueryCategoryInfo.php, ApiQueryInfo.php:
* Added continue parameter which basically skips the first so many items
ApiQueryBacklinks.php:
* Throw the result in a big array first and addValue() that one element at a time if necessary
** This is necessary because the results aren't retrieved in order
* Introduced $this->pageMap to map namespace and title to page ID
* Rewritten extractRowInfo() and extractRedirRowInfo() a little
* Declared all private member variables explicitly
ApiQueryDeletedrevs.php:
* Use a pagemap just like in Backlinks
* Introduce fake page IDs and keep track of them so we know where to add what
** This doesn't change the output format, because the fake page IDs start at 0 and are consecutive
ApiQueryAllmessages.php:
* Add amfrom to facilitate query-continue
ApiQueryUsers.php:
* Rewrite: put the getOtherUsersInfo() code in execute()
2009-02-05 14:30:59 +00:00
$this -> pageMap = array (); // Maps ns and title to pageid
2008-02-25 14:32:57 +00:00
$this -> continueStr = null ;
$this -> redirTitles = array ();
2010-01-11 15:55:52 +00:00
while ( $row = $db -> fetchObject ( $res ) ) {
if ( ++ $count > $this -> params [ 'limit' ] ) {
2006-10-25 17:16:37 +00:00
// We've reached the one extra which shows that there are additional pages to be had. Stop here...
2008-02-25 14:32:57 +00:00
// Continue string preserved in case the redirect query doesn't pass the limit
2010-01-11 15:55:52 +00:00
$this -> continueStr = $this -> getContinueStr ( $row -> page_id );
2006-10-25 17:16:37 +00:00
break ;
}
2010-02-24 13:34:11 +00:00
if ( is_null ( $resultPageSet ) ) {
2010-01-11 15:55:52 +00:00
$this -> extractRowInfo ( $row );
2010-02-24 13:34:11 +00:00
} else {
2009-04-27 14:09:47 +00:00
$this -> pageMap [ $row -> page_namespace ][ $row -> page_title ] = $row -> page_id ;
2010-02-24 13:34:11 +00:00
if ( $row -> page_is_redirect ) {
2010-01-11 15:55:52 +00:00
$this -> redirTitles [] = Title :: makeTitle ( $row -> page_namespace , $row -> page_title );
2010-02-24 13:34:11 +00:00
}
2010-01-31 21:21:46 +00:00
2010-01-11 15:55:52 +00:00
$resultPageSet -> processDbRow ( $row );
2008-03-18 19:31:02 +00:00
}
2008-04-14 07:45:50 +00:00
}
2010-02-24 13:34:11 +00:00
if ( $this -> redirect && count ( $this -> redirTitles ) ) {
2008-02-25 14:32:57 +00:00
$this -> resetQueryParams ();
2010-01-11 15:55:52 +00:00
$this -> prepareSecondQuery ( $resultPageSet );
$res = $this -> select ( __METHOD__ . '::secondQuery' );
2008-02-25 14:32:57 +00:00
$count = 0 ;
2010-02-24 13:34:11 +00:00
while ( $row = $db -> fetchObject ( $res ) ) {
if ( ++ $count > $this -> params [ 'limit' ] ) {
2008-02-25 14:32:57 +00:00
// We've reached the one extra which shows that there are additional pages to be had. Stop here...
// We need to keep the parent page of this redir in
2010-02-24 13:34:11 +00:00
if ( $this -> hasNS ) {
2010-01-11 15:55:52 +00:00
$parentID = $this -> pageMap [ $row -> { $this -> bl_ns } ][ $row -> { $this -> bl_title } ];
2010-02-24 13:34:11 +00:00
} else {
2010-04-17 20:58:04 +00:00
$parentID = $this -> pageMap [ NS_IMAGE ][ $row -> { $this -> bl_title } ];
2010-02-24 13:34:11 +00:00
}
2010-01-11 15:55:52 +00:00
$this -> continueStr = $this -> getContinueRedirStr ( $parentID , $row -> page_id );
2008-02-25 14:32:57 +00:00
break ;
}
2008-04-14 07:45:50 +00:00
2010-02-24 13:34:11 +00:00
if ( is_null ( $resultPageSet ) ) {
2010-01-11 15:55:52 +00:00
$this -> extractRedirRowInfo ( $row );
2010-02-24 13:34:11 +00:00
} else {
2010-01-11 15:55:52 +00:00
$resultPageSet -> processDbRow ( $row );
2010-02-24 13:34:11 +00:00
}
2006-10-25 17:16:37 +00:00
}
}
2010-01-11 15:55:52 +00:00
if ( is_null ( $resultPageSet ) ) {
2009-02-19 21:24:28 +00:00
// Try to add the result data in one go and pray that it fits
2010-01-11 15:55:52 +00:00
$fit = $this -> getResult () -> addValue ( 'query' , $this -> getModuleName (), array_values ( $this -> resultArr ) );
2010-02-24 13:34:11 +00:00
if ( ! $fit ) {
2009-02-19 21:24:28 +00:00
// It didn't fit. Add elements one by one until the
// result is full.
2010-02-24 13:34:11 +00:00
foreach ( $this -> resultArr as $pageID => $arr ) {
2009-02-19 21:24:28 +00:00
// Add the basic entry without redirlinks first
* API: BREAKING CHANGE: (bug 11430) Return fewer results than the limit in some cases to prevent running out of memory
* This means queries could possibly return fewer results than the limit and still set a query-continue
* Add iicontinue, rvcontinue, cicontinue, incontinue, amfrom to faciliate query-continue for these modules
* Implemented by blocking additions to the ApiResult object if they would make it too large
** Important things like query-continue values and warnings are exempt from this check
** RSS feeds and exported XML are also exempted (size-checking them would be too messy)
** Result size is checked against $wgAPIMaxResultSize, which defaults to 8 MB
For those who really care, per-file details follow:
ApiResult.php:
* Introduced ApiResult::$mSize which keeps track of the result size.
* Introduced ApiResult::size() which calculates an array's size
(which is the sum of the strlen()s of its elements).
* ApiResult::addValue() now checks that the result size stays below
$wgAPIMaxResultSize. If the item won't fit, it won't be added and addValue()
will return false. Callers should check the return value and set a
query-continue if it's false.
* Closed the back door that is ApiResult::getData(): callers can't manipulate
the data array directly anymore so they can't bypass the result size limit.
* Added ApiResult::setIndexedTagName_internal() which will call
setIndexedTagName() on an array already in the result. This is needed for the
'new' order of adding results, which means addValue()ing one result at a time
until you hit the limit or run out, then calling this function to set the tag
name.
* Added ApiResult::disableSizeCheck() and enableSizeCheck() which disable and
enable size checking in addValue(). This is used for stuff like query-continue
elements and warnings which shouldn't count towards the result size.
* Added ApiResult::unsetValue() which removes an element from the result and
decreases $mSize.
ApiBase.php:
* Like ApiResult::getData(), ApiBase::getResultData() no longer returns a
reference.
* Use ApiResult::disableSizeCheck() in ApiBase::setWarning()
ApiQueryBase.php:
* Added ApiQueryBase::addPageSubItem(), which adds page subitems one item
at a time.
* addPageSubItem() and addPageSubItems() now return whether the subitem
fit in the result.
* Use ApiResult::disableSizeCheck() in setContinueEnumParameter()
ApiMain.php:
* Use ApiResult::disableSizeCheck() in ApiMain::substituteResultWithError()
* Use getParameter() rather than $mRequest to obtain requestid
DefaultSettings.php:
* Added $wgAPIMaxResultSize, with a default value of 8 MB
ApiQuery*.php:
* Added results one at a time, and set a query-continue if the result is full.
ApiQueryLangLinks.php and friends:
* Migrated from addPageSubItems() to addPageSubItem(). This eliminates the
need for $lastId.
ApiQueryAllLinks.php, ApiQueryWatchlist.php, ApiQueryAllimages.php, ApiQuerySearch.php:
* Renamed $data to something more appropriate ($pageids, $ids or $titles)
ApiQuerySiteinfo.php:
* Abuse siprop as a query-continue parameter and set it to all props that
couldn't be processed.
ApiQueryRandom.php:
* Doesn't do continuations, because the result is supposed to be random.
* Be smart enough to not run the second query if the results of the first
didn't fit.
ApiQueryImageInfo.php, ApiQueryRevisions.php, ApiQueryCategoryInfo.php, ApiQueryInfo.php:
* Added continue parameter which basically skips the first so many items
ApiQueryBacklinks.php:
* Throw the result in a big array first and addValue() that one element at a time if necessary
** This is necessary because the results aren't retrieved in order
* Introduced $this->pageMap to map namespace and title to page ID
* Rewritten extractRowInfo() and extractRedirRowInfo() a little
* Declared all private member variables explicitly
ApiQueryDeletedrevs.php:
* Use a pagemap just like in Backlinks
* Introduce fake page IDs and keep track of them so we know where to add what
** This doesn't change the output format, because the fake page IDs start at 0 and are consecutive
ApiQueryAllmessages.php:
* Add amfrom to facilitate query-continue
ApiQueryUsers.php:
* Rewrite: put the getOtherUsersInfo() code in execute()
2009-02-05 14:30:59 +00:00
$fit = $this -> getResult () -> addValue (
2010-01-11 15:55:52 +00:00
array ( 'query' , $this -> getModuleName () ),
null , array_diff_key ( $arr , array ( 'redirlinks' => '' ) ) );
2010-02-24 13:34:11 +00:00
if ( ! $fit ) {
2010-01-11 15:55:52 +00:00
$this -> continueStr = $this -> getContinueStr ( $pageID );
* API: BREAKING CHANGE: (bug 11430) Return fewer results than the limit in some cases to prevent running out of memory
* This means queries could possibly return fewer results than the limit and still set a query-continue
* Add iicontinue, rvcontinue, cicontinue, incontinue, amfrom to faciliate query-continue for these modules
* Implemented by blocking additions to the ApiResult object if they would make it too large
** Important things like query-continue values and warnings are exempt from this check
** RSS feeds and exported XML are also exempted (size-checking them would be too messy)
** Result size is checked against $wgAPIMaxResultSize, which defaults to 8 MB
For those who really care, per-file details follow:
ApiResult.php:
* Introduced ApiResult::$mSize which keeps track of the result size.
* Introduced ApiResult::size() which calculates an array's size
(which is the sum of the strlen()s of its elements).
* ApiResult::addValue() now checks that the result size stays below
$wgAPIMaxResultSize. If the item won't fit, it won't be added and addValue()
will return false. Callers should check the return value and set a
query-continue if it's false.
* Closed the back door that is ApiResult::getData(): callers can't manipulate
the data array directly anymore so they can't bypass the result size limit.
* Added ApiResult::setIndexedTagName_internal() which will call
setIndexedTagName() on an array already in the result. This is needed for the
'new' order of adding results, which means addValue()ing one result at a time
until you hit the limit or run out, then calling this function to set the tag
name.
* Added ApiResult::disableSizeCheck() and enableSizeCheck() which disable and
enable size checking in addValue(). This is used for stuff like query-continue
elements and warnings which shouldn't count towards the result size.
* Added ApiResult::unsetValue() which removes an element from the result and
decreases $mSize.
ApiBase.php:
* Like ApiResult::getData(), ApiBase::getResultData() no longer returns a
reference.
* Use ApiResult::disableSizeCheck() in ApiBase::setWarning()
ApiQueryBase.php:
* Added ApiQueryBase::addPageSubItem(), which adds page subitems one item
at a time.
* addPageSubItem() and addPageSubItems() now return whether the subitem
fit in the result.
* Use ApiResult::disableSizeCheck() in setContinueEnumParameter()
ApiMain.php:
* Use ApiResult::disableSizeCheck() in ApiMain::substituteResultWithError()
* Use getParameter() rather than $mRequest to obtain requestid
DefaultSettings.php:
* Added $wgAPIMaxResultSize, with a default value of 8 MB
ApiQuery*.php:
* Added results one at a time, and set a query-continue if the result is full.
ApiQueryLangLinks.php and friends:
* Migrated from addPageSubItems() to addPageSubItem(). This eliminates the
need for $lastId.
ApiQueryAllLinks.php, ApiQueryWatchlist.php, ApiQueryAllimages.php, ApiQuerySearch.php:
* Renamed $data to something more appropriate ($pageids, $ids or $titles)
ApiQuerySiteinfo.php:
* Abuse siprop as a query-continue parameter and set it to all props that
couldn't be processed.
ApiQueryRandom.php:
* Doesn't do continuations, because the result is supposed to be random.
* Be smart enough to not run the second query if the results of the first
didn't fit.
ApiQueryImageInfo.php, ApiQueryRevisions.php, ApiQueryCategoryInfo.php, ApiQueryInfo.php:
* Added continue parameter which basically skips the first so many items
ApiQueryBacklinks.php:
* Throw the result in a big array first and addValue() that one element at a time if necessary
** This is necessary because the results aren't retrieved in order
* Introduced $this->pageMap to map namespace and title to page ID
* Rewritten extractRowInfo() and extractRedirRowInfo() a little
* Declared all private member variables explicitly
ApiQueryDeletedrevs.php:
* Use a pagemap just like in Backlinks
* Introduce fake page IDs and keep track of them so we know where to add what
** This doesn't change the output format, because the fake page IDs start at 0 and are consecutive
ApiQueryAllmessages.php:
* Add amfrom to facilitate query-continue
ApiQueryUsers.php:
* Rewrite: put the getOtherUsersInfo() code in execute()
2009-02-05 14:30:59 +00:00
break ;
}
2009-02-19 21:24:28 +00:00
$hasRedirs = false ;
2010-02-24 13:34:11 +00:00
foreach ( ( array ) @ $arr [ 'redirlinks' ] as $key => $redir ) {
2009-02-19 21:24:28 +00:00
$fit = $this -> getResult () -> addValue (
2010-01-11 15:55:52 +00:00
array ( 'query' , $this -> getModuleName (), $pageID , 'redirlinks' ),
$key , $redir );
2010-02-24 13:34:11 +00:00
if ( ! $fit ) {
2010-01-11 15:55:52 +00:00
$this -> continueStr = $this -> getContinueRedirStr ( $pageID , $redir [ 'pageid' ] );
2009-02-19 21:24:28 +00:00
break ;
}
$hasRedirs = true ;
}
2010-02-24 13:34:11 +00:00
if ( $hasRedirs ) {
2009-02-19 21:24:28 +00:00
$this -> getResult () -> setIndexedTagName_internal (
2010-01-11 15:55:52 +00:00
array ( 'query' , $this -> getModuleName (), $pageID , 'redirlinks' ),
$this -> bl_code );
2010-02-24 13:34:11 +00:00
}
if ( ! $fit ) {
2009-02-19 21:24:28 +00:00
break ;
2010-02-24 13:34:11 +00:00
}
* API: BREAKING CHANGE: (bug 11430) Return fewer results than the limit in some cases to prevent running out of memory
* This means queries could possibly return fewer results than the limit and still set a query-continue
* Add iicontinue, rvcontinue, cicontinue, incontinue, amfrom to faciliate query-continue for these modules
* Implemented by blocking additions to the ApiResult object if they would make it too large
** Important things like query-continue values and warnings are exempt from this check
** RSS feeds and exported XML are also exempted (size-checking them would be too messy)
** Result size is checked against $wgAPIMaxResultSize, which defaults to 8 MB
For those who really care, per-file details follow:
ApiResult.php:
* Introduced ApiResult::$mSize which keeps track of the result size.
* Introduced ApiResult::size() which calculates an array's size
(which is the sum of the strlen()s of its elements).
* ApiResult::addValue() now checks that the result size stays below
$wgAPIMaxResultSize. If the item won't fit, it won't be added and addValue()
will return false. Callers should check the return value and set a
query-continue if it's false.
* Closed the back door that is ApiResult::getData(): callers can't manipulate
the data array directly anymore so they can't bypass the result size limit.
* Added ApiResult::setIndexedTagName_internal() which will call
setIndexedTagName() on an array already in the result. This is needed for the
'new' order of adding results, which means addValue()ing one result at a time
until you hit the limit or run out, then calling this function to set the tag
name.
* Added ApiResult::disableSizeCheck() and enableSizeCheck() which disable and
enable size checking in addValue(). This is used for stuff like query-continue
elements and warnings which shouldn't count towards the result size.
* Added ApiResult::unsetValue() which removes an element from the result and
decreases $mSize.
ApiBase.php:
* Like ApiResult::getData(), ApiBase::getResultData() no longer returns a
reference.
* Use ApiResult::disableSizeCheck() in ApiBase::setWarning()
ApiQueryBase.php:
* Added ApiQueryBase::addPageSubItem(), which adds page subitems one item
at a time.
* addPageSubItem() and addPageSubItems() now return whether the subitem
fit in the result.
* Use ApiResult::disableSizeCheck() in setContinueEnumParameter()
ApiMain.php:
* Use ApiResult::disableSizeCheck() in ApiMain::substituteResultWithError()
* Use getParameter() rather than $mRequest to obtain requestid
DefaultSettings.php:
* Added $wgAPIMaxResultSize, with a default value of 8 MB
ApiQuery*.php:
* Added results one at a time, and set a query-continue if the result is full.
ApiQueryLangLinks.php and friends:
* Migrated from addPageSubItems() to addPageSubItem(). This eliminates the
need for $lastId.
ApiQueryAllLinks.php, ApiQueryWatchlist.php, ApiQueryAllimages.php, ApiQuerySearch.php:
* Renamed $data to something more appropriate ($pageids, $ids or $titles)
ApiQuerySiteinfo.php:
* Abuse siprop as a query-continue parameter and set it to all props that
couldn't be processed.
ApiQueryRandom.php:
* Doesn't do continuations, because the result is supposed to be random.
* Be smart enough to not run the second query if the results of the first
didn't fit.
ApiQueryImageInfo.php, ApiQueryRevisions.php, ApiQueryCategoryInfo.php, ApiQueryInfo.php:
* Added continue parameter which basically skips the first so many items
ApiQueryBacklinks.php:
* Throw the result in a big array first and addValue() that one element at a time if necessary
** This is necessary because the results aren't retrieved in order
* Introduced $this->pageMap to map namespace and title to page ID
* Rewritten extractRowInfo() and extractRedirRowInfo() a little
* Declared all private member variables explicitly
ApiQueryDeletedrevs.php:
* Use a pagemap just like in Backlinks
* Introduce fake page IDs and keep track of them so we know where to add what
** This doesn't change the output format, because the fake page IDs start at 0 and are consecutive
ApiQueryAllmessages.php:
* Add amfrom to facilitate query-continue
ApiQueryUsers.php:
* Rewrite: put the getOtherUsersInfo() code in execute()
2009-02-05 14:30:59 +00:00
}
2010-01-11 15:55:52 +00:00
}
2006-10-25 17:16:37 +00:00
* API: BREAKING CHANGE: (bug 11430) Return fewer results than the limit in some cases to prevent running out of memory
* This means queries could possibly return fewer results than the limit and still set a query-continue
* Add iicontinue, rvcontinue, cicontinue, incontinue, amfrom to faciliate query-continue for these modules
* Implemented by blocking additions to the ApiResult object if they would make it too large
** Important things like query-continue values and warnings are exempt from this check
** RSS feeds and exported XML are also exempted (size-checking them would be too messy)
** Result size is checked against $wgAPIMaxResultSize, which defaults to 8 MB
For those who really care, per-file details follow:
ApiResult.php:
* Introduced ApiResult::$mSize which keeps track of the result size.
* Introduced ApiResult::size() which calculates an array's size
(which is the sum of the strlen()s of its elements).
* ApiResult::addValue() now checks that the result size stays below
$wgAPIMaxResultSize. If the item won't fit, it won't be added and addValue()
will return false. Callers should check the return value and set a
query-continue if it's false.
* Closed the back door that is ApiResult::getData(): callers can't manipulate
the data array directly anymore so they can't bypass the result size limit.
* Added ApiResult::setIndexedTagName_internal() which will call
setIndexedTagName() on an array already in the result. This is needed for the
'new' order of adding results, which means addValue()ing one result at a time
until you hit the limit or run out, then calling this function to set the tag
name.
* Added ApiResult::disableSizeCheck() and enableSizeCheck() which disable and
enable size checking in addValue(). This is used for stuff like query-continue
elements and warnings which shouldn't count towards the result size.
* Added ApiResult::unsetValue() which removes an element from the result and
decreases $mSize.
ApiBase.php:
* Like ApiResult::getData(), ApiBase::getResultData() no longer returns a
reference.
* Use ApiResult::disableSizeCheck() in ApiBase::setWarning()
ApiQueryBase.php:
* Added ApiQueryBase::addPageSubItem(), which adds page subitems one item
at a time.
* addPageSubItem() and addPageSubItems() now return whether the subitem
fit in the result.
* Use ApiResult::disableSizeCheck() in setContinueEnumParameter()
ApiMain.php:
* Use ApiResult::disableSizeCheck() in ApiMain::substituteResultWithError()
* Use getParameter() rather than $mRequest to obtain requestid
DefaultSettings.php:
* Added $wgAPIMaxResultSize, with a default value of 8 MB
ApiQuery*.php:
* Added results one at a time, and set a query-continue if the result is full.
ApiQueryLangLinks.php and friends:
* Migrated from addPageSubItems() to addPageSubItem(). This eliminates the
need for $lastId.
ApiQueryAllLinks.php, ApiQueryWatchlist.php, ApiQueryAllimages.php, ApiQuerySearch.php:
* Renamed $data to something more appropriate ($pageids, $ids or $titles)
ApiQuerySiteinfo.php:
* Abuse siprop as a query-continue parameter and set it to all props that
couldn't be processed.
ApiQueryRandom.php:
* Doesn't do continuations, because the result is supposed to be random.
* Be smart enough to not run the second query if the results of the first
didn't fit.
ApiQueryImageInfo.php, ApiQueryRevisions.php, ApiQueryCategoryInfo.php, ApiQueryInfo.php:
* Added continue parameter which basically skips the first so many items
ApiQueryBacklinks.php:
* Throw the result in a big array first and addValue() that one element at a time if necessary
** This is necessary because the results aren't retrieved in order
* Introduced $this->pageMap to map namespace and title to page ID
* Rewritten extractRowInfo() and extractRedirRowInfo() a little
* Declared all private member variables explicitly
ApiQueryDeletedrevs.php:
* Use a pagemap just like in Backlinks
* Introduce fake page IDs and keep track of them so we know where to add what
** This doesn't change the output format, because the fake page IDs start at 0 and are consecutive
ApiQueryAllmessages.php:
* Add amfrom to facilitate query-continue
ApiQueryUsers.php:
* Rewrite: put the getOtherUsersInfo() code in execute()
2009-02-05 14:30:59 +00:00
$this -> getResult () -> setIndexedTagName_internal (
2010-02-24 13:34:11 +00:00
array ( 'query' , $this -> getModuleName () ),
$this -> bl_code
);
2006-10-25 17:16:37 +00:00
}
2010-02-24 13:34:11 +00:00
if ( ! is_null ( $this -> continueStr ) ) {
2010-01-11 15:55:52 +00:00
$this -> setContinueEnumParameter ( 'continue' , $this -> continueStr );
2010-02-24 13:34:11 +00:00
}
2006-10-25 17:16:37 +00:00
}
2010-01-11 15:55:52 +00:00
private function extractRowInfo ( $row ) {
* API: BREAKING CHANGE: (bug 11430) Return fewer results than the limit in some cases to prevent running out of memory
* This means queries could possibly return fewer results than the limit and still set a query-continue
* Add iicontinue, rvcontinue, cicontinue, incontinue, amfrom to faciliate query-continue for these modules
* Implemented by blocking additions to the ApiResult object if they would make it too large
** Important things like query-continue values and warnings are exempt from this check
** RSS feeds and exported XML are also exempted (size-checking them would be too messy)
** Result size is checked against $wgAPIMaxResultSize, which defaults to 8 MB
For those who really care, per-file details follow:
ApiResult.php:
* Introduced ApiResult::$mSize which keeps track of the result size.
* Introduced ApiResult::size() which calculates an array's size
(which is the sum of the strlen()s of its elements).
* ApiResult::addValue() now checks that the result size stays below
$wgAPIMaxResultSize. If the item won't fit, it won't be added and addValue()
will return false. Callers should check the return value and set a
query-continue if it's false.
* Closed the back door that is ApiResult::getData(): callers can't manipulate
the data array directly anymore so they can't bypass the result size limit.
* Added ApiResult::setIndexedTagName_internal() which will call
setIndexedTagName() on an array already in the result. This is needed for the
'new' order of adding results, which means addValue()ing one result at a time
until you hit the limit or run out, then calling this function to set the tag
name.
* Added ApiResult::disableSizeCheck() and enableSizeCheck() which disable and
enable size checking in addValue(). This is used for stuff like query-continue
elements and warnings which shouldn't count towards the result size.
* Added ApiResult::unsetValue() which removes an element from the result and
decreases $mSize.
ApiBase.php:
* Like ApiResult::getData(), ApiBase::getResultData() no longer returns a
reference.
* Use ApiResult::disableSizeCheck() in ApiBase::setWarning()
ApiQueryBase.php:
* Added ApiQueryBase::addPageSubItem(), which adds page subitems one item
at a time.
* addPageSubItem() and addPageSubItems() now return whether the subitem
fit in the result.
* Use ApiResult::disableSizeCheck() in setContinueEnumParameter()
ApiMain.php:
* Use ApiResult::disableSizeCheck() in ApiMain::substituteResultWithError()
* Use getParameter() rather than $mRequest to obtain requestid
DefaultSettings.php:
* Added $wgAPIMaxResultSize, with a default value of 8 MB
ApiQuery*.php:
* Added results one at a time, and set a query-continue if the result is full.
ApiQueryLangLinks.php and friends:
* Migrated from addPageSubItems() to addPageSubItem(). This eliminates the
need for $lastId.
ApiQueryAllLinks.php, ApiQueryWatchlist.php, ApiQueryAllimages.php, ApiQuerySearch.php:
* Renamed $data to something more appropriate ($pageids, $ids or $titles)
ApiQuerySiteinfo.php:
* Abuse siprop as a query-continue parameter and set it to all props that
couldn't be processed.
ApiQueryRandom.php:
* Doesn't do continuations, because the result is supposed to be random.
* Be smart enough to not run the second query if the results of the first
didn't fit.
ApiQueryImageInfo.php, ApiQueryRevisions.php, ApiQueryCategoryInfo.php, ApiQueryInfo.php:
* Added continue parameter which basically skips the first so many items
ApiQueryBacklinks.php:
* Throw the result in a big array first and addValue() that one element at a time if necessary
** This is necessary because the results aren't retrieved in order
* Introduced $this->pageMap to map namespace and title to page ID
* Rewritten extractRowInfo() and extractRedirRowInfo() a little
* Declared all private member variables explicitly
ApiQueryDeletedrevs.php:
* Use a pagemap just like in Backlinks
* Introduce fake page IDs and keep track of them so we know where to add what
** This doesn't change the output format, because the fake page IDs start at 0 and are consecutive
ApiQueryAllmessages.php:
* Add amfrom to facilitate query-continue
ApiQueryUsers.php:
* Rewrite: put the getOtherUsersInfo() code in execute()
2009-02-05 14:30:59 +00:00
$this -> pageMap [ $row -> page_namespace ][ $row -> page_title ] = $row -> page_id ;
2010-01-11 15:55:52 +00:00
$t = Title :: makeTitle ( $row -> page_namespace , $row -> page_title );
$a = array ( 'pageid' => intval ( $row -> page_id ) );
ApiQueryBase :: addTitleInfo ( $a , $t );
2010-02-24 13:34:11 +00:00
if ( $row -> page_is_redirect ) {
* API: BREAKING CHANGE: (bug 11430) Return fewer results than the limit in some cases to prevent running out of memory
* This means queries could possibly return fewer results than the limit and still set a query-continue
* Add iicontinue, rvcontinue, cicontinue, incontinue, amfrom to faciliate query-continue for these modules
* Implemented by blocking additions to the ApiResult object if they would make it too large
** Important things like query-continue values and warnings are exempt from this check
** RSS feeds and exported XML are also exempted (size-checking them would be too messy)
** Result size is checked against $wgAPIMaxResultSize, which defaults to 8 MB
For those who really care, per-file details follow:
ApiResult.php:
* Introduced ApiResult::$mSize which keeps track of the result size.
* Introduced ApiResult::size() which calculates an array's size
(which is the sum of the strlen()s of its elements).
* ApiResult::addValue() now checks that the result size stays below
$wgAPIMaxResultSize. If the item won't fit, it won't be added and addValue()
will return false. Callers should check the return value and set a
query-continue if it's false.
* Closed the back door that is ApiResult::getData(): callers can't manipulate
the data array directly anymore so they can't bypass the result size limit.
* Added ApiResult::setIndexedTagName_internal() which will call
setIndexedTagName() on an array already in the result. This is needed for the
'new' order of adding results, which means addValue()ing one result at a time
until you hit the limit or run out, then calling this function to set the tag
name.
* Added ApiResult::disableSizeCheck() and enableSizeCheck() which disable and
enable size checking in addValue(). This is used for stuff like query-continue
elements and warnings which shouldn't count towards the result size.
* Added ApiResult::unsetValue() which removes an element from the result and
decreases $mSize.
ApiBase.php:
* Like ApiResult::getData(), ApiBase::getResultData() no longer returns a
reference.
* Use ApiResult::disableSizeCheck() in ApiBase::setWarning()
ApiQueryBase.php:
* Added ApiQueryBase::addPageSubItem(), which adds page subitems one item
at a time.
* addPageSubItem() and addPageSubItems() now return whether the subitem
fit in the result.
* Use ApiResult::disableSizeCheck() in setContinueEnumParameter()
ApiMain.php:
* Use ApiResult::disableSizeCheck() in ApiMain::substituteResultWithError()
* Use getParameter() rather than $mRequest to obtain requestid
DefaultSettings.php:
* Added $wgAPIMaxResultSize, with a default value of 8 MB
ApiQuery*.php:
* Added results one at a time, and set a query-continue if the result is full.
ApiQueryLangLinks.php and friends:
* Migrated from addPageSubItems() to addPageSubItem(). This eliminates the
need for $lastId.
ApiQueryAllLinks.php, ApiQueryWatchlist.php, ApiQueryAllimages.php, ApiQuerySearch.php:
* Renamed $data to something more appropriate ($pageids, $ids or $titles)
ApiQuerySiteinfo.php:
* Abuse siprop as a query-continue parameter and set it to all props that
couldn't be processed.
ApiQueryRandom.php:
* Doesn't do continuations, because the result is supposed to be random.
* Be smart enough to not run the second query if the results of the first
didn't fit.
ApiQueryImageInfo.php, ApiQueryRevisions.php, ApiQueryCategoryInfo.php, ApiQueryInfo.php:
* Added continue parameter which basically skips the first so many items
ApiQueryBacklinks.php:
* Throw the result in a big array first and addValue() that one element at a time if necessary
** This is necessary because the results aren't retrieved in order
* Introduced $this->pageMap to map namespace and title to page ID
* Rewritten extractRowInfo() and extractRedirRowInfo() a little
* Declared all private member variables explicitly
ApiQueryDeletedrevs.php:
* Use a pagemap just like in Backlinks
* Introduce fake page IDs and keep track of them so we know where to add what
** This doesn't change the output format, because the fake page IDs start at 0 and are consecutive
ApiQueryAllmessages.php:
* Add amfrom to facilitate query-continue
ApiQueryUsers.php:
* Rewrite: put the getOtherUsersInfo() code in execute()
2009-02-05 14:30:59 +00:00
$a [ 'redirect' ] = '' ;
$this -> redirTitles [] = $t ;
2008-02-25 14:32:57 +00:00
}
* API: BREAKING CHANGE: (bug 11430) Return fewer results than the limit in some cases to prevent running out of memory
* This means queries could possibly return fewer results than the limit and still set a query-continue
* Add iicontinue, rvcontinue, cicontinue, incontinue, amfrom to faciliate query-continue for these modules
* Implemented by blocking additions to the ApiResult object if they would make it too large
** Important things like query-continue values and warnings are exempt from this check
** RSS feeds and exported XML are also exempted (size-checking them would be too messy)
** Result size is checked against $wgAPIMaxResultSize, which defaults to 8 MB
For those who really care, per-file details follow:
ApiResult.php:
* Introduced ApiResult::$mSize which keeps track of the result size.
* Introduced ApiResult::size() which calculates an array's size
(which is the sum of the strlen()s of its elements).
* ApiResult::addValue() now checks that the result size stays below
$wgAPIMaxResultSize. If the item won't fit, it won't be added and addValue()
will return false. Callers should check the return value and set a
query-continue if it's false.
* Closed the back door that is ApiResult::getData(): callers can't manipulate
the data array directly anymore so they can't bypass the result size limit.
* Added ApiResult::setIndexedTagName_internal() which will call
setIndexedTagName() on an array already in the result. This is needed for the
'new' order of adding results, which means addValue()ing one result at a time
until you hit the limit or run out, then calling this function to set the tag
name.
* Added ApiResult::disableSizeCheck() and enableSizeCheck() which disable and
enable size checking in addValue(). This is used for stuff like query-continue
elements and warnings which shouldn't count towards the result size.
* Added ApiResult::unsetValue() which removes an element from the result and
decreases $mSize.
ApiBase.php:
* Like ApiResult::getData(), ApiBase::getResultData() no longer returns a
reference.
* Use ApiResult::disableSizeCheck() in ApiBase::setWarning()
ApiQueryBase.php:
* Added ApiQueryBase::addPageSubItem(), which adds page subitems one item
at a time.
* addPageSubItem() and addPageSubItems() now return whether the subitem
fit in the result.
* Use ApiResult::disableSizeCheck() in setContinueEnumParameter()
ApiMain.php:
* Use ApiResult::disableSizeCheck() in ApiMain::substituteResultWithError()
* Use getParameter() rather than $mRequest to obtain requestid
DefaultSettings.php:
* Added $wgAPIMaxResultSize, with a default value of 8 MB
ApiQuery*.php:
* Added results one at a time, and set a query-continue if the result is full.
ApiQueryLangLinks.php and friends:
* Migrated from addPageSubItems() to addPageSubItem(). This eliminates the
need for $lastId.
ApiQueryAllLinks.php, ApiQueryWatchlist.php, ApiQueryAllimages.php, ApiQuerySearch.php:
* Renamed $data to something more appropriate ($pageids, $ids or $titles)
ApiQuerySiteinfo.php:
* Abuse siprop as a query-continue parameter and set it to all props that
couldn't be processed.
ApiQueryRandom.php:
* Doesn't do continuations, because the result is supposed to be random.
* Be smart enough to not run the second query if the results of the first
didn't fit.
ApiQueryImageInfo.php, ApiQueryRevisions.php, ApiQueryCategoryInfo.php, ApiQueryInfo.php:
* Added continue parameter which basically skips the first so many items
ApiQueryBacklinks.php:
* Throw the result in a big array first and addValue() that one element at a time if necessary
** This is necessary because the results aren't retrieved in order
* Introduced $this->pageMap to map namespace and title to page ID
* Rewritten extractRowInfo() and extractRedirRowInfo() a little
* Declared all private member variables explicitly
ApiQueryDeletedrevs.php:
* Use a pagemap just like in Backlinks
* Introduce fake page IDs and keep track of them so we know where to add what
** This doesn't change the output format, because the fake page IDs start at 0 and are consecutive
ApiQueryAllmessages.php:
* Add amfrom to facilitate query-continue
ApiQueryUsers.php:
* Rewrite: put the getOtherUsersInfo() code in execute()
2009-02-05 14:30:59 +00:00
// Put all the results in an array first
$this -> resultArr [ $a [ 'pageid' ]] = $a ;
2008-02-25 14:32:57 +00:00
}
2008-04-14 07:45:50 +00:00
2010-02-24 13:34:11 +00:00
private function extractRedirRowInfo ( $row ) {
2010-01-11 15:55:52 +00:00
$a [ 'pageid' ] = intval ( $row -> page_id );
ApiQueryBase :: addTitleInfo ( $a , Title :: makeTitle ( $row -> page_namespace , $row -> page_title ) );
2010-02-24 13:34:11 +00:00
if ( $row -> page_is_redirect ) {
2008-02-25 14:32:57 +00:00
$a [ 'redirect' ] = '' ;
2010-02-24 13:34:11 +00:00
}
2010-01-11 15:55:52 +00:00
$ns = $this -> hasNS ? $row -> { $this -> bl_ns } : NS_FILE ;
$parentID = $this -> pageMap [ $ns ][ $row -> { $this -> bl_title } ];
* API: BREAKING CHANGE: (bug 11430) Return fewer results than the limit in some cases to prevent running out of memory
* This means queries could possibly return fewer results than the limit and still set a query-continue
* Add iicontinue, rvcontinue, cicontinue, incontinue, amfrom to faciliate query-continue for these modules
* Implemented by blocking additions to the ApiResult object if they would make it too large
** Important things like query-continue values and warnings are exempt from this check
** RSS feeds and exported XML are also exempted (size-checking them would be too messy)
** Result size is checked against $wgAPIMaxResultSize, which defaults to 8 MB
For those who really care, per-file details follow:
ApiResult.php:
* Introduced ApiResult::$mSize which keeps track of the result size.
* Introduced ApiResult::size() which calculates an array's size
(which is the sum of the strlen()s of its elements).
* ApiResult::addValue() now checks that the result size stays below
$wgAPIMaxResultSize. If the item won't fit, it won't be added and addValue()
will return false. Callers should check the return value and set a
query-continue if it's false.
* Closed the back door that is ApiResult::getData(): callers can't manipulate
the data array directly anymore so they can't bypass the result size limit.
* Added ApiResult::setIndexedTagName_internal() which will call
setIndexedTagName() on an array already in the result. This is needed for the
'new' order of adding results, which means addValue()ing one result at a time
until you hit the limit or run out, then calling this function to set the tag
name.
* Added ApiResult::disableSizeCheck() and enableSizeCheck() which disable and
enable size checking in addValue(). This is used for stuff like query-continue
elements and warnings which shouldn't count towards the result size.
* Added ApiResult::unsetValue() which removes an element from the result and
decreases $mSize.
ApiBase.php:
* Like ApiResult::getData(), ApiBase::getResultData() no longer returns a
reference.
* Use ApiResult::disableSizeCheck() in ApiBase::setWarning()
ApiQueryBase.php:
* Added ApiQueryBase::addPageSubItem(), which adds page subitems one item
at a time.
* addPageSubItem() and addPageSubItems() now return whether the subitem
fit in the result.
* Use ApiResult::disableSizeCheck() in setContinueEnumParameter()
ApiMain.php:
* Use ApiResult::disableSizeCheck() in ApiMain::substituteResultWithError()
* Use getParameter() rather than $mRequest to obtain requestid
DefaultSettings.php:
* Added $wgAPIMaxResultSize, with a default value of 8 MB
ApiQuery*.php:
* Added results one at a time, and set a query-continue if the result is full.
ApiQueryLangLinks.php and friends:
* Migrated from addPageSubItems() to addPageSubItem(). This eliminates the
need for $lastId.
ApiQueryAllLinks.php, ApiQueryWatchlist.php, ApiQueryAllimages.php, ApiQuerySearch.php:
* Renamed $data to something more appropriate ($pageids, $ids or $titles)
ApiQuerySiteinfo.php:
* Abuse siprop as a query-continue parameter and set it to all props that
couldn't be processed.
ApiQueryRandom.php:
* Doesn't do continuations, because the result is supposed to be random.
* Be smart enough to not run the second query if the results of the first
didn't fit.
ApiQueryImageInfo.php, ApiQueryRevisions.php, ApiQueryCategoryInfo.php, ApiQueryInfo.php:
* Added continue parameter which basically skips the first so many items
ApiQueryBacklinks.php:
* Throw the result in a big array first and addValue() that one element at a time if necessary
** This is necessary because the results aren't retrieved in order
* Introduced $this->pageMap to map namespace and title to page ID
* Rewritten extractRowInfo() and extractRedirRowInfo() a little
* Declared all private member variables explicitly
ApiQueryDeletedrevs.php:
* Use a pagemap just like in Backlinks
* Introduce fake page IDs and keep track of them so we know where to add what
** This doesn't change the output format, because the fake page IDs start at 0 and are consecutive
ApiQueryAllmessages.php:
* Add amfrom to facilitate query-continue
ApiQueryUsers.php:
* Rewrite: put the getOtherUsersInfo() code in execute()
2009-02-05 14:30:59 +00:00
// Put all the results in an array first
$this -> resultArr [ $parentID ][ 'redirlinks' ][] = $a ;
2010-01-11 15:55:52 +00:00
$this -> getResult () -> setIndexedTagName ( $this -> resultArr [ $parentID ][ 'redirlinks' ], $this -> bl_code );
2007-05-21 00:10:01 +00:00
}
2007-07-06 07:16:38 +00:00
protected function processContinue () {
2010-02-24 13:34:11 +00:00
if ( ! is_null ( $this -> params [ 'continue' ] ) ) {
2007-07-06 07:16:38 +00:00
$this -> parseContinueParam ();
2010-02-24 13:34:11 +00:00
} else {
if ( $this -> params [ 'title' ] !== '' ) {
2008-06-05 00:00:07 +00:00
$title = Title :: newFromText ( $this -> params [ 'title' ] );
if ( ! $title ) {
2010-01-11 15:55:52 +00:00
$this -> dieUsageMsg ( array ( 'invalidtitle' , $this -> params [ 'title' ] ) );
2008-06-05 00:00:07 +00:00
} else {
$this -> rootTitle = $title ;
}
2008-05-10 10:49:26 +00:00
} else {
2010-01-11 15:55:52 +00:00
$this -> dieUsageMsg ( array ( 'missingparam' , 'title' ) );
2007-07-06 07:16:38 +00:00
}
2006-10-25 17:16:37 +00:00
}
2006-10-30 00:18:05 +00:00
2008-02-25 14:32:57 +00:00
// only image titles are allowed for the root in imageinfo mode
2010-02-24 13:34:11 +00:00
if ( ! $this -> hasNS && $this -> rootTitle -> getNamespace () !== NS_FILE ) {
2010-01-11 15:55:52 +00:00
$this -> dieUsage ( " The title for { $this -> getModuleName () } query must be an image " , 'bad_image_title' );
2010-02-24 13:34:11 +00:00
}
2006-10-25 17:16:37 +00:00
}
2007-07-06 07:16:38 +00:00
protected function parseContinueParam () {
2010-01-11 15:55:52 +00:00
$continueList = explode ( '|' , $this -> params [ 'continue' ] );
2008-02-25 14:32:57 +00:00
// expected format:
// ns | key | id1 [| id2]
// ns+key: root title
// id1: first-level page ID to continue from
// id2: second-level page ID to continue from
2008-04-14 07:45:50 +00:00
2008-02-25 14:32:57 +00:00
// null stuff out now so we know what's set and what isn't
$this -> rootTitle = $this -> contID = $this -> redirID = null ;
2010-01-11 15:55:52 +00:00
$rootNs = intval ( $continueList [ 0 ] );
2010-02-24 13:34:11 +00:00
if ( $rootNs === 0 && $continueList [ 0 ] !== '0' ) {
2008-02-25 14:32:57 +00:00
// Illegal continue parameter
2010-02-24 13:34:11 +00:00
$this -> dieUsage ( 'Invalid continue param. You should pass the original value returned by the previous query' , '_badcontinue' );
}
2010-01-11 15:55:52 +00:00
$this -> rootTitle = Title :: makeTitleSafe ( $rootNs , $continueList [ 1 ] );
2010-01-23 22:47:49 +00:00
2010-02-24 13:34:11 +00:00
if ( ! $this -> rootTitle ) {
$this -> dieUsage ( 'Invalid continue param. You should pass the original value returned by the previous query' , '_badcontinue' );
}
2010-01-11 15:55:52 +00:00
$contID = intval ( $continueList [ 2 ] );
2010-01-23 22:47:49 +00:00
2010-02-24 13:34:11 +00:00
if ( $contID === 0 && $continueList [ 2 ] !== '0' ) {
$this -> dieUsage ( 'Invalid continue param. You should pass the original value returned by the previous query' , '_badcontinue' );
}
2008-02-25 14:32:57 +00:00
$this -> contID = $contID ;
2010-01-11 15:55:52 +00:00
$redirID = intval ( @ $continueList [ 3 ] );
2010-02-24 13:34:11 +00:00
if ( $redirID === 0 && @ $continueList [ 3 ] !== '0' ) {
2008-02-25 14:32:57 +00:00
// This one isn't required
return ;
2010-02-24 13:34:11 +00:00
}
2008-02-25 14:32:57 +00:00
$this -> redirID = $redirID ;
2008-04-14 07:45:50 +00:00
2006-10-25 17:16:37 +00:00
}
2010-01-11 15:55:52 +00:00
protected function getContinueStr ( $lastPageID ) {
2006-10-30 00:18:05 +00:00
return $this -> rootTitle -> getNamespace () .
'|' . $this -> rootTitle -> getDBkey () .
'|' . $lastPageID ;
}
2010-01-11 15:55:52 +00:00
protected function getContinueRedirStr ( $lastPageID , $lastRedirID ) {
return $this -> getContinueStr ( $lastPageID ) . '|' . $lastRedirID ;
2006-10-30 00:18:05 +00:00
}
2008-01-28 19:05:26 +00:00
public function getAllowedParams () {
2010-02-24 13:34:11 +00:00
$retval = array (
2007-07-06 07:16:38 +00:00
'title' => null ,
2006-10-25 17:16:37 +00:00
'continue' => null ,
2010-02-24 13:34:11 +00:00
'namespace' => array (
ApiBase :: PARAM_ISMULTI => true ,
ApiBase :: PARAM_TYPE => 'namespace'
2006-10-25 17:16:37 +00:00
),
2007-09-04 14:44:46 +00:00
'filterredir' => array (
2010-02-24 13:34:11 +00:00
ApiBase :: PARAM_DFLT => 'all' ,
ApiBase :: PARAM_TYPE => array (
2007-09-04 14:44:46 +00:00
'all' ,
'redirects' ,
'nonredirects'
)
),
2010-02-24 13:34:11 +00:00
'limit' => array (
ApiBase :: PARAM_DFLT => 10 ,
ApiBase :: PARAM_TYPE => 'limit' ,
ApiBase :: PARAM_MIN => 1 ,
ApiBase :: PARAM_MAX => ApiBase :: LIMIT_BIG1 ,
ApiBase :: PARAM_MAX2 => ApiBase :: LIMIT_BIG2
2006-10-25 17:16:37 +00:00
)
);
2010-02-24 13:34:11 +00:00
if ( $this -> getModuleName () == 'embeddedin' ) {
2008-03-18 19:31:02 +00:00
return $retval ;
2010-02-24 13:34:11 +00:00
}
2008-03-18 19:31:02 +00:00
$retval [ 'redirect' ] = false ;
return $retval ;
2006-10-25 17:16:37 +00:00
}
2008-01-28 19:05:26 +00:00
public function getParamDescription () {
2010-02-24 13:34:11 +00:00
$retval = array (
2010-05-11 22:30:18 +00:00
'title' => 'Title to search' ,
'continue' => 'When more results are available, use this to continue' ,
'namespace' => 'The namespace to enumerate' ,
2006-10-25 17:16:37 +00:00
);
2010-02-24 13:34:11 +00:00
if ( $this -> getModuleName () != 'embeddedin' ) {
2010-01-11 15:55:52 +00:00
return array_merge ( $retval , array (
2008-03-18 19:31:02 +00:00
'redirect' => 'If linking page is a redirect, find all pages that link to that redirect as well. Maximum limit is halved.' ,
2010-01-24 10:10:00 +00:00
'filterredir' => " How to filter for redirects. If set to nonredirects when { $this -> bl_code } redirect is enabled, this is only applied to the second level " ,
2009-04-27 14:09:47 +00:00
'limit' => " How many total pages to return. If { $this -> bl_code } redirect is enabled, limit applies to each level separately (which means you may get up to 2 * limit results). "
2010-01-11 15:55:52 +00:00
) );
2010-02-24 13:34:11 +00:00
}
2010-01-11 15:55:52 +00:00
return array_merge ( $retval , array (
2010-01-24 10:10:00 +00:00
'filterredir' => 'How to filter for redirects' ,
2010-05-11 22:30:18 +00:00
'limit' => 'How many total pages to return'
2010-01-11 15:55:52 +00:00
) );
2006-10-25 17:16:37 +00:00
}
2008-01-28 19:05:26 +00:00
public function getDescription () {
2010-01-11 15:55:52 +00:00
switch ( $this -> getModuleName () ) {
2010-02-24 13:34:11 +00:00
case 'backlinks' :
2006-11-03 06:53:47 +00:00
return 'Find all pages that link to the given page' ;
2010-02-24 13:34:11 +00:00
case 'embeddedin' :
2006-11-03 06:53:47 +00:00
return 'Find all pages that embed (transclude) the given title' ;
2010-02-24 13:34:11 +00:00
case 'imageusage' :
2006-11-03 06:53:47 +00:00
return 'Find all pages that use the given image title.' ;
2010-02-24 13:34:11 +00:00
default :
ApiBase :: dieDebug ( __METHOD__ , 'Unknown module name' );
2006-11-03 06:53:47 +00:00
}
2006-10-25 17:16:37 +00:00
}
2010-02-24 13:34:11 +00:00
2010-02-14 14:29:24 +00:00
public function getPossibleErrors () {
2010-02-13 00:28:27 +00:00
return array_merge ( parent :: getPossibleErrors (), array (
array ( 'invalidtitle' , 'title' ),
array ( 'missingparam' , 'title' ),
2010-02-13 01:05:14 +00:00
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' ),
2010-02-14 14:29:24 +00:00
) );
2010-02-13 00:28:27 +00:00
}
2006-10-25 17:16:37 +00:00
protected function getExamples () {
2010-02-24 13:34:11 +00:00
static $examples = array (
'backlinks' => array (
'api.php?action=query&list=backlinks&bltitle=Main%20Page' ,
'api.php?action=query&generator=backlinks&gbltitle=Main%20Page&prop=info'
2006-10-30 00:18:05 +00:00
),
2010-02-24 13:34:11 +00:00
'embeddedin' => array (
'api.php?action=query&list=embeddedin&eititle=Template:Stub' ,
'api.php?action=query&generator=embeddedin&geititle=Template:Stub&prop=info'
2006-10-30 00:18:05 +00:00
),
2010-02-24 13:34:11 +00:00
'imageusage' => array (
'api.php?action=query&list=imageusage&iutitle=File:Albert%20Einstein%20Head.jpg' ,
'api.php?action=query&generator=imageusage&giutitle=File:Albert%20Einstein%20Head.jpg&prop=info'
2006-10-30 00:18:05 +00:00
)
2006-10-25 17:16:37 +00:00
);
2006-10-30 00:18:05 +00:00
return $examples [ $this -> getModuleName ()];
2006-10-25 17:16:37 +00:00
}
public function getVersion () {
2007-12-06 18:33:18 +00:00
return __CLASS__ . ': $Id$' ;
2006-10-25 17:16:37 +00:00
}
}