2007-12-06 16:06:22 +00:00
|
|
|
<?php
|
2010-02-24 14:00:23 +00:00
|
|
|
/**
|
2010-12-22 20:52:06 +00:00
|
|
|
*
|
2007-12-06 16:06:22 +00:00
|
|
|
*
|
2010-08-07 19:59:42 +00:00
|
|
|
* Created on Jul 2, 2007
|
|
|
|
|
*
|
2010-12-22 20:48:10 +00:00
|
|
|
* Copyright © 2007 Roan Kattouw <Firstname>.<Lastname>@gmail.com
|
2007-12-06 16:06:22 +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.,
|
2010-06-21 13:13:32 +00:00
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2007-12-06 16:06:22 +00:00
|
|
|
* http://www.gnu.org/copyleft/gpl.html
|
2010-08-07 19:59:42 +00:00
|
|
|
*
|
|
|
|
|
* @file
|
2007-12-06 16:06:22 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/**
|
2010-05-10 20:35:24 +00:00
|
|
|
* Query module to enumerate all deleted revisions.
|
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 ) {
|
2010-02-24 14:00:23 +00:00
|
|
|
parent::__construct( $query, $moduleName, 'dr' );
|
2007-12-06 16:06:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function execute() {
|
2011-10-26 23:27:01 +00:00
|
|
|
$user = $this->getUser();
|
2007-12-06 16:06:22 +00:00
|
|
|
// Before doing anything at all, let's check permissions
|
2011-10-26 23:27:01 +00:00
|
|
|
if ( !$user->isAllowed( 'deletedhistory' ) ) {
|
2010-01-11 15:55:52 +00:00
|
|
|
$this->dieUsage( 'You don\'t have permission to view deleted revision information', 'permissiondenied' );
|
2010-02-24 14:00:23 +00:00
|
|
|
}
|
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'] );
|
2011-04-10 21:11:39 +00:00
|
|
|
$fld_parentid = isset( $prop['parentid'] );
|
2010-01-11 15:55:52 +00:00
|
|
|
$fld_revid = isset( $prop['revid'] );
|
|
|
|
|
$fld_user = isset( $prop['user'] );
|
2010-08-28 00:52:38 +00:00
|
|
|
$fld_userid = isset( $prop['userid'] );
|
2010-01-11 15:55:52 +00:00
|
|
|
$fld_comment = isset( $prop['comment'] );
|
2010-01-31 23:06:35 +00:00
|
|
|
$fld_parsedcomment = isset ( $prop['parsedcomment'] );
|
2010-01-11 15:55:52 +00:00
|
|
|
$fld_minor = isset( $prop['minor'] );
|
|
|
|
|
$fld_len = isset( $prop['len'] );
|
2011-12-17 18:27:38 +00:00
|
|
|
$fld_sha1 = isset( $prop['sha1'] );
|
2010-01-11 15:55:52 +00:00
|
|
|
$fld_content = isset( $prop['content'] );
|
|
|
|
|
$fld_token = isset( $prop['token'] );
|
2010-02-24 14:00:23 +00:00
|
|
|
|
2007-12-06 16:06:22 +00:00
|
|
|
$result = $this->getResult();
|
|
|
|
|
$pageSet = $this->getPageSet();
|
|
|
|
|
$titles = $pageSet->getTitles();
|
2010-02-24 14:00:23 +00:00
|
|
|
|
2009-01-12 16:39:04 +00:00
|
|
|
// This module operates in three modes:
|
2011-04-23 16:57:03 +00:00
|
|
|
// 'revs': List deleted revs for certain titles (1)
|
|
|
|
|
// 'user': List deleted revs by a certain user (2)
|
|
|
|
|
// 'all': List all deleted revs in NS (3)
|
2009-01-12 16:39:04 +00:00
|
|
|
$mode = 'all';
|
2010-02-24 14:00:23 +00:00
|
|
|
if ( count( $titles ) > 0 ) {
|
2009-01-12 16:39:04 +00:00
|
|
|
$mode = 'revs';
|
2010-02-24 14:00:23 +00:00
|
|
|
} elseif ( !is_null( $params['user'] ) ) {
|
2009-01-12 16:39:04 +00:00
|
|
|
$mode = 'user';
|
2010-02-24 14:00:23 +00:00
|
|
|
}
|
|
|
|
|
|
2011-04-23 16:57:03 +00:00
|
|
|
if ( $mode == 'revs' || $mode == 'user' ) {
|
|
|
|
|
// Ignore namespace and unique due to inability to know whether they were purposely set
|
|
|
|
|
foreach( array( 'from', 'to', 'prefix', /*'namespace',*/ 'continue', /*'unique'*/ ) as $p ) {
|
|
|
|
|
if ( !is_null( $params[$p] ) ) {
|
|
|
|
|
$this->dieUsage( "The '{$p}' parameter cannot be used in modes 1 or 2", 'badparams');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
foreach( array( 'start', 'end' ) as $p ) {
|
|
|
|
|
if ( !is_null( $params[$p] ) ) {
|
|
|
|
|
$this->dieUsage( "The {$p} parameter cannot be used in mode 3", 'badparams');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-02-24 14:00:23 +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-02-24 14:00:23 +00:00
|
|
|
}
|
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' ) );
|
2011-04-10 21:11:39 +00:00
|
|
|
|
2011-06-01 16:40:59 +00:00
|
|
|
$this->addFieldsIf( 'ar_parent_id', $fld_parentid );
|
|
|
|
|
$this->addFieldsIf( 'ar_rev_id', $fld_revid );
|
|
|
|
|
$this->addFieldsIf( 'ar_user_text', $fld_user );
|
|
|
|
|
$this->addFieldsIf( 'ar_user', $fld_userid );
|
|
|
|
|
$this->addFieldsIf( 'ar_comment', $fld_comment || $fld_parsedcomment );
|
|
|
|
|
$this->addFieldsIf( 'ar_minor_edit', $fld_minor );
|
|
|
|
|
$this->addFieldsIf( 'ar_len', $fld_len );
|
2011-12-17 18:27:38 +00:00
|
|
|
$this->addFieldsIf( 'ar_sha1', $fld_sha1 );
|
2011-06-01 16:40:59 +00:00
|
|
|
|
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
|
2011-10-26 23:27:01 +00:00
|
|
|
if ( !$user->isAllowed( 'undelete' ) ) {
|
2010-01-11 15:55:52 +00:00
|
|
|
$this->dieUsage( 'You don\'t have permission to view deleted revision content', 'permissiondenied' );
|
2010-02-24 14:00:23 +00:00
|
|
|
}
|
2007-12-06 16:06:22 +00:00
|
|
|
}
|
2008-01-05 10:05:34 +00:00
|
|
|
// Check limits
|
2010-02-24 14:00:23 +00:00
|
|
|
$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;
|
2010-07-28 11:30:14 +00:00
|
|
|
$this->getResult()->setParsedLimit( $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-02-24 14:00:23 +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
|
2011-10-27 00:46:17 +00:00
|
|
|
$token = $user->getEditToken( '', $this->getMain()->getRequest() );
|
2010-02-24 14:00:23 +00:00
|
|
|
}
|
2007-12-06 16:06:22 +00:00
|
|
|
|
2011-03-13 17:59:27 +00:00
|
|
|
$dir = $params['dir'];
|
|
|
|
|
|
2007-12-06 16:06:22 +00:00
|
|
|
// 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'] );
|
2011-03-13 17:59:27 +00:00
|
|
|
|
|
|
|
|
$from = is_null( $params['from'] ) ? null : $this->titleToKey( $params['from'] );
|
|
|
|
|
$to = is_null( $params['to'] ) ? null : $this->titleToKey( $params['to'] );
|
|
|
|
|
$this->addWhereRange( 'ar_title', $dir, $from, $to );
|
2011-04-23 16:03:40 +00:00
|
|
|
|
|
|
|
|
if ( isset( $params['prefix'] ) ) {
|
|
|
|
|
$this->addWhere( 'ar_title' . $db->buildLike( $this->titlePartToKey( $params['prefix'] ), $db->anyString() ) );
|
|
|
|
|
}
|
2009-01-12 16:39:04 +00:00
|
|
|
}
|
2010-02-24 14:00:23 +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 != ' .
|
2012-05-16 17:22:36 +00:00
|
|
|
$db->addQuotes( $params['excludeuser'] ) );
|
2009-01-12 16:39:04 +00:00
|
|
|
}
|
2010-02-24 14:00:23 +00:00
|
|
|
|
2011-03-13 17:59:27 +00:00
|
|
|
if ( !is_null( $params['continue'] ) && ( $mode == 'all' || $mode == 'revs' ) ) {
|
2010-01-11 15:55:52 +00:00
|
|
|
$cont = explode( '|', $params['continue'] );
|
2010-02-24 14:00:23 +00:00
|
|
|
if ( count( $cont ) != 3 ) {
|
|
|
|
|
$this->dieUsage( 'Invalid continue param. You should pass the original value returned by the previous query', 'badcontinue' );
|
|
|
|
|
}
|
2010-01-11 15:55:52 +00:00
|
|
|
$ns = intval( $cont[0] );
|
2012-05-16 17:22:36 +00:00
|
|
|
$title = $db->addQuotes( $this->titleToKey( $cont[1] ) );
|
|
|
|
|
$ts = $db->addQuotes( $db->timestamp( $cont[2] ) );
|
2011-03-13 17:59:27 +00:00
|
|
|
$op = ( $dir == 'newer' ? '>' : '<' );
|
2010-01-11 15:55:52 +00:00
|
|
|
$this->addWhere( "ar_namespace $op $ns OR " .
|
2009-04-28 11:30:02 +00:00
|
|
|
"(ar_namespace = $ns AND " .
|
2012-05-16 17:22:36 +00:00
|
|
|
"(ar_title $op $title OR " .
|
|
|
|
|
"(ar_title = $title AND " .
|
|
|
|
|
"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-02-24 14:00:23 +00:00
|
|
|
if ( $params['unique'] ) {
|
2010-01-11 15:55:52 +00:00
|
|
|
$this->addOption( 'GROUP BY', 'ar_title' );
|
2010-02-24 14:00:23 +00:00
|
|
|
} else {
|
2012-05-05 13:29:08 +00:00
|
|
|
$this->addOption( 'ORDER BY', array(
|
|
|
|
|
'ar_title',
|
|
|
|
|
'ar_timestamp'
|
|
|
|
|
));
|
2010-02-24 14:00:23 +00:00
|
|
|
}
|
2010-01-31 21:12:15 +00:00
|
|
|
} else {
|
2010-02-24 14:00:23 +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
|
2011-03-13 17:59:27 +00:00
|
|
|
$this->addWhereRange( 'ar_namespace', $dir, null, null );
|
|
|
|
|
$this->addWhereRange( 'ar_title', $dir, null, null );
|
2009-01-12 16:39:04 +00:00
|
|
|
}
|
2011-10-06 20:46:24 +00:00
|
|
|
$this->addTimestampWhereRange( 'ar_timestamp', $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-06-20 18:48:34 +00:00
|
|
|
foreach ( $res as $row ) {
|
2010-01-31 21:12:15 +00:00
|
|
|
if ( ++$count > $limit ) {
|
2007-12-06 16:06:22 +00:00
|
|
|
// We've had enough
|
2010-02-24 14:00:23 +00:00
|
|
|
if ( $mode == 'all' || $mode == 'revs' ) {
|
2010-01-11 15:55:52 +00:00
|
|
|
$this->setContinueEnumParameter( 'continue', intval( $row->ar_namespace ) . '|' .
|
|
|
|
|
$this->keyToTitle( $row->ar_title ) . '|' . $row->ar_timestamp );
|
2010-02-24 14:00:23 +00:00
|
|
|
} else {
|
2010-01-11 15:55:52 +00:00
|
|
|
$this->setContinueEnumParameter( 'start', wfTimestamp( TS_ISO_8601, $row->ar_timestamp ) );
|
2010-02-24 14:00:23 +00:00
|
|
|
}
|
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 );
|
2010-02-24 14:00:23 +00:00
|
|
|
if ( $fld_revid ) {
|
2010-01-11 15:55:52 +00:00
|
|
|
$rev['revid'] = intval( $row->ar_rev_id );
|
2010-02-24 14:00:23 +00:00
|
|
|
}
|
2011-07-26 16:17:19 +00:00
|
|
|
if ( $fld_parentid && !is_null( $row->ar_parent_id ) ) {
|
2011-04-10 21:11:39 +00:00
|
|
|
$rev['parentid'] = intval( $row->ar_parent_id );
|
|
|
|
|
}
|
2010-02-24 14:00:23 +00:00
|
|
|
if ( $fld_user ) {
|
2007-12-06 16:06:22 +00:00
|
|
|
$rev['user'] = $row->ar_user_text;
|
2010-02-24 14:00:23 +00:00
|
|
|
}
|
2010-08-28 00:52:38 +00:00
|
|
|
if ( $fld_userid ) {
|
|
|
|
|
$rev['userid'] = $row->ar_user;
|
|
|
|
|
}
|
2010-02-24 14:00:23 +00:00
|
|
|
if ( $fld_comment ) {
|
2007-12-06 16:06:22 +00:00
|
|
|
$rev['comment'] = $row->ar_comment;
|
2010-02-24 14:00:23 +00:00
|
|
|
}
|
2010-01-31 23:06:35 +00:00
|
|
|
|
|
|
|
|
$title = Title::makeTitle( $row->ar_namespace, $row->ar_title );
|
|
|
|
|
|
2010-02-01 15:36:14 +00:00
|
|
|
if ( $fld_parsedcomment ) {
|
2011-09-16 19:35:14 +00:00
|
|
|
$rev['parsedcomment'] = Linker::formatComment( $row->ar_comment, $title );
|
2010-01-31 23:06:35 +00:00
|
|
|
}
|
2010-02-24 14:00:23 +00:00
|
|
|
if ( $fld_minor && $row->ar_minor_edit == 1 ) {
|
2010-01-31 23:06:35 +00:00
|
|
|
$rev['minor'] = '';
|
2010-02-24 14:00:23 +00:00
|
|
|
}
|
|
|
|
|
if ( $fld_len ) {
|
2007-12-06 16:06:22 +00:00
|
|
|
$rev['len'] = $row->ar_len;
|
2010-02-24 14:00:23 +00:00
|
|
|
}
|
2011-12-17 18:27:38 +00:00
|
|
|
if ( $fld_sha1 ) {
|
2011-12-20 21:58:29 +00:00
|
|
|
if ( $row->ar_sha1 != '' ) {
|
|
|
|
|
$rev['sha1'] = wfBaseConvert( $row->ar_sha1, 36, 16, 40 );
|
|
|
|
|
} else {
|
|
|
|
|
$rev['sha1'] = '';
|
|
|
|
|
}
|
2011-12-17 18:27:38 +00:00
|
|
|
}
|
2010-02-24 14:00:23 +00:00
|
|
|
if ( $fld_content ) {
|
2010-01-11 15:55:52 +00:00
|
|
|
ApiResult::setContent( $rev, Revision::getRevisionText( $row ) );
|
2010-02-24 14:00:23 +00:00
|
|
|
}
|
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
|
|
|
$a['revisions'] = array( $rev );
|
|
|
|
|
$result->setIndexedTagName( $a['revisions'], 'rev' );
|
2010-01-31 23:06:35 +00:00
|
|
|
ApiQueryBase::addTitleInfo( $a, $title );
|
2010-02-24 14:00:23 +00:00
|
|
|
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-02-24 14:00:23 +00:00
|
|
|
}
|
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-02-24 14:00:23 +00:00
|
|
|
if ( $mode == 'all' || $mode == 'revs' ) {
|
2010-01-11 15:55:52 +00:00
|
|
|
$this->setContinueEnumParameter( 'continue', intval( $row->ar_namespace ) . '|' .
|
|
|
|
|
$this->keyToTitle( $row->ar_title ) . '|' . $row->ar_timestamp );
|
2010-02-24 14:00:23 +00:00
|
|
|
} else {
|
2010-01-11 15:55:52 +00:00
|
|
|
$this->setContinueEnumParameter( 'start', wfTimestamp( TS_ISO_8601, $row->ar_timestamp ) );
|
2010-02-24 14:00:23 +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
|
|
|
break;
|
|
|
|
|
}
|
2007-12-06 16:06:22 +00:00
|
|
|
}
|
2010-01-11 15:55:52 +00:00
|
|
|
$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() {
|
2010-02-24 14:00:23 +00:00
|
|
|
return array(
|
2007-12-06 16:06:22 +00:00
|
|
|
'start' => array(
|
2010-02-24 14:00:23 +00:00
|
|
|
ApiBase::PARAM_TYPE => 'timestamp'
|
2007-12-06 16:06:22 +00:00
|
|
|
),
|
|
|
|
|
'end' => array(
|
2010-02-24 14:00:23 +00:00
|
|
|
ApiBase::PARAM_TYPE => 'timestamp',
|
2007-12-06 16:06:22 +00:00
|
|
|
),
|
|
|
|
|
'dir' => array(
|
2010-02-24 14:00:23 +00:00
|
|
|
ApiBase::PARAM_TYPE => array(
|
2007-12-06 16:06:22 +00:00
|
|
|
'newer',
|
|
|
|
|
'older'
|
|
|
|
|
),
|
2010-02-24 14:00:23 +00:00
|
|
|
ApiBase::PARAM_DFLT => 'older'
|
2007-12-06 16:06:22 +00:00
|
|
|
),
|
2009-01-12 16:39:04 +00:00
|
|
|
'from' => null,
|
2011-03-13 17:59:27 +00:00
|
|
|
'to' => null,
|
2011-04-23 16:03:40 +00:00
|
|
|
'prefix' => null,
|
2009-01-12 16:39:04 +00:00
|
|
|
'continue' => null,
|
|
|
|
|
'unique' => false,
|
|
|
|
|
'user' => array(
|
2010-02-24 14:00:23 +00:00
|
|
|
ApiBase::PARAM_TYPE => 'user'
|
2009-01-12 16:39:04 +00:00
|
|
|
),
|
|
|
|
|
'excludeuser' => array(
|
2010-02-24 14:00:23 +00:00
|
|
|
ApiBase::PARAM_TYPE => 'user'
|
2009-01-12 16:39:04 +00:00
|
|
|
),
|
|
|
|
|
'namespace' => array(
|
2010-02-24 14:00:23 +00:00
|
|
|
ApiBase::PARAM_TYPE => 'namespace',
|
|
|
|
|
ApiBase::PARAM_DFLT => 0,
|
2009-01-12 16:39:04 +00:00
|
|
|
),
|
2007-12-06 16:06:22 +00:00
|
|
|
'limit' => array(
|
2010-02-24 14:00:23 +00:00
|
|
|
ApiBase::PARAM_DFLT => 10,
|
|
|
|
|
ApiBase::PARAM_TYPE => 'limit',
|
|
|
|
|
ApiBase::PARAM_MIN => 1,
|
|
|
|
|
ApiBase::PARAM_MAX => ApiBase::LIMIT_BIG1,
|
|
|
|
|
ApiBase::PARAM_MAX2 => ApiBase::LIMIT_BIG2
|
2007-12-06 16:06:22 +00:00
|
|
|
),
|
|
|
|
|
'prop' => array(
|
2010-02-24 14:00:23 +00:00
|
|
|
ApiBase::PARAM_DFLT => 'user|comment',
|
|
|
|
|
ApiBase::PARAM_TYPE => array(
|
2007-12-06 16:06:22 +00:00
|
|
|
'revid',
|
2011-04-10 21:11:39 +00:00
|
|
|
'parentid',
|
2007-12-06 16:06:22 +00:00
|
|
|
'user',
|
2010-08-28 00:52:38 +00:00
|
|
|
'userid',
|
2007-12-06 16:06:22 +00:00
|
|
|
'comment',
|
2010-01-31 23:06:35 +00:00
|
|
|
'parsedcomment',
|
2007-12-06 16:06:22 +00:00
|
|
|
'minor',
|
|
|
|
|
'len',
|
2011-12-17 18:27:38 +00:00
|
|
|
'sha1',
|
2007-12-06 16:06:22 +00:00
|
|
|
'content',
|
|
|
|
|
'token'
|
|
|
|
|
),
|
2010-02-24 14:00:23 +00:00
|
|
|
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() {
|
2010-02-24 14:00:23 +00:00
|
|
|
return array(
|
2012-04-10 13:08:11 +00:00
|
|
|
'start' => 'The timestamp to start enumerating from (1, 2)',
|
|
|
|
|
'end' => 'The timestamp to stop enumerating at (1, 2)',
|
2011-04-23 16:57:03 +00:00
|
|
|
'dir' => $this->getDirectionDescription( $this->getModulePrefix(), ' (1, 3)' ),
|
2011-03-13 17:59:27 +00:00
|
|
|
'from' => 'Start listing at this title (3)',
|
|
|
|
|
'to' => 'Stop listing at this title (3)',
|
2011-04-23 16:03:40 +00:00
|
|
|
'prefix' => 'Search for all page titles that begin with this value (3)',
|
2007-12-06 16:06:22 +00:00
|
|
|
'limit' => 'The maximum amount of revisions to list',
|
2010-06-23 19:36:26 +00:00
|
|
|
'prop' => array(
|
|
|
|
|
'Which properties to get',
|
2010-12-14 11:47:13 +00:00
|
|
|
' revid - Adds the revision ID of the deleted revision',
|
2011-04-10 21:11:39 +00:00
|
|
|
' parentid - Adds the revision ID of the previous revision to the page',
|
2010-08-28 00:52:38 +00:00
|
|
|
' user - Adds the user who made the revision',
|
2010-12-14 11:47:13 +00:00
|
|
|
' userid - Adds the user ID whom made the revision',
|
2010-06-23 19:36:26 +00:00
|
|
|
' comment - Adds the comment of the revision',
|
|
|
|
|
' parsedcomment - Adds the parsed comment of the revision',
|
|
|
|
|
' minor - Tags if the revision is minor',
|
2011-12-17 18:27:38 +00:00
|
|
|
' len - Adds the length (bytes) of the revision',
|
2011-12-18 16:35:45 +00:00
|
|
|
' sha1 - Adds the SHA-1 (base 16) of the revision',
|
2010-06-23 19:36:26 +00:00
|
|
|
' content - Adds the content of the revision',
|
|
|
|
|
' token - Gives the edit token',
|
|
|
|
|
),
|
2009-01-12 16:39:04 +00:00
|
|
|
'namespace' => 'Only list pages in this namespace (3)',
|
|
|
|
|
'user' => 'Only list revisions by this user',
|
|
|
|
|
'excludeuser' => 'Don\'t list revisions by this user',
|
|
|
|
|
'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
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
Added result properties to action=paraminfo
Added information about the properties of the results of API calls
to action=paraminfo, including information about "property groups":
what should the prop parameter be set to to get that property.
Uses the same format for types as parameters already do.
The output format of some modules doesn't fit this, so the result
properties for them weren't added, or only partially.
Partially implemented modules:
* expandtemplates:
parsetree is in its own tag
* protect, allusers, backlinks, deletedrevs, info, imageinfo,
logevents, querypage, recentchanges, revisions, searchinfo,
usercontribs, userinfo, users, watchlist, upload:
response with partially complex structure
Not implemented modules:
* feedcontributions, feedwatchlist, opensearch, rds:
non-standard reponse
* help:
error is normal response; not very useful for automated tools anyway
* paraminfo, parse, pageprops, siteinfo, userrights:
response with complex structure
Change-Id: Iff2a9bef79f994e73eef3062b4dd5461bff968ab
2012-05-02 15:00:30 +00:00
|
|
|
public function getResultProperties() {
|
|
|
|
|
return array(
|
|
|
|
|
'' => array(
|
|
|
|
|
'ns' => 'namespace',
|
|
|
|
|
'title' => 'string'
|
|
|
|
|
),
|
|
|
|
|
'token' => array(
|
|
|
|
|
'token' => 'string'
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2008-01-28 19:05:26 +00:00
|
|
|
public function getDescription() {
|
2011-04-23 16:03:40 +00:00
|
|
|
$p = $this->getModulePrefix();
|
2010-02-24 14:00:23 +00:00
|
|
|
return array(
|
|
|
|
|
'List deleted revisions.',
|
2011-04-25 14:05:57 +00:00
|
|
|
'Operates in three modes:',
|
2011-04-23 16:57:03 +00:00
|
|
|
' 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, {$p}user not set)",
|
2010-02-24 14:00:23 +00:00
|
|
|
'Certain parameters only apply to some modes and are ignored in others.',
|
2010-05-11 22:30:18 +00:00
|
|
|
'For instance, a parameter marked (1) only applies to mode 1 and is ignored in modes 2 and 3',
|
2009-01-12 16:39:04 +00:00
|
|
|
);
|
2007-12-06 16:06:22 +00:00
|
|
|
}
|
2010-02-24 14:00:23 +00:00
|
|
|
|
2010-02-13 01:21:52 +00:00
|
|
|
public function getPossibleErrors() {
|
|
|
|
|
return array_merge( parent::getPossibleErrors(), array(
|
|
|
|
|
array( 'code' => 'permissiondenied', 'info' => 'You don\'t have permission to view deleted revision information' ),
|
|
|
|
|
array( 'code' => 'badparams', 'info' => 'user and excludeuser cannot be used together' ),
|
|
|
|
|
array( 'code' => 'permissiondenied', 'info' => 'You don\'t have permission to view deleted revision content' ),
|
|
|
|
|
array( 'code' => 'badcontinue', 'info' => 'Invalid continue param. You should pass the original value returned by the previous query' ),
|
2011-04-23 16:57:03 +00:00
|
|
|
array( 'code' => 'badparams', 'info' => "The 'from' parameter cannot be used in modes 1 or 2" ),
|
|
|
|
|
array( 'code' => 'badparams', 'info' => "The 'to' parameter cannot be used in modes 1 or 2" ),
|
|
|
|
|
array( 'code' => 'badparams', 'info' => "The 'prefix' parameter cannot be used in modes 1 or 2" ),
|
|
|
|
|
array( 'code' => 'badparams', 'info' => "The 'continue' parameter cannot be used in modes 1 or 2" ),
|
|
|
|
|
array( 'code' => 'badparams', 'info' => "The 'start' parameter cannot be used in mode 3" ),
|
|
|
|
|
array( 'code' => 'badparams', 'info' => "The 'end' parameter cannot be used in mode 3" ),
|
2010-02-13 01:21:52 +00:00
|
|
|
) );
|
|
|
|
|
}
|
2007-12-06 16:06:22 +00:00
|
|
|
|
2011-08-17 22:24:21 +00:00
|
|
|
public function getExamples() {
|
2010-02-24 14:00:23 +00:00
|
|
|
return array(
|
2011-12-27 16:22:35 +00:00
|
|
|
'api.php?action=query&list=deletedrevs&titles=Main%20Page|Talk:Main%20Page&drprop=user|comment|content'
|
|
|
|
|
=> 'List the last deleted revisions of Main Page and Talk:Main Page, with content (mode 1)',
|
|
|
|
|
'api.php?action=query&list=deletedrevs&druser=Bob&drlimit=50'
|
|
|
|
|
=> 'List the last 50 deleted contributions by Bob (mode 2)',
|
|
|
|
|
'api.php?action=query&list=deletedrevs&drdir=newer&drlimit=50'
|
|
|
|
|
=> 'List the first 50 deleted revisions in the main namespace (mode 3)',
|
|
|
|
|
'api.php?action=query&list=deletedrevs&drdir=newer&drlimit=50&drnamespace=1&drunique='
|
|
|
|
|
=> 'List the first 50 deleted pages in the Talk namespace (mode 3):',
|
2007-12-06 16:06:22 +00:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2011-07-17 17:02:06 +00:00
|
|
|
public function getHelpUrls() {
|
2011-11-28 15:43:11 +00:00
|
|
|
return 'https://www.mediawiki.org/wiki/API:Deletedrevs';
|
2011-07-17 17:02:06 +00:00
|
|
|
}
|
|
|
|
|
|
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
|
|
|
}
|
2010-07-23 07:17:56 +00:00
|
|
|
}
|