2007-12-06 16:06:22 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Created on Jul 2, 2007
|
|
|
|
|
*
|
|
|
|
|
* API for MediaWiki 1.8+
|
|
|
|
|
*
|
|
|
|
|
* Copyright (C) 2007 Roan Kattouw <Firstname>.<Lastname>@home.nl
|
|
|
|
|
*
|
|
|
|
|
* 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' ) ) {
|
2007-12-06 16:06:22 +00:00
|
|
|
// Eclipse helper - will be ignored in production
|
2010-01-11 15:55:52 +00:00
|
|
|
require_once ( 'ApiQueryBase.php' );
|
2007-12-06 16:06:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Query module to enumerate all available pages.
|
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-12-06 16:06:22 +00:00
|
|
|
*/
|
|
|
|
|
class ApiQueryDeletedrevs extends ApiQueryBase {
|
|
|
|
|
|
2010-01-11 15:55:52 +00:00
|
|
|
public function __construct( $query, $moduleName ) {
|
|
|
|
|
parent :: __construct( $query, $moduleName, 'dr' );
|
2007-12-06 16:06:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function execute() {
|
|
|
|
|
|
|
|
|
|
global $wgUser;
|
|
|
|
|
// Before doing anything at all, let's check permissions
|
2010-01-11 15:55:52 +00:00
|
|
|
if ( !$wgUser->isAllowed( 'deletedhistory' ) )
|
|
|
|
|
$this->dieUsage( 'You don\'t have permission to view deleted revision information', 'permissiondenied' );
|
2007-12-06 16:06:22 +00:00
|
|
|
|
|
|
|
|
$db = $this->getDB();
|
2010-01-11 15:55:52 +00:00
|
|
|
$params = $this->extractRequestParams( false );
|
|
|
|
|
$prop = array_flip( $params['prop'] );
|
|
|
|
|
$fld_revid = isset( $prop['revid'] );
|
|
|
|
|
$fld_user = isset( $prop['user'] );
|
|
|
|
|
$fld_comment = isset( $prop['comment'] );
|
|
|
|
|
$fld_minor = isset( $prop['minor'] );
|
|
|
|
|
$fld_len = isset( $prop['len'] );
|
|
|
|
|
$fld_content = isset( $prop['content'] );
|
|
|
|
|
$fld_token = isset( $prop['token'] );
|
2009-01-12 16:39:04 +00:00
|
|
|
|
2007-12-06 16:06:22 +00:00
|
|
|
$result = $this->getResult();
|
|
|
|
|
$pageSet = $this->getPageSet();
|
|
|
|
|
$titles = $pageSet->getTitles();
|
|
|
|
|
$data = array();
|
2009-01-12 16:39:04 +00:00
|
|
|
|
|
|
|
|
// This module operates in three modes:
|
|
|
|
|
// 'revs': List deleted revs for certain titles
|
|
|
|
|
// 'user': List deleted revs by a certain user
|
|
|
|
|
// 'all': List all deleted revs
|
|
|
|
|
$mode = 'all';
|
2010-01-11 15:55:52 +00:00
|
|
|
if ( count( $titles ) > 0 )
|
2009-01-12 16:39:04 +00:00
|
|
|
$mode = 'revs';
|
2010-01-11 15:55:52 +00:00
|
|
|
else if ( !is_null( $params['user'] ) )
|
2009-01-12 16:39:04 +00:00
|
|
|
$mode = 'user';
|
|
|
|
|
|
2010-01-11 15:55:52 +00:00
|
|
|
if ( !is_null( $params['user'] ) && !is_null( $params['excludeuser'] ) )
|
2010-01-31 21:12:15 +00:00
|
|
|
$this->dieUsage( 'user and excludeuser cannot be used together', 'badparams' );
|
2010-01-11 15:55:52 +00:00
|
|
|
|
|
|
|
|
$this->addTables( 'archive' );
|
|
|
|
|
$this->addWhere( 'ar_deleted = 0' );
|
|
|
|
|
$this->addFields( array( 'ar_title', 'ar_namespace', 'ar_timestamp' ) );
|
|
|
|
|
if ( $fld_revid )
|
|
|
|
|
$this->addFields( 'ar_rev_id' );
|
|
|
|
|
if ( $fld_user )
|
|
|
|
|
$this->addFields( 'ar_user_text' );
|
|
|
|
|
if ( $fld_comment )
|
|
|
|
|
$this->addFields( 'ar_comment' );
|
|
|
|
|
if ( $fld_minor )
|
|
|
|
|
$this->addFields( 'ar_minor_edit' );
|
|
|
|
|
if ( $fld_len )
|
|
|
|
|
$this->addFields( 'ar_len' );
|
2010-01-31 21:12:15 +00:00
|
|
|
if ( $fld_content ) {
|
2010-01-11 15:55:52 +00:00
|
|
|
$this->addTables( 'text' );
|
|
|
|
|
$this->addFields( array( 'ar_text', 'ar_text_id', 'old_text', 'old_flags' ) );
|
|
|
|
|
$this->addWhere( 'ar_text_id = old_id' );
|
2007-12-06 16:06:22 +00:00
|
|
|
|
2008-01-05 10:05:34 +00:00
|
|
|
// This also means stricter restrictions
|
2010-01-11 15:55:52 +00:00
|
|
|
if ( !$wgUser->isAllowed( 'undelete' ) )
|
|
|
|
|
$this->dieUsage( 'You don\'t have permission to view deleted revision content', 'permissiondenied' );
|
2007-12-06 16:06:22 +00:00
|
|
|
}
|
2008-01-05 10:05:34 +00:00
|
|
|
// Check limits
|
|
|
|
|
$userMax = $fld_content ? ApiBase :: LIMIT_SML1 : ApiBase :: LIMIT_BIG1;
|
|
|
|
|
$botMax = $fld_content ? ApiBase :: LIMIT_SML2 : ApiBase :: LIMIT_BIG2;
|
2008-02-28 17:25:33 +00:00
|
|
|
|
|
|
|
|
$limit = $params['limit'];
|
|
|
|
|
|
2010-01-11 15:55:52 +00:00
|
|
|
if ( $limit == 'max' ) {
|
2008-01-05 10:05:34 +00:00
|
|
|
$limit = $this->getMain()->canApiHighLimits() ? $botMax : $userMax;
|
2008-02-28 17:25:33 +00:00
|
|
|
$this->getResult()->addValue( 'limits', $this->getModuleName(), $limit );
|
2008-01-05 10:05:34 +00:00
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2010-01-11 15:55:52 +00:00
|
|
|
$this->validateLimit( 'limit', $limit, 1, $userMax, $botMax );
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2010-01-11 15:55:52 +00:00
|
|
|
if ( $fld_token )
|
2007-12-06 16:06:22 +00:00
|
|
|
// Undelete tokens are identical for all pages, so we cache one here
|
|
|
|
|
$token = $wgUser->editToken();
|
|
|
|
|
|
|
|
|
|
// We need a custom WHERE clause that matches all titles.
|
2010-01-31 21:12:15 +00:00
|
|
|
if ( $mode == 'revs' ) {
|
2010-01-11 15:55:52 +00:00
|
|
|
$lb = new LinkBatch( $titles );
|
|
|
|
|
$where = $lb->constructSet( 'ar', $db );
|
|
|
|
|
$this->addWhere( $where );
|
2010-01-31 21:12:15 +00:00
|
|
|
} elseif ( $mode == 'all' ) {
|
2010-01-11 15:55:52 +00:00
|
|
|
$this->addWhereFld( 'ar_namespace', $params['namespace'] );
|
|
|
|
|
if ( !is_null( $params['from'] ) )
|
2009-01-12 16:39:04 +00:00
|
|
|
{
|
2010-01-11 15:55:52 +00:00
|
|
|
$from = $this->getDB()->strencode( $this->titleToKey( $params['from'] ) );
|
|
|
|
|
$this->addWhere( "ar_title >= '$from'" );
|
2009-01-12 16:39:04 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-01-11 15:55:52 +00:00
|
|
|
if ( !is_null( $params['user'] ) ) {
|
|
|
|
|
$this->addWhereFld( 'ar_user_text', $params['user'] );
|
|
|
|
|
} elseif ( !is_null( $params['excludeuser'] ) ) {
|
|
|
|
|
$this->addWhere( 'ar_user_text != ' .
|
|
|
|
|
$this->getDB()->addQuotes( $params['excludeuser'] ) );
|
2009-01-12 16:39:04 +00:00
|
|
|
}
|
|
|
|
|
|
2010-01-11 15:55:52 +00:00
|
|
|
if ( !is_null( $params['continue'] ) && ( $mode == 'all' || $mode == 'revs' ) )
|
2009-01-12 16:39:04 +00:00
|
|
|
{
|
2010-01-11 15:55:52 +00:00
|
|
|
$cont = explode( '|', $params['continue'] );
|
|
|
|
|
if ( count( $cont ) != 3 )
|
|
|
|
|
$this->dieUsage( "Invalid continue param. You should pass the original value returned by the previous query", "badcontinue" );
|
|
|
|
|
$ns = intval( $cont[0] );
|
|
|
|
|
$title = $this->getDB()->strencode( $this->titleToKey( $cont[1] ) );
|
|
|
|
|
$ts = $this->getDB()->strencode( $cont[2] );
|
|
|
|
|
$op = ( $params['dir'] == 'newer' ? '>' : '<' );
|
|
|
|
|
$this->addWhere( "ar_namespace $op $ns OR " .
|
2009-04-28 11:30:02 +00:00
|
|
|
"(ar_namespace = $ns AND " .
|
|
|
|
|
"(ar_title $op '$title' OR " .
|
2009-01-12 16:39:04 +00:00
|
|
|
"(ar_title = '$title' AND " .
|
2010-01-11 15:55:52 +00:00
|
|
|
"ar_timestamp $op= '$ts')))" );
|
2007-12-06 16:06:22 +00:00
|
|
|
}
|
|
|
|
|
|
2010-01-11 15:55:52 +00:00
|
|
|
$this->addOption( 'LIMIT', $limit + 1 );
|
|
|
|
|
$this->addOption( 'USE INDEX', array( 'archive' => ( $mode == 'user' ? 'usertext_timestamp' : 'name_title_timestamp' ) ) );
|
2010-01-31 21:12:15 +00:00
|
|
|
if ( $mode == 'all' ) {
|
2010-01-11 15:55:52 +00:00
|
|
|
if ( $params['unique'] )
|
2009-01-12 16:39:04 +00:00
|
|
|
{
|
2010-01-11 15:55:52 +00:00
|
|
|
$this->addOption( 'GROUP BY', 'ar_title' );
|
|
|
|
|
$this->addOption( 'ORDER BY', 'ar_title' );
|
2010-01-31 21:12:15 +00:00
|
|
|
} else
|
2010-01-11 15:55:52 +00:00
|
|
|
$this->addOption( 'ORDER BY', 'ar_title, ar_timestamp' );
|
2010-01-31 21:12:15 +00:00
|
|
|
} else {
|
2010-01-11 15:55:52 +00:00
|
|
|
if ( $mode == 'revs' )
|
2009-01-12 16:39:04 +00:00
|
|
|
{
|
|
|
|
|
// Sort by ns and title in the same order as timestamp for efficiency
|
2010-01-11 15:55:52 +00:00
|
|
|
$this->addWhereRange( 'ar_namespace', $params['dir'], null, null );
|
|
|
|
|
$this->addWhereRange( 'ar_title', $params['dir'], null, null );
|
2009-01-12 16:39:04 +00:00
|
|
|
}
|
2010-01-11 15:55:52 +00:00
|
|
|
$this->addWhereRange( 'ar_timestamp', $params['dir'], $params['start'], $params['end'] );
|
2009-01-12 16:39:04 +00:00
|
|
|
}
|
2010-01-11 15:55:52 +00:00
|
|
|
$res = $this->select( __METHOD__ );
|
* 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
|
|
|
$pageMap = array(); // Maps ns&title to (fake) pageid
|
2007-12-06 16:06:22 +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
|
|
|
$newPageID = 0;
|
2010-01-11 15:55:52 +00:00
|
|
|
while ( $row = $db->fetchObject( $res ) )
|
2007-12-06 16:06:22 +00:00
|
|
|
{
|
2010-01-31 21:12:15 +00:00
|
|
|
if ( ++$count > $limit ) {
|
2007-12-06 16:06:22 +00:00
|
|
|
// We've had enough
|
2010-01-11 15:55:52 +00:00
|
|
|
if ( $mode == 'all' || $mode == 'revs' )
|
|
|
|
|
$this->setContinueEnumParameter( 'continue', intval( $row->ar_namespace ) . '|' .
|
|
|
|
|
$this->keyToTitle( $row->ar_title ) . '|' . $row->ar_timestamp );
|
2009-01-12 16:39:04 +00:00
|
|
|
else
|
2010-01-11 15:55:52 +00:00
|
|
|
$this->setContinueEnumParameter( 'start', wfTimestamp( TS_ISO_8601, $row->ar_timestamp ) );
|
2007-12-06 16:06:22 +00:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$rev = array();
|
2010-01-11 15:55:52 +00:00
|
|
|
$rev['timestamp'] = wfTimestamp( TS_ISO_8601, $row->ar_timestamp );
|
|
|
|
|
if ( $fld_revid )
|
|
|
|
|
$rev['revid'] = intval( $row->ar_rev_id );
|
|
|
|
|
if ( $fld_user )
|
2007-12-06 16:06:22 +00:00
|
|
|
$rev['user'] = $row->ar_user_text;
|
2010-01-11 15:55:52 +00:00
|
|
|
if ( $fld_comment )
|
2007-12-06 16:06:22 +00:00
|
|
|
$rev['comment'] = $row->ar_comment;
|
2010-01-31 21:21:46 +00:00
|
|
|
if ( $fld_minor && $row->ar_minor_edit == 1 )
|
2007-12-06 16:06:22 +00:00
|
|
|
$rev['minor'] = '';
|
2010-01-11 15:55:52 +00:00
|
|
|
if ( $fld_len )
|
2007-12-06 16:06:22 +00:00
|
|
|
$rev['len'] = $row->ar_len;
|
2010-01-11 15:55:52 +00:00
|
|
|
if ( $fld_content )
|
|
|
|
|
ApiResult::setContent( $rev, Revision::getRevisionText( $row ) );
|
2007-12-06 16:06:22 +00:00
|
|
|
|
2010-01-31 21:12:15 +00:00
|
|
|
if ( !isset( $pageMap[$row->ar_namespace][$row->ar_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
|
|
|
$pageID = $newPageID++;
|
|
|
|
|
$pageMap[$row->ar_namespace][$row->ar_title] = $pageID;
|
2010-01-11 15:55:52 +00:00
|
|
|
$t = Title::makeTitle( $row->ar_namespace, $row->ar_title );
|
|
|
|
|
$a['revisions'] = array( $rev );
|
|
|
|
|
$result->setIndexedTagName( $a['revisions'], 'rev' );
|
|
|
|
|
ApiQueryBase::addTitleInfo( $a, $t );
|
|
|
|
|
if ( $fld_token )
|
* 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['token'] = $token;
|
2010-01-11 15:55:52 +00:00
|
|
|
$fit = $result->addValue( array( 'query', $this->getModuleName() ), $pageID, $a );
|
2010-01-31 21:12:15 +00:00
|
|
|
} else {
|
* 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
|
|
|
$pageID = $pageMap[$row->ar_namespace][$row->ar_title];
|
|
|
|
|
$fit = $result->addValue(
|
2010-01-11 15:55:52 +00:00
|
|
|
array( 'query', $this->getModuleName(), $pageID, 'revisions' ),
|
|
|
|
|
null, $rev );
|
* 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-31 21:12:15 +00:00
|
|
|
if ( !$fit ) {
|
2010-01-11 15:55:52 +00:00
|
|
|
if ( $mode == 'all' || $mode == 'revs' )
|
|
|
|
|
$this->setContinueEnumParameter( 'continue', intval( $row->ar_namespace ) . '|' .
|
|
|
|
|
$this->keyToTitle( $row->ar_title ) . '|' . $row->ar_timestamp );
|
2009-02-09 13:28:12 +00:00
|
|
|
else
|
2010-01-11 15:55:52 +00:00
|
|
|
$this->setContinueEnumParameter( 'start', wfTimestamp( TS_ISO_8601, $row->ar_timestamp ) );
|
* 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;
|
|
|
|
|
}
|
2007-12-06 16:06:22 +00:00
|
|
|
}
|
2010-01-11 15:55:52 +00:00
|
|
|
$db->freeResult( $res );
|
|
|
|
|
$result->setIndexedTagName_internal( array( 'query', $this->getModuleName() ), 'page' );
|
* 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
|
|
|
}
|
2007-12-06 16:06:22 +00:00
|
|
|
|
2008-01-28 19:05:26 +00:00
|
|
|
public function getAllowedParams() {
|
2007-12-06 16:06:22 +00:00
|
|
|
return array (
|
|
|
|
|
'start' => array(
|
|
|
|
|
ApiBase :: PARAM_TYPE => 'timestamp'
|
|
|
|
|
),
|
|
|
|
|
'end' => array(
|
|
|
|
|
ApiBase :: PARAM_TYPE => 'timestamp',
|
|
|
|
|
),
|
|
|
|
|
'dir' => array(
|
|
|
|
|
ApiBase :: PARAM_TYPE => array(
|
|
|
|
|
'newer',
|
|
|
|
|
'older'
|
|
|
|
|
),
|
|
|
|
|
ApiBase :: PARAM_DFLT => 'older'
|
|
|
|
|
),
|
2009-01-12 16:39:04 +00:00
|
|
|
'from' => null,
|
|
|
|
|
'continue' => null,
|
|
|
|
|
'unique' => false,
|
|
|
|
|
'user' => array(
|
|
|
|
|
ApiBase :: PARAM_TYPE => 'user'
|
|
|
|
|
),
|
|
|
|
|
'excludeuser' => array(
|
|
|
|
|
ApiBase :: PARAM_TYPE => 'user'
|
|
|
|
|
),
|
|
|
|
|
'namespace' => array(
|
|
|
|
|
ApiBase :: PARAM_TYPE => 'namespace',
|
|
|
|
|
ApiBase :: PARAM_DFLT => 0,
|
|
|
|
|
),
|
2007-12-06 16:06:22 +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
|
|
|
|
|
),
|
|
|
|
|
'prop' => array(
|
|
|
|
|
ApiBase :: PARAM_DFLT => 'user|comment',
|
|
|
|
|
ApiBase :: PARAM_TYPE => array(
|
|
|
|
|
'revid',
|
|
|
|
|
'user',
|
|
|
|
|
'comment',
|
|
|
|
|
'minor',
|
|
|
|
|
'len',
|
|
|
|
|
'content',
|
|
|
|
|
'token'
|
|
|
|
|
),
|
|
|
|
|
ApiBase :: PARAM_ISMULTI => true
|
2009-01-12 16:39:04 +00:00
|
|
|
),
|
2007-12-06 16:06:22 +00:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2008-01-28 19:05:26 +00:00
|
|
|
public function getParamDescription() {
|
2007-12-06 16:06:22 +00:00
|
|
|
return array (
|
2009-01-12 16:39:04 +00:00
|
|
|
'start' => 'The timestamp to start enumerating from. (1,2)',
|
|
|
|
|
'end' => 'The timestamp to stop enumerating at. (1,2)',
|
|
|
|
|
'dir' => 'The direction in which to enumerate. (1,2)',
|
2007-12-06 16:06:22 +00:00
|
|
|
'limit' => 'The maximum amount of revisions to list',
|
2009-01-12 16:39:04 +00:00
|
|
|
'prop' => 'Which properties to get',
|
|
|
|
|
'namespace' => 'Only list pages in this namespace (3)',
|
|
|
|
|
'user' => 'Only list revisions by this user',
|
|
|
|
|
'excludeuser' => 'Don\'t list revisions by this user',
|
|
|
|
|
'from' => 'Start listing at this title (3)',
|
|
|
|
|
'continue' => 'When more results are available, use this to continue (3)',
|
|
|
|
|
'unique' => 'List only one revision for each page (3)',
|
2007-12-06 16:06:22 +00:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2008-01-28 19:05:26 +00:00
|
|
|
public function getDescription() {
|
2009-01-12 16:39:04 +00:00
|
|
|
return array( 'List deleted revisions.',
|
|
|
|
|
'This module operates in three modes:',
|
|
|
|
|
'1) List deleted revisions for the given title(s), sorted by timestamp',
|
|
|
|
|
'2) List deleted contributions for the given user, sorted by timestamp (no titles specified)',
|
|
|
|
|
'3) List all deleted revisions in the given namespace, sorted by title and timestamp (no titles specified, druser not set)',
|
|
|
|
|
'Certain parameters only apply to some modes and are ignored in others.',
|
|
|
|
|
'For instance, a parameter marked (1) only applies to mode 1 and is ignored in modes 2 and 3.',
|
|
|
|
|
);
|
2007-12-06 16:06:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected function getExamples() {
|
|
|
|
|
return array (
|
2009-01-12 16:39:04 +00:00
|
|
|
'List the last deleted revisions of Main Page and Talk:Main Page, with content (mode 1):',
|
|
|
|
|
' api.php?action=query&list=deletedrevs&titles=Main%20Page|Talk:Main%20Page&drprop=user|comment|content',
|
|
|
|
|
'List the last 50 deleted contributions by Bob (mode 2):',
|
|
|
|
|
' api.php?action=query&list=deletedrevs&druser=Bob&drlimit=50',
|
|
|
|
|
'List the first 50 deleted revisions in the main namespace (mode 3):',
|
2008-03-26 13:43:11 +00:00
|
|
|
' api.php?action=query&list=deletedrevs&drdir=newer&drlimit=50',
|
2009-01-12 16:39:04 +00:00
|
|
|
'List the first 50 deleted pages in the Talk namespace (mode 3):',
|
|
|
|
|
' api.php?action=query&list=deletedrevs&drdir=newer&drlimit=50&drnamespace=1&drunique',
|
2007-12-06 16:06:22 +00:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getVersion() {
|
2007-12-06 18:33:18 +00:00
|
|
|
return __CLASS__ . ': $Id$';
|
2007-12-06 16:06:22 +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
|
|
|
}
|