2006-09-26 05:43:02 +00:00
< ? php
/*
* Created on Sep 7 , 2006
*
* API for MediaWiki 1.8 +
*
2007-05-20 23:31:44 +00:00
* Copyright ( C ) 2006 Yuri Astrakhan < Firstname >< Lastname >@ gmail . com
2006-09-26 05:43:02 +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
*/
if ( ! defined ( 'MEDIAWIKI' )) {
// Eclipse helper - will be ignored in production
2006-10-01 02:02:13 +00:00
require_once ( 'ApiQueryBase.php' );
2006-09-26 05:43:02 +00:00
}
2007-04-20 08:55:14 +00:00
/**
2007-05-20 23:31:44 +00:00
* A query action to enumerate revisions of a given page , or show top revisions of multiple pages .
2008-04-14 07:45:50 +00:00
* Various pieces of information may be shown - flags , comments , and the actual wiki markup of the rev .
* In the enumeration mode , ranges of revisions may be requested and filtered .
*
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-09-26 05:43:02 +00:00
class ApiQueryRevisions extends ApiQueryBase {
2006-10-03 05:41:55 +00:00
public function __construct ( $query , $moduleName ) {
parent :: __construct ( $query , $moduleName , 'rv' );
2006-09-26 05:43:02 +00:00
}
2007-08-09 06:38:48 +00:00
private $fld_ids = false , $fld_flags = false , $fld_timestamp = false , $fld_size = false ,
2007-05-21 06:32:32 +00:00
$fld_comment = false , $fld_user = false , $fld_content = false ;
2007-05-20 08:34:47 +00:00
2008-07-04 12:07:02 +00:00
protected function getTokenFunctions () {
// tokenname => function
// function prototype is func($pageid, $title, $rev)
// should return token or false
// Don't call the hooks twice
if ( isset ( $this -> tokenFunctions ))
return $this -> tokenFunctions ;
2008-07-05 11:18:50 +00:00
// If we're in JSON callback mode, no tokens can be obtained
if ( ! is_null ( $this -> getMain () -> getRequest () -> getVal ( 'callback' )))
return array ();
2008-07-04 12:07:02 +00:00
$this -> tokenFunctions = array (
2008-09-04 15:17:51 +00:00
'rollback' => array ( 'ApiQueryRevisions' , 'getRollbackToken' )
2008-07-04 12:07:02 +00:00
);
wfRunHooks ( 'APIQueryRevisionsTokens' , array ( & $this -> tokenFunctions ));
return $this -> tokenFunctions ;
}
public static function getRollbackToken ( $pageid , $title , $rev )
{
global $wgUser ;
if ( ! $wgUser -> isAllowed ( 'rollback' ))
return false ;
2008-07-08 08:42:27 +00:00
return $wgUser -> editToken ( array ( $title -> getPrefixedText (),
$rev -> getUserText ()));
2008-07-04 12:07:02 +00:00
}
2006-09-27 05:13:48 +00:00
public function execute () {
2008-12-17 16:34:01 +00:00
$params = $this -> extractRequestParams ( false );
2006-09-26 05:43:02 +00:00
2006-10-01 02:02:13 +00:00
// If any of those parameters are used, work in 'enumeration' mode.
2006-09-30 08:06:27 +00:00
// Enum mode can only be used when exactly one page is provided.
2008-04-14 07:45:50 +00:00
// Enumerating revisions on multiple pages make it extremely
// difficult to manage continuations and require additional SQL indexes
2008-12-17 16:34:01 +00:00
$enumRevMode = ( ! is_null ( $params [ 'user' ]) || ! is_null ( $params [ 'excludeuser' ]) ||
! is_null ( $params [ 'limit' ]) || ! is_null ( $params [ 'startid' ]) ||
! is_null ( $params [ 'endid' ]) || $params [ 'dir' ] === 'newer' ||
! is_null ( $params [ 'start' ]) || ! is_null ( $params [ 'end' ]));
2008-04-14 07:45:50 +00:00
2006-09-27 05:13:48 +00:00
2006-10-01 20:17:16 +00:00
$pageSet = $this -> getPageSet ();
$pageCount = $pageSet -> getGoodTitleCount ();
$revCount = $pageSet -> getRevisionCount ();
2006-09-29 07:29:13 +00:00
2006-10-01 02:02:13 +00:00
// Optimization -- nothing to do
if ( $revCount === 0 && $pageCount === 0 )
return ;
2006-09-30 08:06:27 +00:00
if ( $revCount > 0 && $enumRevMode )
2006-10-03 05:41:55 +00:00
$this -> dieUsage ( 'The revids= parameter may not be used with the list options (limit, startid, endid, dirNewer, start, end).' , 'revids' );
2006-09-30 08:06:27 +00:00
2006-10-13 04:59:14 +00:00
if ( $pageCount > 1 && $enumRevMode )
2007-12-02 00:22:32 +00:00
$this -> dieUsage ( 'titles, pageids or a generator was used to supply multiple pages, but the limit, startid, endid, dirNewer, user, excludeuser, start and end parameters may only be used on a single page.' , 'multpages' );
2006-09-27 05:13:48 +00:00
2006-10-21 08:26:32 +00:00
$this -> addTables ( 'revision' );
2009-02-05 11:44:10 +00:00
$this -> addFields ( Revision :: selectFields ());
$this -> addTables ( 'page' );
2008-10-29 04:17:31 +00:00
$this -> addWhere ( 'page_id = rev_page' );
2006-10-21 08:26:32 +00:00
2008-12-17 16:34:01 +00:00
$prop = array_flip ( $params [ 'prop' ]);
2007-05-21 06:32:32 +00:00
// Optional fields
2007-07-01 06:45:14 +00:00
$this -> fld_ids = isset ( $prop [ 'ids' ]);
2007-05-21 06:32:32 +00:00
// $this->addFieldsIf('rev_text_id', $this->fld_ids); // should this be exposed?
2008-05-13 10:42:32 +00:00
$this -> fld_flags = isset ( $prop [ 'flags' ]);
$this -> fld_timestamp = isset ( $prop [ 'timestamp' ]);
$this -> fld_comment = isset ( $prop [ 'comment' ]);
$this -> fld_size = isset ( $prop [ 'size' ]);
$this -> fld_user = isset ( $prop [ 'user' ]);
2008-12-17 16:34:01 +00:00
$this -> token = $params [ 'token' ];
2007-05-21 06:32:32 +00:00
2008-11-21 13:55:27 +00:00
if ( ! is_null ( $this -> token ) || $pageCount > 0 ) {
2008-05-13 10:42:32 +00:00
$this -> addFields ( Revision :: selectPageFields () );
2007-05-21 06:32:32 +00:00
}
2008-04-14 07:45:50 +00:00
2007-12-02 00:22:32 +00:00
if ( isset ( $prop [ 'content' ])) {
2007-07-14 19:04:31 +00:00
// For each page we will request, the user must have read rights for that page
foreach ( $pageSet -> getGoodTitles () as $title ) {
if ( ! $title -> userCanRead () )
$this -> dieUsage (
'The current user is not allowed to read ' . $title -> getPrefixedText (),
'accessdenied' );
}
2007-05-21 06:32:32 +00:00
$this -> addTables ( 'text' );
$this -> addWhere ( 'rev_text_id=old_id' );
$this -> addFields ( 'old_id' );
2009-02-05 11:44:10 +00:00
$this -> addFields ( Revision :: selectTextFields ());
2007-09-25 18:36:25 +00:00
2007-12-02 00:22:32 +00:00
$this -> fld_content = true ;
2008-04-14 07:45:50 +00:00
2008-12-17 16:34:01 +00:00
$this -> expandTemplates = $params [ 'expandtemplates' ];
$this -> generateXML = $params [ 'generatexml' ];
if ( isset ( $params [ 'section' ]))
$this -> section = $params [ 'section' ];
2008-03-14 13:07:38 +00:00
else
$this -> section = false ;
2006-09-27 05:13:48 +00:00
}
2007-12-05 06:32:17 +00:00
$userMax = ( $this -> fld_content ? ApiBase :: LIMIT_SML1 : ApiBase :: LIMIT_BIG1 );
$botMax = ( $this -> fld_content ? ApiBase :: LIMIT_SML2 : ApiBase :: LIMIT_BIG2 );
2008-12-17 16:34:01 +00:00
$limit = $params [ 'limit' ];
2008-01-05 10:05:34 +00:00
if ( $limit == 'max' ) {
$limit = $this -> getMain () -> canApiHighLimits () ? $botMax : $userMax ;
2008-02-25 14:12:55 +00:00
$this -> getResult () -> addValue ( 'limits' , $this -> getModuleName (), $limit );
2008-01-05 10:05:34 +00:00
}
2006-09-29 07:29:13 +00:00
if ( $enumRevMode ) {
2006-09-27 05:13:48 +00:00
2007-11-27 16:41:13 +00:00
// This is mostly to prevent parameter errors (and optimize SQL?)
2008-12-17 16:34:01 +00:00
if ( ! is_null ( $params [ 'startid' ]) && ! is_null ( $params [ 'start' ]))
2006-10-03 05:41:55 +00:00
$this -> dieUsage ( 'start and startid cannot be used together' , 'badparams' );
2006-09-30 08:06:27 +00:00
2008-12-17 16:34:01 +00:00
if ( ! is_null ( $params [ 'endid' ]) && ! is_null ( $params [ 'end' ]))
2006-10-03 05:41:55 +00:00
$this -> dieUsage ( 'end and endid cannot be used together' , 'badparams' );
2006-09-30 08:06:27 +00:00
2008-12-17 16:34:01 +00:00
if ( ! is_null ( $params [ 'user' ]) && ! is_null ( $params [ 'excludeuser' ]))
2008-04-14 07:45:50 +00:00
$this -> dieUsage ( 'user and excludeuser cannot be used together' , 'badparams' );
2006-10-02 18:27:06 +00:00
// This code makes an assumption that sorting by rev_id and rev_timestamp produces
// the same result. This way users may request revisions starting at a given time,
// but to page through results use the rev_id returned after each page.
2008-04-14 07:45:50 +00:00
// Switching to rev_id removes the potential problem of having more than
// one row with the same timestamp for the same page.
2006-10-02 18:27:06 +00:00
// The order needs to be the same as start parameter to avoid SQL filesort.
2008-12-17 16:34:01 +00:00
if ( is_null ( $params [ 'startid' ]) && is_null ( $params [ 'endid' ]))
$this -> addWhereRange ( 'rev_timestamp' , $params [ 'dir' ],
$params [ 'start' ], $params [ 'end' ]);
2006-11-03 06:53:47 +00:00
else
2008-12-17 16:34:01 +00:00
$this -> addWhereRange ( 'rev_id' , $params [ 'dir' ],
$params [ 'startid' ], $params [ 'endid' ]);
2006-09-29 07:29:13 +00:00
2006-10-03 05:41:55 +00:00
// must manually initialize unset limit
2006-10-18 23:49:09 +00:00
if ( is_null ( $limit ))
2006-10-03 05:41:55 +00:00
$limit = 10 ;
2007-06-25 05:44:33 +00:00
$this -> validateLimit ( 'limit' , $limit , 1 , $userMax , $botMax );
2006-09-29 07:29:13 +00:00
2006-09-30 08:06:27 +00:00
// There is only one ID, use it
2006-10-30 00:18:05 +00:00
$this -> addWhereFld ( 'rev_page' , current ( array_keys ( $pageSet -> getGoodTitles ())));
2008-04-14 07:45:50 +00:00
2008-12-17 16:34:01 +00:00
if ( ! is_null ( $params [ 'user' ])) {
$this -> addWhereFld ( 'rev_user_text' , $params [ 'user' ]);
2009-02-05 11:44:10 +00:00
} elseif ( ! is_null ( $params [ 'excludeuser' ])) {
2008-12-17 16:34:01 +00:00
$this -> addWhere ( 'rev_user_text != ' .
$this -> getDB () -> addQuotes ( $params [ 'excludeuser' ]));
2007-05-19 04:13:48 +00:00
}
2009-02-05 11:44:10 +00:00
if ( ! is_null ( $params [ 'user' ]) || ! is_null ( $params [ 'excludeuser' ])) {
// Paranoia: avoid brute force searches (bug 17342)
$this -> addWhere ( 'rev_deleted & ' . Revision :: DELETED_USER . ' = 0' );
}
2006-10-01 20:17:16 +00:00
}
2007-05-19 01:46:13 +00:00
elseif ( $revCount > 0 ) {
2008-10-24 13:05:44 +00:00
$max = $this -> getMain () -> canApiHighLimits () ? $botMax : $userMax ;
$revs = $pageSet -> getRevisionIDs ();
if ( self :: truncateArray ( $revs , $max ))
$this -> setWarning ( " Too many values supplied for parameter 'revids': the limit is $max " );
2007-05-19 01:46:13 +00:00
// Get all revision IDs
2008-10-24 13:05:44 +00:00
$this -> addWhereFld ( 'rev_id' , array_keys ( $revs ));
2007-05-19 01:46:13 +00:00
2009-02-10 12:32:22 +00:00
if ( ! is_null ( $params [ 'continue' ]))
$this -> addWhere ( " rev_id >= ' " . intval ( $params [ 'continue' ]) . " ' " );
$this -> addOption ( 'ORDER BY' , 'rev_id' );
2007-05-21 06:32:32 +00:00
// assumption testing -- we should never get more then $revCount rows.
$limit = $revCount ;
2007-05-19 01:46:13 +00:00
}
2006-10-01 20:17:16 +00:00
elseif ( $pageCount > 0 ) {
2008-10-24 13:05:44 +00:00
$max = $this -> getMain () -> canApiHighLimits () ? $botMax : $userMax ;
$titles = $pageSet -> getGoodTitles ();
if ( self :: truncateArray ( $titles , $max ))
$this -> setWarning ( " Too many values supplied for parameter 'titles': the limit is $max " );
2006-10-01 20:17:16 +00:00
// When working in multi-page non-enumeration mode,
// limit to the latest revision only
2006-10-21 08:26:32 +00:00
$this -> addWhere ( 'page_id=rev_page' );
$this -> addWhere ( 'page_latest=rev_id' );
2008-10-24 13:05:44 +00:00
2006-10-01 20:17:16 +00:00
// Get all page IDs
2008-10-24 13:05:44 +00:00
$this -> addWhereFld ( 'page_id' , array_keys ( $titles ));
2006-10-01 20:17:16 +00:00
2009-02-10 12:32:22 +00:00
if ( ! is_null ( $params [ 'continue' ]))
{
$cont = explode ( '|' , $params [ 'continue' ]);
if ( count ( $cont ) != 2 )
$this -> dieUsage ( " Invalid continue param. You should pass the original " .
" value returned by the previous query " , " _badcontinue " );
$pageid = intval ( $cont [ 0 ]);
$revid = intval ( $cont [ 1 ]);
$this -> addWhere ( " rev_page > ' $pageid ' OR " .
" (rev_page = ' $pageid ' AND " .
" rev_id >= ' $revid ') " );
}
$this -> addOption ( 'ORDER BY' , 'rev_page, rev_id' );
2007-05-21 06:32:32 +00:00
// assumption testing -- we should never get more then $pageCount rows.
$limit = $pageCount ;
2006-10-01 20:17:16 +00:00
} else
ApiBase :: dieDebug ( __METHOD__ , 'param validation?' );
2006-09-30 08:06:27 +00:00
2006-10-21 08:26:32 +00:00
$this -> addOption ( 'LIMIT' , $limit + 1 );
2006-09-27 05:13:48 +00:00
$data = array ();
$count = 0 ;
2006-10-21 08:26:32 +00:00
$res = $this -> select ( __METHOD__ );
2006-10-25 03:54:56 +00:00
2007-01-22 23:50:42 +00:00
$db = $this -> getDB ();
2006-09-27 05:13:48 +00:00
while ( $row = $db -> fetchObject ( $res )) {
2006-10-03 05:41:55 +00:00
if ( ++ $count > $limit ) {
2006-09-27 05:13:48 +00:00
// We've reached the one extra which shows that there are additional pages to be had. Stop here...
2006-09-30 08:06:27 +00:00
if ( ! $enumRevMode )
2006-10-01 20:17:16 +00:00
ApiBase :: dieDebug ( __METHOD__ , 'Got more rows then expected' ); // bug report
2007-05-21 06:32:32 +00:00
$this -> setContinueEnumParameter ( 'startid' , intval ( $row -> rev_id ));
2006-09-27 05:13:48 +00:00
break ;
}
2008-05-13 10:42:32 +00:00
$revision = new Revision ( $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
//
$fit = $this -> addPageSubItem ( $revision -> getPage (), $this -> extractRowInfo ( $revision ), 'rev' );
if ( ! $fit )
{
if ( $enumRevMode )
$this -> setContinueEnumParameter ( 'startid' , intval ( $row -> rev_id ));
2009-02-10 12:32:22 +00:00
else if ( $revCount > 0 )
$this -> setContinueEnumParameter ( 'continue' , intval ( $row -> rev_id ));
* 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
else
2009-02-10 12:32:22 +00:00
$this -> setContinueEnumParameter ( 'continue' , intval ( $row -> rev_page ) .
'|' . intval ( $row -> rev_id ));
* 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 ;
2006-10-01 02:02:13 +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
$db -> freeResult ( $res );
2006-09-26 05:43:02 +00:00
}
2008-05-13 10:42:32 +00:00
private function extractRowInfo ( $revision ) {
2007-05-20 08:34:47 +00:00
$vals = array ();
2007-05-21 06:32:32 +00:00
if ( $this -> fld_ids ) {
2008-05-13 10:42:32 +00:00
$vals [ 'revid' ] = $revision -> getId ();
2007-05-21 06:32:32 +00:00
// $vals['oldid'] = intval($row->rev_text_id); // todo: should this be exposed?
}
2008-04-14 07:45:50 +00:00
2008-05-13 10:42:32 +00:00
if ( $this -> fld_flags && $revision -> isMinor ())
2007-05-20 08:34:47 +00:00
$vals [ 'minor' ] = '' ;
if ( $this -> fld_user ) {
2009-02-05 11:44:10 +00:00
if ( $revision -> isDeleted ( Revision :: DELETED_USER )) {
$vals [ 'userhidden' ] = '' ;
} else {
$vals [ 'user' ] = $revision -> getUserText ();
if ( ! $revision -> getUser ())
$vals [ 'anon' ] = '' ;
}
2007-05-20 08:34:47 +00:00
}
if ( $this -> fld_timestamp ) {
2008-05-13 10:42:32 +00:00
$vals [ 'timestamp' ] = wfTimestamp ( TS_ISO_8601 , $revision -> getTimestamp ());
2007-05-20 08:34:47 +00:00
}
2008-04-14 07:45:50 +00:00
2008-05-13 10:42:32 +00:00
if ( $this -> fld_size && ! is_null ( $revision -> getSize ())) {
$vals [ 'size' ] = $revision -> getSize ();
2007-08-09 06:38:48 +00:00
}
2008-05-13 10:42:32 +00:00
if ( $this -> fld_comment ) {
2009-02-05 11:44:10 +00:00
if ( $revision -> isDeleted ( Revision :: DELETED_COMMENT )) {
$vals [ 'commenthidden' ] = '' ;
} else {
$comment = $revision -> getComment ();
if ( strval ( $comment ) !== '' )
$vals [ 'comment' ] = $comment ;
}
2007-05-20 08:34:47 +00:00
}
2008-04-14 07:45:50 +00:00
2008-07-04 12:07:02 +00:00
if ( ! is_null ( $this -> token ) || ( $this -> fld_content && $this -> expandTemplates ))
2008-05-13 10:42:32 +00:00
$title = $revision -> getTitle ();
2008-04-14 07:45:50 +00:00
2008-07-04 12:07:02 +00:00
if ( ! is_null ( $this -> token ))
{
$tokenFunctions = $this -> getTokenFunctions ();
foreach ( $this -> token as $t )
{
$val = call_user_func ( $tokenFunctions [ $t ], $title -> getArticleID (), $title , $revision );
if ( $val === false )
$this -> setWarning ( " Action ' $t ' is not allowed for the current user " );
else
$vals [ $t . 'token' ] = $val ;
}
2007-12-01 15:08:57 +00:00
}
2009-02-05 11:44:10 +00:00
if ( $this -> fld_content && ! $revision -> isDeleted ( Revision :: DELETED_TEXT )) {
2008-03-14 13:07:38 +00:00
global $wgParser ;
2008-05-13 10:42:32 +00:00
$text = $revision -> getText ();
2008-03-14 13:07:38 +00:00
# Expand templates after getting section content because
# template-added sections don't count and Parser::preprocess()
# will have less input
if ( $this -> section !== false ) {
$text = $wgParser -> getSection ( $text , $this -> section , false );
if ( $text === false )
2008-05-13 10:42:32 +00:00
$this -> dieUsage ( " There is no section { $this -> section } in r " . $revision -> getId (), 'nosuchsection' );
2008-03-14 13:07:38 +00:00
}
2008-11-21 13:55:27 +00:00
if ( $this -> generateXML ) {
$wgParser -> startExternalParse ( $title , new ParserOptions (), OT_PREPROCESS );
$dom = $wgParser -> preprocessToDom ( $text );
if ( is_callable ( array ( $dom , 'saveXML' ) ) ) {
$xml = $dom -> saveXML ();
} else {
$xml = $dom -> __toString ();
}
$vals [ 'parsetree' ] = $xml ;
}
2007-09-25 18:36:25 +00:00
if ( $this -> expandTemplates ) {
2007-12-01 15:08:57 +00:00
$text = $wgParser -> preprocess ( $text , $title , new ParserOptions () );
2007-09-25 18:36:25 +00:00
}
ApiResult :: setContent ( $vals , $text );
2009-02-05 11:44:10 +00:00
} else if ( $this -> fld_content ) {
$vals [ 'texthidden' ] = '' ;
2008-04-14 07:45:50 +00:00
}
2007-05-20 08:34:47 +00:00
return $vals ;
}
2008-01-28 19:05:26 +00:00
public function getAllowedParams () {
2006-09-26 05:43:02 +00:00
return array (
2006-10-03 05:41:55 +00:00
'prop' => array (
2006-10-01 20:17:16 +00:00
ApiBase :: PARAM_ISMULTI => true ,
2007-05-21 06:32:32 +00:00
ApiBase :: PARAM_DFLT => 'ids|timestamp|flags|comment|user' ,
2006-10-01 20:17:16 +00:00
ApiBase :: PARAM_TYPE => array (
2007-05-21 06:32:32 +00:00
'ids' ,
'flags' ,
2006-10-01 20:17:16 +00:00
'timestamp' ,
'user' ,
2007-08-09 06:38:48 +00:00
'size' ,
2006-10-01 20:17:16 +00:00
'comment' ,
2007-08-09 06:38:48 +00:00
'content' ,
2006-10-01 20:17:16 +00:00
)
),
2006-10-03 05:41:55 +00:00
'limit' => array (
2006-10-01 20:17:16 +00:00
ApiBase :: PARAM_TYPE => 'limit' ,
2006-10-17 02:01:20 +00:00
ApiBase :: PARAM_MIN => 1 ,
2007-10-05 07:37:58 +00:00
ApiBase :: PARAM_MAX => ApiBase :: LIMIT_BIG1 ,
ApiBase :: PARAM_MAX2 => ApiBase :: LIMIT_BIG2
2006-09-27 05:13:48 +00:00
),
2006-10-16 00:08:03 +00:00
'startid' => array (
ApiBase :: PARAM_TYPE => 'integer'
),
'endid' => array (
ApiBase :: PARAM_TYPE => 'integer'
),
2006-10-03 05:41:55 +00:00
'start' => array (
2006-10-01 20:17:16 +00:00
ApiBase :: PARAM_TYPE => 'timestamp'
2006-09-26 05:43:02 +00:00
),
2006-10-03 05:41:55 +00:00
'end' => array (
2006-10-01 20:17:16 +00:00
ApiBase :: PARAM_TYPE => 'timestamp'
2006-09-26 05:43:02 +00:00
),
2006-10-03 05:41:55 +00:00
'dir' => array (
2006-10-01 20:17:16 +00:00
ApiBase :: PARAM_DFLT => 'older' ,
ApiBase :: PARAM_TYPE => array (
2006-09-26 05:43:02 +00:00
'newer' ,
'older'
)
2007-05-19 04:13:48 +00:00
),
'user' => array (
ApiBase :: PARAM_TYPE => 'user'
),
'excludeuser' => array (
ApiBase :: PARAM_TYPE => 'user'
2007-09-25 18:36:25 +00:00
),
'expandtemplates' => false ,
2008-11-21 13:55:27 +00:00
'generatexml' => false ,
2008-12-03 19:01:30 +00:00
'section' => null ,
2007-12-01 15:08:57 +00:00
'token' => array (
2008-07-04 12:07:02 +00:00
ApiBase :: PARAM_TYPE => array_keys ( $this -> getTokenFunctions ()),
2007-12-01 15:08:57 +00:00
ApiBase :: PARAM_ISMULTI => true
),
* 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
'continue' => null ,
2006-09-26 05:43:02 +00:00
);
}
2008-01-28 19:05:26 +00:00
public function getParamDescription () {
2006-10-01 20:17:16 +00:00
return array (
2006-10-16 00:08:03 +00:00
'prop' => 'Which properties to get for each revision.' ,
2006-10-03 05:41:55 +00:00
'limit' => 'limit how many revisions will be returned (enum)' ,
'startid' => 'from which revision id to start enumeration (enum)' ,
'endid' => 'stop revision enumeration on this revid (enum)' ,
'start' => 'from which revision timestamp to start enumeration (enum)' ,
'end' => 'enumerate up to this timestamp (enum)' ,
2007-05-19 04:13:48 +00:00
'dir' => 'direction of enumeration - towards "newer" or "older" revisions (enum)' ,
'user' => 'only include revisions made by user' ,
'excludeuser' => 'exclude revisions made by user' ,
2007-11-27 16:41:13 +00:00
'expandtemplates' => 'expand templates in revision content' ,
2008-11-21 13:55:27 +00:00
'generatexml' => 'generate XML parse tree for revision content' ,
2008-03-14 13:07:38 +00:00
'section' => 'only retrieve the content of this section' ,
2007-12-01 15:08:57 +00:00
'token' => 'Which tokens to obtain for each revision' ,
* 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
'continue' => 'When more results are available, use this to continue' ,
2006-10-01 20:17:16 +00:00
);
}
2008-01-28 19:05:26 +00:00
public function getDescription () {
2006-09-30 08:06:27 +00:00
return array (
'Get revision information.' ,
'This module may be used in several ways:' ,
' 1) Get data about a set of pages (last revision), by setting titles or pageids parameter.' ,
2006-10-03 05:41:55 +00:00
' 2) Get revisions for one given page, by using titles/pageids with start/end/limit params.' ,
2006-10-01 20:17:16 +00:00
' 3) Get data about a set of revisions by setting their IDs with revids parameter.' ,
'All parameters marked as (enum) may only be used with a single page (#2).'
2006-09-30 08:06:27 +00:00
);
2006-09-26 05:43:02 +00:00
}
2006-09-27 05:13:48 +00:00
protected function getExamples () {
2006-09-26 05:43:02 +00:00
return array (
2007-12-01 17:53:42 +00:00
'Get data with content for the last revision of titles "API" and "Main Page":' ,
' api.php?action=query&prop=revisions&titles=API|Main%20Page&rvprop=timestamp|user|comment|content' ,
2006-10-01 20:17:16 +00:00
'Get last 5 revisions of the "Main Page":' ,
' api.php?action=query&prop=revisions&titles=Main%20Page&rvlimit=5&rvprop=timestamp|user|comment' ,
'Get first 5 revisions of the "Main Page":' ,
' api.php?action=query&prop=revisions&titles=Main%20Page&rvlimit=5&rvprop=timestamp|user|comment&rvdir=newer' ,
'Get first 5 revisions of the "Main Page" made after 2006-05-01:' ,
2007-05-19 04:13:48 +00:00
' api.php?action=query&prop=revisions&titles=Main%20Page&rvlimit=5&rvprop=timestamp|user|comment&rvdir=newer&rvstart=20060501000000' ,
'Get first 5 revisions of the "Main Page" that were not made made by anonymous user "127.0.0.1"' ,
' api.php?action=query&prop=revisions&titles=Main%20Page&rvlimit=5&rvprop=timestamp|user|comment&rvexcludeuser=127.0.0.1' ,
'Get first 5 revisions of the "Main Page" that were made by the user "MediaWiki default"' ,
' api.php?action=query&prop=revisions&titles=Main%20Page&rvlimit=5&rvprop=timestamp|user|comment&rvuser=MediaWiki%20default' ,
2006-09-26 05:43:02 +00:00
);
}
2006-10-01 21:20:55 +00:00
public function getVersion () {
2007-12-06 18:33:18 +00:00
return __CLASS__ . ': $Id$' ;
2006-10-01 21:20:55 +00:00
}
2006-09-26 05:43:02 +00:00
}