2006-09-26 05:43:02 +00:00
|
|
|
<?php
|
2010-02-24 14:45:19 +00:00
|
|
|
/**
|
2010-12-22 20:52:06 +00:00
|
|
|
*
|
2006-09-26 05:43:02 +00:00
|
|
|
*
|
2010-08-07 19:59:42 +00:00
|
|
|
* Created on Sep 7, 2006
|
|
|
|
|
*
|
2012-07-15 20:13:02 +00:00
|
|
|
* Copyright © 2006 Yuri Astrakhan "<Firstname><Lastname>@gmail.com"
|
2006-09-26 05:43:02 +00:00
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
2010-06-21 13:13:32 +00:00
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2006-09-26 05:43:02 +00:00
|
|
|
* http://www.gnu.org/copyleft/gpl.html
|
2010-08-07 19:59:42 +00:00
|
|
|
*
|
|
|
|
|
* @file
|
2006-09-26 05:43:02 +00:00
|
|
|
*/
|
|
|
|
|
|
2007-04-20 08:55:14 +00:00
|
|
|
/**
|
2013-11-14 13:58:14 +00:00
|
|
|
* A query action to enumerate revisions of a given page, or show top revisions
|
|
|
|
|
* of multiple pages. Various pieces of information may be shown - flags,
|
|
|
|
|
* comments, and the actual wiki markup of the rev. In the enumeration mode,
|
|
|
|
|
* ranges of revisions may be requested and filtered.
|
2008-04-14 07:45:50 +00:00
|
|
|
*
|
WARNING: HUGE COMMIT
Doxygen documentation update:
* Changed alls @addtogroup to @ingroup. @addtogroup adds the comment to the group description, but doesn't add the file, class, function, ... to the group like @ingroup does. See for example http://svn.wikimedia.org/doc/group__SpecialPage.html where it's impossible to see related files, classes, ... that should belong to that group.
* Added @file to file description, it seems that it should be explicitely decalred for file descriptions, otherwise doxygen will think that the comment document the first class, variabled, function, ... that is in that file.
* Removed some empty comments
* Removed some ?>
Added following groups:
* ExternalStorage
* JobQueue
* MaintenanceLanguage
One more thing: there are still a lot of warnings when generating the doc.
2008-05-20 17:13:28 +00:00
|
|
|
* @ingroup API
|
2007-04-20 08:55:14 +00:00
|
|
|
*/
|
2006-09-26 05:43:02 +00:00
|
|
|
class ApiQueryRevisions extends ApiQueryBase {
|
|
|
|
|
|
2010-10-20 20:16:46 +00:00
|
|
|
private $diffto, $difftotext, $expandTemplates, $generateXML, $section,
|
2012-06-13 09:58:05 +00:00
|
|
|
$token, $parseContent, $contentFormat;
|
2010-10-20 20:16:46 +00:00
|
|
|
|
2014-03-25 17:22:11 +00:00
|
|
|
public function __construct( ApiQuery $query, $moduleName ) {
|
2010-02-24 14:45:19 +00:00
|
|
|
parent::__construct( $query, $moduleName, 'rv' );
|
2006-09-26 05:43:02 +00:00
|
|
|
}
|
|
|
|
|
|
2013-11-14 13:58:14 +00:00
|
|
|
private $fld_ids = false, $fld_flags = false, $fld_timestamp = false,
|
|
|
|
|
$fld_size = false, $fld_sha1 = false, $fld_comment = false,
|
|
|
|
|
$fld_parsedcomment = false, $fld_user = false, $fld_userid = false,
|
2013-11-14 13:00:02 +00:00
|
|
|
$fld_content = false, $fld_tags = false, $fld_contentmodel = false;
|
2007-05-20 08:34:47 +00:00
|
|
|
|
2010-10-20 18:50:33 +00:00
|
|
|
private $tokenFunctions;
|
|
|
|
|
|
2008-07-04 12:07:02 +00:00
|
|
|
protected function getTokenFunctions() {
|
|
|
|
|
// tokenname => function
|
|
|
|
|
// function prototype is func($pageid, $title, $rev)
|
|
|
|
|
// should return token or false
|
|
|
|
|
|
|
|
|
|
// Don't call the hooks twice
|
2010-02-24 14:45:19 +00:00
|
|
|
if ( isset( $this->tokenFunctions ) ) {
|
2008-07-04 12:07:02 +00:00
|
|
|
return $this->tokenFunctions;
|
2010-02-24 14:45:19 +00:00
|
|
|
}
|
2008-07-05 11:18:50 +00:00
|
|
|
|
|
|
|
|
// If we're in JSON callback mode, no tokens can be obtained
|
2010-02-24 14:45:19 +00:00
|
|
|
if ( !is_null( $this->getMain()->getRequest()->getVal( 'callback' ) ) ) {
|
2008-07-05 11:18:50 +00:00
|
|
|
return array();
|
2010-02-24 14:45:19 +00:00
|
|
|
}
|
2008-07-05 11:18:50 +00:00
|
|
|
|
2008-07-04 12:07:02 +00:00
|
|
|
$this->tokenFunctions = array(
|
2008-09-04 15:17:51 +00:00
|
|
|
'rollback' => array( 'ApiQueryRevisions', 'getRollbackToken' )
|
2008-07-04 12:07:02 +00:00
|
|
|
);
|
2010-01-11 15:55:52 +00:00
|
|
|
wfRunHooks( 'APIQueryRevisionsTokens', array( &$this->tokenFunctions ) );
|
2013-11-14 13:00:02 +00:00
|
|
|
|
2008-07-04 12:07:02 +00:00
|
|
|
return $this->tokenFunctions;
|
|
|
|
|
}
|
|
|
|
|
|
2011-02-19 00:30:18 +00:00
|
|
|
/**
|
2014-04-15 18:12:09 +00:00
|
|
|
* @param int $pageid
|
|
|
|
|
* @param Title $title
|
|
|
|
|
* @param Revision $rev
|
|
|
|
|
* @return bool|string
|
2011-02-19 00:30:18 +00:00
|
|
|
*/
|
2010-02-24 14:45:19 +00:00
|
|
|
public static function getRollbackToken( $pageid, $title, $rev ) {
|
2008-07-04 12:07:02 +00:00
|
|
|
global $wgUser;
|
2010-02-24 14:45:19 +00:00
|
|
|
if ( !$wgUser->isAllowed( 'rollback' ) ) {
|
2008-07-04 12:07:02 +00:00
|
|
|
return false;
|
2010-02-24 14:45:19 +00:00
|
|
|
}
|
2013-11-14 13:00:02 +00:00
|
|
|
|
2011-10-27 00:46:17 +00:00
|
|
|
return $wgUser->getEditToken(
|
|
|
|
|
array( $title->getPrefixedText(), $rev->getUserText() ) );
|
2008-07-04 12:07:02 +00:00
|
|
|
}
|
|
|
|
|
|
2006-09-27 05:13:48 +00:00
|
|
|
public function execute() {
|
2010-01-11 15:55:52 +00:00
|
|
|
$params = $this->extractRequestParams( false );
|
2006-09-26 05:43:02 +00:00
|
|
|
|
2006-10-01 02:02:13 +00:00
|
|
|
// If any of those parameters are used, work in 'enumeration' mode.
|
2006-09-30 08:06:27 +00:00
|
|
|
// Enum mode can only be used when exactly one page is provided.
|
2008-04-14 07:45:50 +00:00
|
|
|
// Enumerating revisions on multiple pages make it extremely
|
|
|
|
|
// difficult to manage continuations and require additional SQL indexes
|
2010-01-11 15:55:52 +00:00
|
|
|
$enumRevMode = ( !is_null( $params['user'] ) || !is_null( $params['excludeuser'] ) ||
|
2013-11-14 13:00:02 +00:00
|
|
|
!is_null( $params['limit'] ) || !is_null( $params['startid'] ) ||
|
|
|
|
|
!is_null( $params['endid'] ) || $params['dir'] === 'newer' ||
|
|
|
|
|
!is_null( $params['start'] ) || !is_null( $params['end'] ) );
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2006-10-01 20:17:16 +00:00
|
|
|
$pageSet = $this->getPageSet();
|
|
|
|
|
$pageCount = $pageSet->getGoodTitleCount();
|
|
|
|
|
$revCount = $pageSet->getRevisionCount();
|
2006-09-29 07:29:13 +00:00
|
|
|
|
2006-10-01 02:02:13 +00:00
|
|
|
// Optimization -- nothing to do
|
2010-02-24 14:45:19 +00:00
|
|
|
if ( $revCount === 0 && $pageCount === 0 ) {
|
2006-10-01 02:02:13 +00:00
|
|
|
return;
|
2010-02-24 14:45:19 +00:00
|
|
|
}
|
2006-10-01 02:02:13 +00:00
|
|
|
|
2010-02-24 14:45:19 +00:00
|
|
|
if ( $revCount > 0 && $enumRevMode ) {
|
2013-11-14 13:58:14 +00:00
|
|
|
$this->dieUsage(
|
|
|
|
|
'The revids= parameter may not be used with the list options ' .
|
|
|
|
|
'(limit, startid, endid, dirNewer, start, end).',
|
|
|
|
|
'revids'
|
|
|
|
|
);
|
2010-02-24 14:45:19 +00:00
|
|
|
}
|
2006-09-30 08:06:27 +00:00
|
|
|
|
2010-02-24 14:45:19 +00:00
|
|
|
if ( $pageCount > 1 && $enumRevMode ) {
|
2013-11-14 13:58:14 +00:00
|
|
|
$this->dieUsage(
|
|
|
|
|
'titles, pageids or a generator was used to supply multiple pages, ' .
|
|
|
|
|
'but the limit, startid, endid, dirNewer, user, excludeuser, start ' .
|
|
|
|
|
'and end parameters may only be used on a single page.',
|
|
|
|
|
'multpages'
|
|
|
|
|
);
|
2010-02-24 14:45:19 +00:00
|
|
|
}
|
2006-09-27 05:13:48 +00:00
|
|
|
|
2010-01-11 15:55:52 +00:00
|
|
|
if ( !is_null( $params['difftotext'] ) ) {
|
2012-06-13 09:58:05 +00:00
|
|
|
$this->difftotext = $params['difftotext'];
|
2010-02-24 14:45:19 +00:00
|
|
|
} elseif ( !is_null( $params['diffto'] ) ) {
|
|
|
|
|
if ( $params['diffto'] == 'cur' ) {
|
2009-02-28 13:25:21 +00:00
|
|
|
$params['diffto'] = 0;
|
2010-02-24 14:45:19 +00:00
|
|
|
}
|
2010-01-11 15:55:52 +00:00
|
|
|
if ( ( !ctype_digit( $params['diffto'] ) || $params['diffto'] < 0 )
|
2013-11-14 13:00:02 +00:00
|
|
|
&& $params['diffto'] != 'prev' && $params['diffto'] != 'next'
|
|
|
|
|
) {
|
2013-11-14 13:58:14 +00:00
|
|
|
$this->dieUsage(
|
|
|
|
|
'rvdiffto must be set to a non-negative number, "prev", "next" or "cur"',
|
|
|
|
|
'diffto'
|
|
|
|
|
);
|
2010-02-24 14:45:19 +00:00
|
|
|
}
|
2009-02-28 13:25:21 +00:00
|
|
|
// Check whether the revision exists and is readable,
|
|
|
|
|
// DifferenceEngine returns a rather ambiguous empty
|
|
|
|
|
// string if that's not the case
|
2010-01-11 15:55:52 +00:00
|
|
|
if ( $params['diffto'] != 0 ) {
|
|
|
|
|
$difftoRev = Revision::newFromID( $params['diffto'] );
|
2010-02-24 14:45:19 +00:00
|
|
|
if ( !$difftoRev ) {
|
2010-01-11 15:55:52 +00:00
|
|
|
$this->dieUsageMsg( array( 'nosuchrevid', $params['diffto'] ) );
|
2010-02-24 14:45:19 +00:00
|
|
|
}
|
2014-01-30 19:36:53 +00:00
|
|
|
if ( !$difftoRev->userCan( Revision::DELETED_TEXT, $this->getUser() ) ) {
|
2010-01-11 15:55:52 +00:00
|
|
|
$this->setWarning( "Couldn't diff to r{$difftoRev->getID()}: content is hidden" );
|
2009-02-28 13:25:21 +00:00
|
|
|
$params['diffto'] = null;
|
|
|
|
|
}
|
|
|
|
|
}
|
2009-12-09 18:34:32 +00:00
|
|
|
$this->diffto = $params['diffto'];
|
2009-02-28 13:25:21 +00:00
|
|
|
}
|
|
|
|
|
|
2009-06-13 06:31:38 +00:00
|
|
|
$db = $this->getDB();
|
2010-09-01 16:47:21 +00:00
|
|
|
$this->addTables( 'page' );
|
2010-01-11 15:55:52 +00:00
|
|
|
$this->addFields( Revision::selectFields() );
|
|
|
|
|
$this->addWhere( 'page_id = rev_page' );
|
2006-10-21 08:26:32 +00:00
|
|
|
|
2010-01-11 15:55:52 +00:00
|
|
|
$prop = array_flip( $params['prop'] );
|
2007-05-21 06:32:32 +00:00
|
|
|
|
|
|
|
|
// Optional fields
|
2013-04-26 12:18:06 +00:00
|
|
|
$this->fld_ids = isset( $prop['ids'] );
|
2007-05-21 06:32:32 +00:00
|
|
|
// $this->addFieldsIf('rev_text_id', $this->fld_ids); // should this be exposed?
|
2013-04-26 12:18:06 +00:00
|
|
|
$this->fld_flags = isset( $prop['flags'] );
|
|
|
|
|
$this->fld_timestamp = isset( $prop['timestamp'] );
|
|
|
|
|
$this->fld_comment = isset( $prop['comment'] );
|
|
|
|
|
$this->fld_parsedcomment = isset( $prop['parsedcomment'] );
|
|
|
|
|
$this->fld_size = isset( $prop['size'] );
|
|
|
|
|
$this->fld_sha1 = isset( $prop['sha1'] );
|
|
|
|
|
$this->fld_contentmodel = isset( $prop['contentmodel'] );
|
2010-08-28 00:37:48 +00:00
|
|
|
$this->fld_userid = isset( $prop['userid'] );
|
2013-04-26 12:18:06 +00:00
|
|
|
$this->fld_user = isset( $prop['user'] );
|
2008-12-17 16:34:01 +00:00
|
|
|
$this->token = $params['token'];
|
2007-05-21 06:32:32 +00:00
|
|
|
|
2012-06-13 09:58:05 +00:00
|
|
|
if ( !empty( $params['contentformat'] ) ) {
|
2012-06-25 21:30:51 +00:00
|
|
|
$this->contentFormat = $params['contentformat'];
|
2012-06-13 09:58:05 +00:00
|
|
|
}
|
|
|
|
|
|
2010-10-23 16:41:20 +00:00
|
|
|
$userMax = ( $this->fld_content ? ApiBase::LIMIT_SML1 : ApiBase::LIMIT_BIG1 );
|
2013-03-07 16:50:43 +00:00
|
|
|
$botMax = ( $this->fld_content ? ApiBase::LIMIT_SML2 : ApiBase::LIMIT_BIG2 );
|
2010-10-23 16:41:20 +00:00
|
|
|
$limit = $params['limit'];
|
|
|
|
|
if ( $limit == 'max' ) {
|
|
|
|
|
$limit = $this->getMain()->canApiHighLimits() ? $botMax : $userMax;
|
|
|
|
|
$this->getResult()->setParsedLimit( $this->getModuleName(), $limit );
|
|
|
|
|
}
|
|
|
|
|
|
2010-01-11 15:55:52 +00:00
|
|
|
if ( !is_null( $this->token ) || $pageCount > 0 ) {
|
2008-05-13 10:42:32 +00:00
|
|
|
$this->addFields( Revision::selectPageFields() );
|
2007-05-21 06:32:32 +00:00
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2010-02-24 14:45:19 +00:00
|
|
|
if ( isset( $prop['tags'] ) ) {
|
2009-11-01 10:42:41 +00:00
|
|
|
$this->fld_tags = true;
|
2010-01-11 15:55:52 +00:00
|
|
|
$this->addTables( 'tag_summary' );
|
2013-11-14 13:58:14 +00:00
|
|
|
$this->addJoinConds(
|
|
|
|
|
array( 'tag_summary' => array( 'LEFT JOIN', array( 'rev_id=ts_rev_id' ) ) )
|
|
|
|
|
);
|
2010-01-11 15:55:52 +00:00
|
|
|
$this->addFields( 'ts_tags' );
|
2009-11-01 10:42:41 +00:00
|
|
|
}
|
2010-02-24 14:45:19 +00:00
|
|
|
|
2010-01-11 15:55:52 +00:00
|
|
|
if ( !is_null( $params['tag'] ) ) {
|
|
|
|
|
$this->addTables( 'change_tag' );
|
2013-11-14 13:58:14 +00:00
|
|
|
$this->addJoinConds(
|
|
|
|
|
array( 'change_tag' => array( 'INNER JOIN', array( 'rev_id=ct_rev_id' ) ) )
|
|
|
|
|
);
|
2013-02-03 18:47:42 +00:00
|
|
|
$this->addWhereFld( 'ct_tag', $params['tag'] );
|
2009-11-01 10:42:41 +00:00
|
|
|
}
|
2007-07-14 19:04:31 +00:00
|
|
|
|
2010-02-24 14:45:19 +00:00
|
|
|
if ( isset( $prop['content'] ) || !is_null( $this->difftotext ) ) {
|
2007-07-14 19:04:31 +00:00
|
|
|
// For each page we will request, the user must have read rights for that page
|
2012-09-22 11:33:33 +00:00
|
|
|
$user = $this->getUser();
|
2013-03-11 03:45:51 +00:00
|
|
|
/** @var $title Title */
|
2010-01-11 15:55:52 +00:00
|
|
|
foreach ( $pageSet->getGoodTitles() as $title ) {
|
2012-09-22 11:33:33 +00:00
|
|
|
if ( !$title->userCan( 'read', $user ) ) {
|
2007-07-14 19:04:31 +00:00
|
|
|
$this->dieUsage(
|
|
|
|
|
'The current user is not allowed to read ' . $title->getPrefixedText(),
|
2010-01-11 15:55:52 +00:00
|
|
|
'accessdenied' );
|
2010-02-24 14:45:19 +00:00
|
|
|
}
|
2007-07-14 19:04:31 +00:00
|
|
|
}
|
|
|
|
|
|
2010-01-11 15:55:52 +00:00
|
|
|
$this->addTables( 'text' );
|
|
|
|
|
$this->addWhere( 'rev_text_id=old_id' );
|
|
|
|
|
$this->addFields( 'old_id' );
|
|
|
|
|
$this->addFields( Revision::selectTextFields() );
|
2007-09-25 18:36:25 +00:00
|
|
|
|
2010-01-11 15:55:52 +00:00
|
|
|
$this->fld_content = isset( $prop['content'] );
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-12-17 16:34:01 +00:00
|
|
|
$this->expandTemplates = $params['expandtemplates'];
|
|
|
|
|
$this->generateXML = $params['generatexml'];
|
2010-10-23 16:41:20 +00:00
|
|
|
$this->parseContent = $params['parse'];
|
|
|
|
|
if ( $this->parseContent ) {
|
2010-10-27 11:50:20 +00:00
|
|
|
// Must manually initialize unset limit
|
|
|
|
|
if ( is_null( $limit ) ) {
|
|
|
|
|
$limit = 1;
|
|
|
|
|
}
|
2010-10-23 16:41:20 +00:00
|
|
|
// We are only going to parse 1 revision per request
|
|
|
|
|
$this->validateLimit( 'limit', $limit, 1, 1, 1 );
|
|
|
|
|
}
|
2010-02-24 14:45:19 +00:00
|
|
|
if ( isset( $params['section'] ) ) {
|
2008-12-17 16:34:01 +00:00
|
|
|
$this->section = $params['section'];
|
2010-02-24 14:45:19 +00:00
|
|
|
} else {
|
2008-03-14 13:07:38 +00:00
|
|
|
$this->section = false;
|
2010-02-24 14:45:19 +00:00
|
|
|
}
|
2006-09-27 05:13:48 +00:00
|
|
|
}
|
|
|
|
|
|
2012-05-16 14:38:40 +00:00
|
|
|
// add user name, if needed
|
|
|
|
|
if ( $this->fld_user ) {
|
|
|
|
|
$this->addTables( 'user' );
|
|
|
|
|
$this->addJoinConds( array( 'user' => Revision::userJoinCond() ) );
|
|
|
|
|
$this->addFields( Revision::selectUserFields() );
|
|
|
|
|
}
|
|
|
|
|
|
2010-12-30 17:06:09 +00:00
|
|
|
// Bug 24166 - API error when using rvprop=tags
|
2010-09-01 16:47:21 +00:00
|
|
|
$this->addTables( 'revision' );
|
|
|
|
|
|
2010-01-11 15:55:52 +00:00
|
|
|
if ( $enumRevMode ) {
|
2007-11-27 16:41:13 +00:00
|
|
|
// This is mostly to prevent parameter errors (and optimize SQL?)
|
2010-05-10 17:12:09 +00:00
|
|
|
if ( !is_null( $params['startid'] ) && !is_null( $params['start'] ) ) {
|
2010-01-11 15:55:52 +00:00
|
|
|
$this->dieUsage( 'start and startid cannot be used together', 'badparams' );
|
2010-02-24 14:45:19 +00:00
|
|
|
}
|
2006-09-30 08:06:27 +00:00
|
|
|
|
2010-02-24 14:45:19 +00:00
|
|
|
if ( !is_null( $params['endid'] ) && !is_null( $params['end'] ) ) {
|
2010-01-11 15:55:52 +00:00
|
|
|
$this->dieUsage( 'end and endid cannot be used together', 'badparams' );
|
2010-02-24 14:45:19 +00:00
|
|
|
}
|
2006-09-30 08:06:27 +00:00
|
|
|
|
2010-05-10 17:12:09 +00:00
|
|
|
if ( !is_null( $params['user'] ) && !is_null( $params['excludeuser'] ) ) {
|
2010-01-11 15:55:52 +00:00
|
|
|
$this->dieUsage( 'user and excludeuser cannot be used together', 'badparams' );
|
2010-02-24 14:45:19 +00:00
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2012-08-20 14:55:28 +00:00
|
|
|
// Continuing effectively uses startid. But we can't use rvstartid
|
|
|
|
|
// directly, because there is no way to tell the client to ''not''
|
|
|
|
|
// send rvstart if it sent it in the original query. So instead we
|
|
|
|
|
// send the continuation startid as rvcontinue, and ignore both
|
|
|
|
|
// rvstart and rvstartid when that is supplied.
|
|
|
|
|
if ( !is_null( $params['continue'] ) ) {
|
|
|
|
|
$params['startid'] = $params['continue'];
|
2012-11-08 18:37:06 +00:00
|
|
|
$params['start'] = null;
|
2012-08-20 14:55:28 +00:00
|
|
|
}
|
|
|
|
|
|
2006-10-02 18:27:06 +00:00
|
|
|
// This code makes an assumption that sorting by rev_id and rev_timestamp produces
|
|
|
|
|
// the same result. This way users may request revisions starting at a given time,
|
|
|
|
|
// but to page through results use the rev_id returned after each page.
|
2008-04-14 07:45:50 +00:00
|
|
|
// Switching to rev_id removes the potential problem of having more than
|
|
|
|
|
// one row with the same timestamp for the same page.
|
2006-10-02 18:27:06 +00:00
|
|
|
// The order needs to be the same as start parameter to avoid SQL filesort.
|
2010-02-24 14:45:19 +00:00
|
|
|
if ( is_null( $params['startid'] ) && is_null( $params['endid'] ) ) {
|
2011-10-06 20:46:24 +00:00
|
|
|
$this->addTimestampWhereRange( 'rev_timestamp', $params['dir'],
|
2010-01-11 15:55:52 +00:00
|
|
|
$params['start'], $params['end'] );
|
2010-02-24 14:45:19 +00:00
|
|
|
} else {
|
2010-01-11 15:55:52 +00:00
|
|
|
$this->addWhereRange( 'rev_id', $params['dir'],
|
|
|
|
|
$params['startid'], $params['endid'] );
|
2009-02-18 15:26:09 +00:00
|
|
|
// One of start and end can be set
|
|
|
|
|
// If neither is set, this does nothing
|
2011-10-06 20:46:24 +00:00
|
|
|
$this->addTimestampWhereRange( 'rev_timestamp', $params['dir'],
|
2010-01-11 15:55:52 +00:00
|
|
|
$params['start'], $params['end'], false );
|
2009-02-18 15:26:09 +00:00
|
|
|
}
|
2006-09-29 07:29:13 +00:00
|
|
|
|
2006-10-03 05:41:55 +00:00
|
|
|
// must manually initialize unset limit
|
2010-02-24 14:45:19 +00:00
|
|
|
if ( is_null( $limit ) ) {
|
2006-10-03 05:41:55 +00:00
|
|
|
$limit = 10;
|
2010-02-24 14:45:19 +00:00
|
|
|
}
|
2010-01-11 15:55:52 +00:00
|
|
|
$this->validateLimit( 'limit', $limit, 1, $userMax, $botMax );
|
2006-09-29 07:29:13 +00:00
|
|
|
|
2006-09-30 08:06:27 +00:00
|
|
|
// There is only one ID, use it
|
2010-01-11 15:55:52 +00:00
|
|
|
$ids = array_keys( $pageSet->getGoodTitles() );
|
|
|
|
|
$this->addWhereFld( 'rev_page', reset( $ids ) );
|
|
|
|
|
|
|
|
|
|
if ( !is_null( $params['user'] ) ) {
|
|
|
|
|
$this->addWhereFld( 'rev_user_text', $params['user'] );
|
|
|
|
|
} elseif ( !is_null( $params['excludeuser'] ) ) {
|
|
|
|
|
$this->addWhere( 'rev_user_text != ' .
|
|
|
|
|
$db->addQuotes( $params['excludeuser'] ) );
|
2007-05-19 04:13:48 +00:00
|
|
|
}
|
2010-01-11 15:55:52 +00:00
|
|
|
if ( !is_null( $params['user'] ) || !is_null( $params['excludeuser'] ) ) {
|
2009-02-05 11:44:10 +00:00
|
|
|
// Paranoia: avoid brute force searches (bug 17342)
|
Improve API query RevDel handling
* ApiQueryDeletedrevs, ApiQueryFilearchive, ApiQueryRecentChanges, and
ApiQueryWatchlist will now return entires where fields have been
revision-deleted. "Hidden" indicators will be provided as appropriate.
* ApiQueryImageInfo, ApiQueryLogEvents, ApiQueryRevisions,
ApiQueryContributions will now return field values in addition to the
"hidden" indicators when the requesting user has the necessary rights.
* Modules that return "hidden" indicators will now also return a
"suppressed" indicator.
* ApiQueryImageInfo will now return info for DELETED_FILE file revisions
if the requesting user has the 'deletedtext' right.
* ApiQueryLogEvents, when searching by user or title, will now return
entries where the user or action are revision-deleted if the
requesting user has the 'deletedhistory' right.
* ApiQueryContributions now uses the correct user rights rather than
'hideuser' to determine when to show contributions where the username
was revision-deleted.
* ApiQueryContributions will now indicate when the revision text is
hidden.
* Fix a bug in ApiQueryDeletedrevs found during testing where specifying
the "content" prop along with the "tags" prop or "drtag" parameter
would cause an SQL error.
* Fix various PHP warnings in ApiQueryFilearchive caused by the lack of
ArchivedFile::selectFields() fields.
* ApiQueryImageInfo::getInfo's $metadataOpts parameter has been renamed
$opts, and now may have an option to indicate the user to use for
RevDel visibility checks.
* ApiQueryWatchlist now properly uses the actual user's rights for
checking whether wlprop=patrol is allowed, rather than using the
wlowner's rights.
Bug: 27747
Bug: 27748
Bug: 28261
Bug: 34926
Bug: 48966
Change-Id: Idec2199976f460e1c73a26d0717e9fc4ab8042bb
2013-12-18 21:58:39 +00:00
|
|
|
if ( !$this->getUser()->isAllowed( 'deletedhistory' ) ) {
|
|
|
|
|
$bitmask = Revision::DELETED_USER;
|
|
|
|
|
} elseif ( !$this->getUser()->isAllowed( 'suppressrevision' ) ) {
|
|
|
|
|
$bitmask = Revision::DELETED_USER | Revision::DELETED_RESTRICTED;
|
|
|
|
|
} else {
|
|
|
|
|
$bitmask = 0;
|
|
|
|
|
}
|
|
|
|
|
if ( $bitmask ) {
|
|
|
|
|
$this->addWhere( $db->bitAnd( 'rev_deleted', $bitmask ) . " != $bitmask" );
|
|
|
|
|
}
|
2009-02-05 11:44:10 +00:00
|
|
|
}
|
2010-02-24 14:45:19 +00:00
|
|
|
} elseif ( $revCount > 0 ) {
|
2008-10-24 13:05:44 +00:00
|
|
|
$max = $this->getMain()->canApiHighLimits() ? $botMax : $userMax;
|
|
|
|
|
$revs = $pageSet->getRevisionIDs();
|
2010-02-24 14:45:19 +00:00
|
|
|
if ( self::truncateArray( $revs, $max ) ) {
|
2010-01-11 15:55:52 +00:00
|
|
|
$this->setWarning( "Too many values supplied for parameter 'revids': the limit is $max" );
|
2010-02-24 14:45:19 +00:00
|
|
|
}
|
2007-05-19 01:46:13 +00:00
|
|
|
|
|
|
|
|
// Get all revision IDs
|
2010-01-11 15:55:52 +00:00
|
|
|
$this->addWhereFld( 'rev_id', array_keys( $revs ) );
|
2007-05-19 01:46:13 +00:00
|
|
|
|
2010-02-24 14:45:19 +00:00
|
|
|
if ( !is_null( $params['continue'] ) ) {
|
2012-05-16 17:22:36 +00:00
|
|
|
$this->addWhere( 'rev_id >= ' . intval( $params['continue'] ) );
|
2010-02-24 14:45:19 +00:00
|
|
|
}
|
2010-01-11 15:55:52 +00:00
|
|
|
$this->addOption( 'ORDER BY', 'rev_id' );
|
2009-02-10 12:32:22 +00:00
|
|
|
|
2007-05-21 06:32:32 +00:00
|
|
|
// assumption testing -- we should never get more then $revCount rows.
|
|
|
|
|
$limit = $revCount;
|
2010-02-24 14:45:19 +00:00
|
|
|
} elseif ( $pageCount > 0 ) {
|
2008-10-24 13:05:44 +00:00
|
|
|
$max = $this->getMain()->canApiHighLimits() ? $botMax : $userMax;
|
|
|
|
|
$titles = $pageSet->getGoodTitles();
|
2010-02-24 14:45:19 +00:00
|
|
|
if ( self::truncateArray( $titles, $max ) ) {
|
2010-01-11 15:55:52 +00:00
|
|
|
$this->setWarning( "Too many values supplied for parameter 'titles': the limit is $max" );
|
2010-02-24 14:45:19 +00:00
|
|
|
}
|
|
|
|
|
|
2006-10-01 20:17:16 +00:00
|
|
|
// When working in multi-page non-enumeration mode,
|
|
|
|
|
// limit to the latest revision only
|
2010-01-11 15:55:52 +00:00
|
|
|
$this->addWhere( 'page_id=rev_page' );
|
|
|
|
|
$this->addWhere( 'page_latest=rev_id' );
|
2010-02-24 14:45:19 +00:00
|
|
|
|
2006-10-01 20:17:16 +00:00
|
|
|
// Get all page IDs
|
2010-01-11 15:55:52 +00:00
|
|
|
$this->addWhereFld( 'page_id', array_keys( $titles ) );
|
2009-03-20 20:21:38 +00:00
|
|
|
// Every time someone relies on equality propagation, god kills a kitten :)
|
2010-01-11 15:55:52 +00:00
|
|
|
$this->addWhereFld( 'rev_page', array_keys( $titles ) );
|
2010-02-24 14:45:19 +00:00
|
|
|
|
|
|
|
|
if ( !is_null( $params['continue'] ) ) {
|
2010-01-11 15:55:52 +00:00
|
|
|
$cont = explode( '|', $params['continue'] );
|
2013-01-15 02:19:16 +00:00
|
|
|
$this->dieContinueUsageIf( count( $cont ) != 2 );
|
2010-01-11 15:55:52 +00:00
|
|
|
$pageid = intval( $cont[0] );
|
|
|
|
|
$revid = intval( $cont[1] );
|
2010-02-24 14:45:19 +00:00
|
|
|
$this->addWhere(
|
2012-05-16 17:22:36 +00:00
|
|
|
"rev_page > $pageid OR " .
|
|
|
|
|
"(rev_page = $pageid AND " .
|
|
|
|
|
"rev_id >= $revid)"
|
2010-02-24 14:45:19 +00:00
|
|
|
);
|
2009-02-10 12:32:22 +00:00
|
|
|
}
|
2012-05-05 13:29:08 +00:00
|
|
|
$this->addOption( 'ORDER BY', array(
|
|
|
|
|
'rev_page',
|
|
|
|
|
'rev_id'
|
2013-11-14 13:00:02 +00:00
|
|
|
) );
|
2009-02-10 12:32:22 +00:00
|
|
|
|
2007-05-21 06:32:32 +00:00
|
|
|
// assumption testing -- we should never get more then $pageCount rows.
|
|
|
|
|
$limit = $pageCount;
|
2010-02-24 14:45:19 +00:00
|
|
|
} else {
|
|
|
|
|
ApiBase::dieDebug( __METHOD__, 'param validation?' );
|
|
|
|
|
}
|
2006-09-30 08:06:27 +00:00
|
|
|
|
2010-01-11 15:55:52 +00:00
|
|
|
$this->addOption( 'LIMIT', $limit + 1 );
|
2006-09-27 05:13:48 +00:00
|
|
|
|
|
|
|
|
$count = 0;
|
2010-01-11 15:55:52 +00:00
|
|
|
$res = $this->select( __METHOD__ );
|
2006-10-25 03:54:56 +00:00
|
|
|
|
2010-06-20 18:48:34 +00:00
|
|
|
foreach ( $res as $row ) {
|
2013-11-14 13:00:02 +00:00
|
|
|
if ( ++$count > $limit ) {
|
2013-11-14 13:58:14 +00:00
|
|
|
// We've reached the one extra which shows that there are
|
|
|
|
|
// additional pages to be had. Stop here...
|
2010-02-24 14:45:19 +00:00
|
|
|
if ( !$enumRevMode ) {
|
|
|
|
|
ApiBase::dieDebug( __METHOD__, 'Got more rows then expected' ); // bug report
|
|
|
|
|
}
|
2012-08-20 14:55:28 +00:00
|
|
|
$this->setContinueEnumParameter( 'continue', intval( $row->rev_id ) );
|
2006-09-27 05:13:48 +00:00
|
|
|
break;
|
|
|
|
|
}
|
2010-02-24 14:45:19 +00:00
|
|
|
|
2010-01-11 15:55:52 +00:00
|
|
|
$fit = $this->addPageSubItem( $row->rev_page, $this->extractRowInfo( $row ), 'rev' );
|
2010-02-24 14:45:19 +00:00
|
|
|
if ( !$fit ) {
|
|
|
|
|
if ( $enumRevMode ) {
|
2012-08-20 14:55:28 +00:00
|
|
|
$this->setContinueEnumParameter( 'continue', intval( $row->rev_id ) );
|
2010-02-24 14:45:19 +00:00
|
|
|
} elseif ( $revCount > 0 ) {
|
2010-01-11 15:55:52 +00:00
|
|
|
$this->setContinueEnumParameter( 'continue', intval( $row->rev_id ) );
|
2010-02-24 14:45:19 +00:00
|
|
|
} else {
|
2010-01-11 15:55:52 +00:00
|
|
|
$this->setContinueEnumParameter( 'continue', intval( $row->rev_page ) .
|
|
|
|
|
'|' . intval( $row->rev_id ) );
|
2010-02-24 14:45:19 +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;
|
2006-10-01 02:02:13 +00:00
|
|
|
}
|
|
|
|
|
}
|
2006-09-26 05:43:02 +00:00
|
|
|
}
|
|
|
|
|
|
2009-11-01 10:42:41 +00:00
|
|
|
private function extractRowInfo( $row ) {
|
|
|
|
|
$revision = new Revision( $row );
|
2009-02-28 13:25:21 +00:00
|
|
|
$title = $revision->getTitle();
|
Improve API query RevDel handling
* ApiQueryDeletedrevs, ApiQueryFilearchive, ApiQueryRecentChanges, and
ApiQueryWatchlist will now return entires where fields have been
revision-deleted. "Hidden" indicators will be provided as appropriate.
* ApiQueryImageInfo, ApiQueryLogEvents, ApiQueryRevisions,
ApiQueryContributions will now return field values in addition to the
"hidden" indicators when the requesting user has the necessary rights.
* Modules that return "hidden" indicators will now also return a
"suppressed" indicator.
* ApiQueryImageInfo will now return info for DELETED_FILE file revisions
if the requesting user has the 'deletedtext' right.
* ApiQueryLogEvents, when searching by user or title, will now return
entries where the user or action are revision-deleted if the
requesting user has the 'deletedhistory' right.
* ApiQueryContributions now uses the correct user rights rather than
'hideuser' to determine when to show contributions where the username
was revision-deleted.
* ApiQueryContributions will now indicate when the revision text is
hidden.
* Fix a bug in ApiQueryDeletedrevs found during testing where specifying
the "content" prop along with the "tags" prop or "drtag" parameter
would cause an SQL error.
* Fix various PHP warnings in ApiQueryFilearchive caused by the lack of
ArchivedFile::selectFields() fields.
* ApiQueryImageInfo::getInfo's $metadataOpts parameter has been renamed
$opts, and now may have an option to indicate the user to use for
RevDel visibility checks.
* ApiQueryWatchlist now properly uses the actual user's rights for
checking whether wlprop=patrol is allowed, rather than using the
wlowner's rights.
Bug: 27747
Bug: 27748
Bug: 28261
Bug: 34926
Bug: 48966
Change-Id: Idec2199976f460e1c73a26d0717e9fc4ab8042bb
2013-12-18 21:58:39 +00:00
|
|
|
$user = $this->getUser();
|
2010-02-24 14:45:19 +00:00
|
|
|
$vals = array();
|
Improve API query RevDel handling
* ApiQueryDeletedrevs, ApiQueryFilearchive, ApiQueryRecentChanges, and
ApiQueryWatchlist will now return entires where fields have been
revision-deleted. "Hidden" indicators will be provided as appropriate.
* ApiQueryImageInfo, ApiQueryLogEvents, ApiQueryRevisions,
ApiQueryContributions will now return field values in addition to the
"hidden" indicators when the requesting user has the necessary rights.
* Modules that return "hidden" indicators will now also return a
"suppressed" indicator.
* ApiQueryImageInfo will now return info for DELETED_FILE file revisions
if the requesting user has the 'deletedtext' right.
* ApiQueryLogEvents, when searching by user or title, will now return
entries where the user or action are revision-deleted if the
requesting user has the 'deletedhistory' right.
* ApiQueryContributions now uses the correct user rights rather than
'hideuser' to determine when to show contributions where the username
was revision-deleted.
* ApiQueryContributions will now indicate when the revision text is
hidden.
* Fix a bug in ApiQueryDeletedrevs found during testing where specifying
the "content" prop along with the "tags" prop or "drtag" parameter
would cause an SQL error.
* Fix various PHP warnings in ApiQueryFilearchive caused by the lack of
ArchivedFile::selectFields() fields.
* ApiQueryImageInfo::getInfo's $metadataOpts parameter has been renamed
$opts, and now may have an option to indicate the user to use for
RevDel visibility checks.
* ApiQueryWatchlist now properly uses the actual user's rights for
checking whether wlprop=patrol is allowed, rather than using the
wlowner's rights.
Bug: 27747
Bug: 27748
Bug: 28261
Bug: 34926
Bug: 48966
Change-Id: Idec2199976f460e1c73a26d0717e9fc4ab8042bb
2013-12-18 21:58:39 +00:00
|
|
|
$anyHidden = false;
|
2007-05-20 08:34:47 +00:00
|
|
|
|
2010-01-11 15:55:52 +00:00
|
|
|
if ( $this->fld_ids ) {
|
|
|
|
|
$vals['revid'] = intval( $revision->getId() );
|
2010-02-24 14:45:19 +00:00
|
|
|
// $vals['oldid'] = intval( $row->rev_text_id ); // todo: should this be exposed?
|
|
|
|
|
if ( !is_null( $revision->getParentId() ) ) {
|
2010-01-11 15:55:52 +00:00
|
|
|
$vals['parentid'] = intval( $revision->getParentId() );
|
2010-02-24 14:45:19 +00:00
|
|
|
}
|
2007-05-21 06:32:32 +00:00
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2010-02-24 14:45:19 +00:00
|
|
|
if ( $this->fld_flags && $revision->isMinor() ) {
|
2007-05-20 08:34:47 +00:00
|
|
|
$vals['minor'] = '';
|
2010-02-24 14:45:19 +00:00
|
|
|
}
|
2007-05-20 08:34:47 +00:00
|
|
|
|
2010-08-28 00:37:48 +00:00
|
|
|
if ( $this->fld_user || $this->fld_userid ) {
|
2010-01-11 15:55:52 +00:00
|
|
|
if ( $revision->isDeleted( Revision::DELETED_USER ) ) {
|
2009-02-05 11:44:10 +00:00
|
|
|
$vals['userhidden'] = '';
|
Improve API query RevDel handling
* ApiQueryDeletedrevs, ApiQueryFilearchive, ApiQueryRecentChanges, and
ApiQueryWatchlist will now return entires where fields have been
revision-deleted. "Hidden" indicators will be provided as appropriate.
* ApiQueryImageInfo, ApiQueryLogEvents, ApiQueryRevisions,
ApiQueryContributions will now return field values in addition to the
"hidden" indicators when the requesting user has the necessary rights.
* Modules that return "hidden" indicators will now also return a
"suppressed" indicator.
* ApiQueryImageInfo will now return info for DELETED_FILE file revisions
if the requesting user has the 'deletedtext' right.
* ApiQueryLogEvents, when searching by user or title, will now return
entries where the user or action are revision-deleted if the
requesting user has the 'deletedhistory' right.
* ApiQueryContributions now uses the correct user rights rather than
'hideuser' to determine when to show contributions where the username
was revision-deleted.
* ApiQueryContributions will now indicate when the revision text is
hidden.
* Fix a bug in ApiQueryDeletedrevs found during testing where specifying
the "content" prop along with the "tags" prop or "drtag" parameter
would cause an SQL error.
* Fix various PHP warnings in ApiQueryFilearchive caused by the lack of
ArchivedFile::selectFields() fields.
* ApiQueryImageInfo::getInfo's $metadataOpts parameter has been renamed
$opts, and now may have an option to indicate the user to use for
RevDel visibility checks.
* ApiQueryWatchlist now properly uses the actual user's rights for
checking whether wlprop=patrol is allowed, rather than using the
wlowner's rights.
Bug: 27747
Bug: 27748
Bug: 28261
Bug: 34926
Bug: 48966
Change-Id: Idec2199976f460e1c73a26d0717e9fc4ab8042bb
2013-12-18 21:58:39 +00:00
|
|
|
$anyHidden = true;
|
|
|
|
|
}
|
|
|
|
|
if ( $revision->userCan( Revision::DELETED_USER, $user ) ) {
|
2010-08-28 00:37:48 +00:00
|
|
|
if ( $this->fld_user ) {
|
Improve API query RevDel handling
* ApiQueryDeletedrevs, ApiQueryFilearchive, ApiQueryRecentChanges, and
ApiQueryWatchlist will now return entires where fields have been
revision-deleted. "Hidden" indicators will be provided as appropriate.
* ApiQueryImageInfo, ApiQueryLogEvents, ApiQueryRevisions,
ApiQueryContributions will now return field values in addition to the
"hidden" indicators when the requesting user has the necessary rights.
* Modules that return "hidden" indicators will now also return a
"suppressed" indicator.
* ApiQueryImageInfo will now return info for DELETED_FILE file revisions
if the requesting user has the 'deletedtext' right.
* ApiQueryLogEvents, when searching by user or title, will now return
entries where the user or action are revision-deleted if the
requesting user has the 'deletedhistory' right.
* ApiQueryContributions now uses the correct user rights rather than
'hideuser' to determine when to show contributions where the username
was revision-deleted.
* ApiQueryContributions will now indicate when the revision text is
hidden.
* Fix a bug in ApiQueryDeletedrevs found during testing where specifying
the "content" prop along with the "tags" prop or "drtag" parameter
would cause an SQL error.
* Fix various PHP warnings in ApiQueryFilearchive caused by the lack of
ArchivedFile::selectFields() fields.
* ApiQueryImageInfo::getInfo's $metadataOpts parameter has been renamed
$opts, and now may have an option to indicate the user to use for
RevDel visibility checks.
* ApiQueryWatchlist now properly uses the actual user's rights for
checking whether wlprop=patrol is allowed, rather than using the
wlowner's rights.
Bug: 27747
Bug: 27748
Bug: 28261
Bug: 34926
Bug: 48966
Change-Id: Idec2199976f460e1c73a26d0717e9fc4ab8042bb
2013-12-18 21:58:39 +00:00
|
|
|
$vals['user'] = $revision->getRawUserText();
|
2010-08-28 00:54:16 +00:00
|
|
|
}
|
Improve API query RevDel handling
* ApiQueryDeletedrevs, ApiQueryFilearchive, ApiQueryRecentChanges, and
ApiQueryWatchlist will now return entires where fields have been
revision-deleted. "Hidden" indicators will be provided as appropriate.
* ApiQueryImageInfo, ApiQueryLogEvents, ApiQueryRevisions,
ApiQueryContributions will now return field values in addition to the
"hidden" indicators when the requesting user has the necessary rights.
* Modules that return "hidden" indicators will now also return a
"suppressed" indicator.
* ApiQueryImageInfo will now return info for DELETED_FILE file revisions
if the requesting user has the 'deletedtext' right.
* ApiQueryLogEvents, when searching by user or title, will now return
entries where the user or action are revision-deleted if the
requesting user has the 'deletedhistory' right.
* ApiQueryContributions now uses the correct user rights rather than
'hideuser' to determine when to show contributions where the username
was revision-deleted.
* ApiQueryContributions will now indicate when the revision text is
hidden.
* Fix a bug in ApiQueryDeletedrevs found during testing where specifying
the "content" prop along with the "tags" prop or "drtag" parameter
would cause an SQL error.
* Fix various PHP warnings in ApiQueryFilearchive caused by the lack of
ArchivedFile::selectFields() fields.
* ApiQueryImageInfo::getInfo's $metadataOpts parameter has been renamed
$opts, and now may have an option to indicate the user to use for
RevDel visibility checks.
* ApiQueryWatchlist now properly uses the actual user's rights for
checking whether wlprop=patrol is allowed, rather than using the
wlowner's rights.
Bug: 27747
Bug: 27748
Bug: 28261
Bug: 34926
Bug: 48966
Change-Id: Idec2199976f460e1c73a26d0717e9fc4ab8042bb
2013-12-18 21:58:39 +00:00
|
|
|
$userid = $revision->getRawUser();
|
2010-10-17 18:54:39 +00:00
|
|
|
if ( !$userid ) {
|
2009-02-05 11:44:10 +00:00
|
|
|
$vals['anon'] = '';
|
2010-02-24 14:45:19 +00:00
|
|
|
}
|
2010-10-17 18:54:39 +00:00
|
|
|
|
|
|
|
|
if ( $this->fld_userid ) {
|
|
|
|
|
$vals['userid'] = $userid;
|
|
|
|
|
}
|
2009-02-05 11:44:10 +00:00
|
|
|
}
|
2007-05-20 08:34:47 +00:00
|
|
|
}
|
|
|
|
|
|
2010-01-11 15:55:52 +00:00
|
|
|
if ( $this->fld_timestamp ) {
|
|
|
|
|
$vals['timestamp'] = wfTimestamp( TS_ISO_8601, $revision->getTimestamp() );
|
2007-05-20 08:34:47 +00:00
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2011-12-11 18:39:31 +00:00
|
|
|
if ( $this->fld_size ) {
|
|
|
|
|
if ( !is_null( $revision->getSize() ) ) {
|
|
|
|
|
$vals['size'] = intval( $revision->getSize() );
|
|
|
|
|
} else {
|
|
|
|
|
$vals['size'] = 0;
|
|
|
|
|
}
|
2007-08-09 06:38:48 +00:00
|
|
|
}
|
|
|
|
|
|
Improve API query RevDel handling
* ApiQueryDeletedrevs, ApiQueryFilearchive, ApiQueryRecentChanges, and
ApiQueryWatchlist will now return entires where fields have been
revision-deleted. "Hidden" indicators will be provided as appropriate.
* ApiQueryImageInfo, ApiQueryLogEvents, ApiQueryRevisions,
ApiQueryContributions will now return field values in addition to the
"hidden" indicators when the requesting user has the necessary rights.
* Modules that return "hidden" indicators will now also return a
"suppressed" indicator.
* ApiQueryImageInfo will now return info for DELETED_FILE file revisions
if the requesting user has the 'deletedtext' right.
* ApiQueryLogEvents, when searching by user or title, will now return
entries where the user or action are revision-deleted if the
requesting user has the 'deletedhistory' right.
* ApiQueryContributions now uses the correct user rights rather than
'hideuser' to determine when to show contributions where the username
was revision-deleted.
* ApiQueryContributions will now indicate when the revision text is
hidden.
* Fix a bug in ApiQueryDeletedrevs found during testing where specifying
the "content" prop along with the "tags" prop or "drtag" parameter
would cause an SQL error.
* Fix various PHP warnings in ApiQueryFilearchive caused by the lack of
ArchivedFile::selectFields() fields.
* ApiQueryImageInfo::getInfo's $metadataOpts parameter has been renamed
$opts, and now may have an option to indicate the user to use for
RevDel visibility checks.
* ApiQueryWatchlist now properly uses the actual user's rights for
checking whether wlprop=patrol is allowed, rather than using the
wlowner's rights.
Bug: 27747
Bug: 27748
Bug: 28261
Bug: 34926
Bug: 48966
Change-Id: Idec2199976f460e1c73a26d0717e9fc4ab8042bb
2013-12-18 21:58:39 +00:00
|
|
|
if ( $this->fld_sha1 ) {
|
|
|
|
|
if ( $revision->isDeleted( Revision::DELETED_TEXT ) ) {
|
|
|
|
|
$vals['sha1hidden'] = '';
|
|
|
|
|
$anyHidden = true;
|
|
|
|
|
}
|
|
|
|
|
if ( $revision->userCan( Revision::DELETED_TEXT, $user ) ) {
|
|
|
|
|
if ( $revision->getSha1() != '' ) {
|
|
|
|
|
$vals['sha1'] = wfBaseConvert( $revision->getSha1(), 36, 16, 40 );
|
|
|
|
|
} else {
|
|
|
|
|
$vals['sha1'] = '';
|
|
|
|
|
}
|
2011-12-20 21:58:29 +00:00
|
|
|
}
|
2011-12-17 18:27:38 +00:00
|
|
|
}
|
|
|
|
|
|
2012-06-13 09:58:05 +00:00
|
|
|
if ( $this->fld_contentmodel ) {
|
|
|
|
|
$vals['contentmodel'] = $revision->getContentModel();
|
|
|
|
|
}
|
|
|
|
|
|
2010-01-31 20:59:50 +00:00
|
|
|
if ( $this->fld_comment || $this->fld_parsedcomment ) {
|
2010-01-11 15:55:52 +00:00
|
|
|
if ( $revision->isDeleted( Revision::DELETED_COMMENT ) ) {
|
2009-02-05 11:44:10 +00:00
|
|
|
$vals['commenthidden'] = '';
|
Improve API query RevDel handling
* ApiQueryDeletedrevs, ApiQueryFilearchive, ApiQueryRecentChanges, and
ApiQueryWatchlist will now return entires where fields have been
revision-deleted. "Hidden" indicators will be provided as appropriate.
* ApiQueryImageInfo, ApiQueryLogEvents, ApiQueryRevisions,
ApiQueryContributions will now return field values in addition to the
"hidden" indicators when the requesting user has the necessary rights.
* Modules that return "hidden" indicators will now also return a
"suppressed" indicator.
* ApiQueryImageInfo will now return info for DELETED_FILE file revisions
if the requesting user has the 'deletedtext' right.
* ApiQueryLogEvents, when searching by user or title, will now return
entries where the user or action are revision-deleted if the
requesting user has the 'deletedhistory' right.
* ApiQueryContributions now uses the correct user rights rather than
'hideuser' to determine when to show contributions where the username
was revision-deleted.
* ApiQueryContributions will now indicate when the revision text is
hidden.
* Fix a bug in ApiQueryDeletedrevs found during testing where specifying
the "content" prop along with the "tags" prop or "drtag" parameter
would cause an SQL error.
* Fix various PHP warnings in ApiQueryFilearchive caused by the lack of
ArchivedFile::selectFields() fields.
* ApiQueryImageInfo::getInfo's $metadataOpts parameter has been renamed
$opts, and now may have an option to indicate the user to use for
RevDel visibility checks.
* ApiQueryWatchlist now properly uses the actual user's rights for
checking whether wlprop=patrol is allowed, rather than using the
wlowner's rights.
Bug: 27747
Bug: 27748
Bug: 28261
Bug: 34926
Bug: 48966
Change-Id: Idec2199976f460e1c73a26d0717e9fc4ab8042bb
2013-12-18 21:58:39 +00:00
|
|
|
$anyHidden = true;
|
|
|
|
|
}
|
|
|
|
|
if ( $revision->userCan( Revision::DELETED_COMMENT, $user ) ) {
|
|
|
|
|
$comment = $revision->getRawComment();
|
2010-07-23 07:33:40 +00:00
|
|
|
|
2010-03-31 15:26:17 +00:00
|
|
|
if ( $this->fld_comment ) {
|
|
|
|
|
$vals['comment'] = $comment;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( $this->fld_parsedcomment ) {
|
2011-09-16 19:35:14 +00:00
|
|
|
$vals['parsedcomment'] = Linker::formatComment( $comment, $title );
|
2010-01-31 20:59:50 +00:00
|
|
|
}
|
2009-02-05 11:44:10 +00:00
|
|
|
}
|
2010-01-11 15:55:52 +00:00
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2010-01-11 15:55:52 +00:00
|
|
|
if ( $this->fld_tags ) {
|
|
|
|
|
if ( $row->ts_tags ) {
|
|
|
|
|
$tags = explode( ',', $row->ts_tags );
|
|
|
|
|
$this->getResult()->setIndexedTagName( $tags, 'tag' );
|
2009-11-01 10:42:41 +00:00
|
|
|
$vals['tags'] = $tags;
|
|
|
|
|
} else {
|
|
|
|
|
$vals['tags'] = array();
|
|
|
|
|
}
|
|
|
|
|
}
|
2010-02-24 14:45:19 +00:00
|
|
|
|
|
|
|
|
if ( !is_null( $this->token ) ) {
|
2008-07-04 12:07:02 +00:00
|
|
|
$tokenFunctions = $this->getTokenFunctions();
|
2010-02-24 14:45:19 +00:00
|
|
|
foreach ( $this->token as $t ) {
|
2010-01-11 15:55:52 +00:00
|
|
|
$val = call_user_func( $tokenFunctions[$t], $title->getArticleID(), $title, $revision );
|
2010-02-24 14:45:19 +00:00
|
|
|
if ( $val === false ) {
|
2010-01-11 15:55:52 +00:00
|
|
|
$this->setWarning( "Action '$t' is not allowed for the current user" );
|
2010-02-24 14:45:19 +00:00
|
|
|
} else {
|
2008-07-04 12:07:02 +00:00
|
|
|
$vals[$t . 'token'] = $val;
|
2010-02-24 14:45:19 +00:00
|
|
|
}
|
2008-07-04 12:07:02 +00:00
|
|
|
}
|
2007-12-01 15:08:57 +00:00
|
|
|
}
|
2010-02-24 14:45:19 +00:00
|
|
|
|
2012-06-13 09:58:05 +00:00
|
|
|
$content = null;
|
2010-07-25 19:45:52 +00:00
|
|
|
global $wgParser;
|
2013-01-10 14:24:39 +00:00
|
|
|
if ( $this->fld_content || !is_null( $this->diffto ) || !is_null( $this->difftotext ) ) {
|
Improve API query RevDel handling
* ApiQueryDeletedrevs, ApiQueryFilearchive, ApiQueryRecentChanges, and
ApiQueryWatchlist will now return entires where fields have been
revision-deleted. "Hidden" indicators will be provided as appropriate.
* ApiQueryImageInfo, ApiQueryLogEvents, ApiQueryRevisions,
ApiQueryContributions will now return field values in addition to the
"hidden" indicators when the requesting user has the necessary rights.
* Modules that return "hidden" indicators will now also return a
"suppressed" indicator.
* ApiQueryImageInfo will now return info for DELETED_FILE file revisions
if the requesting user has the 'deletedtext' right.
* ApiQueryLogEvents, when searching by user or title, will now return
entries where the user or action are revision-deleted if the
requesting user has the 'deletedhistory' right.
* ApiQueryContributions now uses the correct user rights rather than
'hideuser' to determine when to show contributions where the username
was revision-deleted.
* ApiQueryContributions will now indicate when the revision text is
hidden.
* Fix a bug in ApiQueryDeletedrevs found during testing where specifying
the "content" prop along with the "tags" prop or "drtag" parameter
would cause an SQL error.
* Fix various PHP warnings in ApiQueryFilearchive caused by the lack of
ArchivedFile::selectFields() fields.
* ApiQueryImageInfo::getInfo's $metadataOpts parameter has been renamed
$opts, and now may have an option to indicate the user to use for
RevDel visibility checks.
* ApiQueryWatchlist now properly uses the actual user's rights for
checking whether wlprop=patrol is allowed, rather than using the
wlowner's rights.
Bug: 27747
Bug: 27748
Bug: 28261
Bug: 34926
Bug: 48966
Change-Id: Idec2199976f460e1c73a26d0717e9fc4ab8042bb
2013-12-18 21:58:39 +00:00
|
|
|
$content = $revision->getContent( Revision::FOR_THIS_USER, $this->getUser() );
|
2010-01-23 22:52:40 +00:00
|
|
|
// Expand templates after getting section content because
|
|
|
|
|
// template-added sections don't count and Parser::preprocess()
|
|
|
|
|
// will have less input
|
2012-12-13 16:50:45 +00:00
|
|
|
if ( $content && $this->section !== false ) {
|
2012-06-13 09:58:05 +00:00
|
|
|
$content = $content->getSection( $this->section, false );
|
|
|
|
|
if ( !$content ) {
|
2013-11-14 13:58:14 +00:00
|
|
|
$this->dieUsage(
|
|
|
|
|
"There is no section {$this->section} in r" . $revision->getId(),
|
|
|
|
|
'nosuchsection'
|
|
|
|
|
);
|
2010-02-24 14:45:19 +00:00
|
|
|
}
|
2008-03-14 13:07:38 +00:00
|
|
|
}
|
Improve API query RevDel handling
* ApiQueryDeletedrevs, ApiQueryFilearchive, ApiQueryRecentChanges, and
ApiQueryWatchlist will now return entires where fields have been
revision-deleted. "Hidden" indicators will be provided as appropriate.
* ApiQueryImageInfo, ApiQueryLogEvents, ApiQueryRevisions,
ApiQueryContributions will now return field values in addition to the
"hidden" indicators when the requesting user has the necessary rights.
* Modules that return "hidden" indicators will now also return a
"suppressed" indicator.
* ApiQueryImageInfo will now return info for DELETED_FILE file revisions
if the requesting user has the 'deletedtext' right.
* ApiQueryLogEvents, when searching by user or title, will now return
entries where the user or action are revision-deleted if the
requesting user has the 'deletedhistory' right.
* ApiQueryContributions now uses the correct user rights rather than
'hideuser' to determine when to show contributions where the username
was revision-deleted.
* ApiQueryContributions will now indicate when the revision text is
hidden.
* Fix a bug in ApiQueryDeletedrevs found during testing where specifying
the "content" prop along with the "tags" prop or "drtag" parameter
would cause an SQL error.
* Fix various PHP warnings in ApiQueryFilearchive caused by the lack of
ArchivedFile::selectFields() fields.
* ApiQueryImageInfo::getInfo's $metadataOpts parameter has been renamed
$opts, and now may have an option to indicate the user to use for
RevDel visibility checks.
* ApiQueryWatchlist now properly uses the actual user's rights for
checking whether wlprop=patrol is allowed, rather than using the
wlowner's rights.
Bug: 27747
Bug: 27748
Bug: 28261
Bug: 34926
Bug: 48966
Change-Id: Idec2199976f460e1c73a26d0717e9fc4ab8042bb
2013-12-18 21:58:39 +00:00
|
|
|
if ( $revision->isDeleted( Revision::DELETED_TEXT ) ) {
|
|
|
|
|
$vals['texthidden'] = '';
|
|
|
|
|
$anyHidden = true;
|
|
|
|
|
} elseif ( !$content ) {
|
|
|
|
|
$vals['textmissing'] = '';
|
|
|
|
|
}
|
2009-12-09 18:34:32 +00:00
|
|
|
}
|
Improve API query RevDel handling
* ApiQueryDeletedrevs, ApiQueryFilearchive, ApiQueryRecentChanges, and
ApiQueryWatchlist will now return entires where fields have been
revision-deleted. "Hidden" indicators will be provided as appropriate.
* ApiQueryImageInfo, ApiQueryLogEvents, ApiQueryRevisions,
ApiQueryContributions will now return field values in addition to the
"hidden" indicators when the requesting user has the necessary rights.
* Modules that return "hidden" indicators will now also return a
"suppressed" indicator.
* ApiQueryImageInfo will now return info for DELETED_FILE file revisions
if the requesting user has the 'deletedtext' right.
* ApiQueryLogEvents, when searching by user or title, will now return
entries where the user or action are revision-deleted if the
requesting user has the 'deletedhistory' right.
* ApiQueryContributions now uses the correct user rights rather than
'hideuser' to determine when to show contributions where the username
was revision-deleted.
* ApiQueryContributions will now indicate when the revision text is
hidden.
* Fix a bug in ApiQueryDeletedrevs found during testing where specifying
the "content" prop along with the "tags" prop or "drtag" parameter
would cause an SQL error.
* Fix various PHP warnings in ApiQueryFilearchive caused by the lack of
ArchivedFile::selectFields() fields.
* ApiQueryImageInfo::getInfo's $metadataOpts parameter has been renamed
$opts, and now may have an option to indicate the user to use for
RevDel visibility checks.
* ApiQueryWatchlist now properly uses the actual user's rights for
checking whether wlprop=patrol is allowed, rather than using the
wlowner's rights.
Bug: 27747
Bug: 27748
Bug: 28261
Bug: 34926
Bug: 48966
Change-Id: Idec2199976f460e1c73a26d0717e9fc4ab8042bb
2013-12-18 21:58:39 +00:00
|
|
|
if ( $this->fld_content && $content ) {
|
2012-06-13 09:58:05 +00:00
|
|
|
$text = null;
|
|
|
|
|
|
2010-01-11 15:55:52 +00:00
|
|
|
if ( $this->generateXML ) {
|
2012-06-13 09:58:05 +00:00
|
|
|
if ( $content->getModel() === CONTENT_MODEL_WIKITEXT ) {
|
|
|
|
|
$t = $content->getNativeData(); # note: don't set $text
|
|
|
|
|
|
2013-11-14 13:58:14 +00:00
|
|
|
$wgParser->startExternalParse(
|
|
|
|
|
$title,
|
|
|
|
|
ParserOptions::newFromContext( $this->getContext() ),
|
|
|
|
|
OT_PREPROCESS
|
|
|
|
|
);
|
2012-06-13 09:58:05 +00:00
|
|
|
$dom = $wgParser->preprocessToDom( $t );
|
|
|
|
|
if ( is_callable( array( $dom, 'saveXML' ) ) ) {
|
|
|
|
|
$xml = $dom->saveXML();
|
|
|
|
|
} else {
|
|
|
|
|
$xml = $dom->__toString();
|
|
|
|
|
}
|
|
|
|
|
$vals['parsetree'] = $xml;
|
2008-11-21 13:55:27 +00:00
|
|
|
} else {
|
2012-06-13 09:58:05 +00:00
|
|
|
$this->setWarning( "Conversion to XML is supported for wikitext only, " .
|
2013-11-14 13:00:02 +00:00
|
|
|
$title->getPrefixedDBkey() .
|
|
|
|
|
" uses content model " . $content->getModel() );
|
2008-11-21 13:55:27 +00:00
|
|
|
}
|
|
|
|
|
}
|
2012-06-13 09:58:05 +00:00
|
|
|
|
2010-10-23 16:41:20 +00:00
|
|
|
if ( $this->expandTemplates && !$this->parseContent ) {
|
2012-06-13 09:58:05 +00:00
|
|
|
#XXX: implement template expansion for all content types in ContentHandler?
|
|
|
|
|
if ( $content->getModel() === CONTENT_MODEL_WIKITEXT ) {
|
|
|
|
|
$text = $content->getNativeData();
|
|
|
|
|
|
2013-11-14 13:58:14 +00:00
|
|
|
$text = $wgParser->preprocess(
|
|
|
|
|
$text,
|
|
|
|
|
$title,
|
|
|
|
|
ParserOptions::newFromContext( $this->getContext() )
|
|
|
|
|
);
|
2012-06-13 09:58:05 +00:00
|
|
|
} else {
|
|
|
|
|
$this->setWarning( "Template expansion is supported for wikitext only, " .
|
|
|
|
|
$title->getPrefixedDBkey() .
|
2013-06-09 10:07:41 +00:00
|
|
|
" uses content model " . $content->getModel() );
|
2012-06-13 09:58:05 +00:00
|
|
|
|
|
|
|
|
$text = false;
|
|
|
|
|
}
|
2007-09-25 18:36:25 +00:00
|
|
|
}
|
2010-10-23 16:41:20 +00:00
|
|
|
if ( $this->parseContent ) {
|
2013-11-14 13:58:14 +00:00
|
|
|
$po = $content->getParserOutput(
|
|
|
|
|
$title,
|
|
|
|
|
$revision->getId(),
|
|
|
|
|
ParserOptions::newFromContext( $this->getContext() )
|
|
|
|
|
);
|
2012-06-13 09:58:05 +00:00
|
|
|
$text = $po->getText();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( $text === null ) {
|
|
|
|
|
$format = $this->contentFormat ? $this->contentFormat : $content->getDefaultFormat();
|
2012-11-14 11:17:13 +00:00
|
|
|
$model = $content->getModel();
|
2012-06-13 09:58:05 +00:00
|
|
|
|
|
|
|
|
if ( !$content->isSupportedFormat( $format ) ) {
|
|
|
|
|
$name = $title->getPrefixedDBkey();
|
|
|
|
|
|
2013-04-13 11:36:24 +00:00
|
|
|
$this->dieUsage( "The requested format {$this->contentFormat} is not supported " .
|
2013-11-14 13:00:02 +00:00
|
|
|
"for content model $model used by $name", 'badformat' );
|
2012-06-13 09:58:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$text = $content->serialize( $format );
|
2012-11-14 11:17:13 +00:00
|
|
|
|
|
|
|
|
// always include format and model.
|
|
|
|
|
// Format is needed to deserialize, model is needed to interpret.
|
2012-06-25 21:30:51 +00:00
|
|
|
$vals['contentformat'] = $format;
|
2012-11-14 11:17:13 +00:00
|
|
|
$vals['contentmodel'] = $model;
|
2012-06-13 09:58:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( $text !== false ) {
|
|
|
|
|
ApiResult::setContent( $vals, $text );
|
2010-10-23 16:41:20 +00:00
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
}
|
2009-02-28 13:25:21 +00:00
|
|
|
|
Improve API query RevDel handling
* ApiQueryDeletedrevs, ApiQueryFilearchive, ApiQueryRecentChanges, and
ApiQueryWatchlist will now return entires where fields have been
revision-deleted. "Hidden" indicators will be provided as appropriate.
* ApiQueryImageInfo, ApiQueryLogEvents, ApiQueryRevisions,
ApiQueryContributions will now return field values in addition to the
"hidden" indicators when the requesting user has the necessary rights.
* Modules that return "hidden" indicators will now also return a
"suppressed" indicator.
* ApiQueryImageInfo will now return info for DELETED_FILE file revisions
if the requesting user has the 'deletedtext' right.
* ApiQueryLogEvents, when searching by user or title, will now return
entries where the user or action are revision-deleted if the
requesting user has the 'deletedhistory' right.
* ApiQueryContributions now uses the correct user rights rather than
'hideuser' to determine when to show contributions where the username
was revision-deleted.
* ApiQueryContributions will now indicate when the revision text is
hidden.
* Fix a bug in ApiQueryDeletedrevs found during testing where specifying
the "content" prop along with the "tags" prop or "drtag" parameter
would cause an SQL error.
* Fix various PHP warnings in ApiQueryFilearchive caused by the lack of
ArchivedFile::selectFields() fields.
* ApiQueryImageInfo::getInfo's $metadataOpts parameter has been renamed
$opts, and now may have an option to indicate the user to use for
RevDel visibility checks.
* ApiQueryWatchlist now properly uses the actual user's rights for
checking whether wlprop=patrol is allowed, rather than using the
wlowner's rights.
Bug: 27747
Bug: 27748
Bug: 28261
Bug: 34926
Bug: 48966
Change-Id: Idec2199976f460e1c73a26d0717e9fc4ab8042bb
2013-12-18 21:58:39 +00:00
|
|
|
if ( $content && ( !is_null( $this->diffto ) || !is_null( $this->difftotext ) ) ) {
|
2009-02-28 13:25:21 +00:00
|
|
|
global $wgAPIMaxUncachedDiffs;
|
2009-12-09 18:34:32 +00:00
|
|
|
static $n = 0; // Number of uncached diffs we've had
|
2012-12-13 16:50:45 +00:00
|
|
|
|
Improve API query RevDel handling
* ApiQueryDeletedrevs, ApiQueryFilearchive, ApiQueryRecentChanges, and
ApiQueryWatchlist will now return entires where fields have been
revision-deleted. "Hidden" indicators will be provided as appropriate.
* ApiQueryImageInfo, ApiQueryLogEvents, ApiQueryRevisions,
ApiQueryContributions will now return field values in addition to the
"hidden" indicators when the requesting user has the necessary rights.
* Modules that return "hidden" indicators will now also return a
"suppressed" indicator.
* ApiQueryImageInfo will now return info for DELETED_FILE file revisions
if the requesting user has the 'deletedtext' right.
* ApiQueryLogEvents, when searching by user or title, will now return
entries where the user or action are revision-deleted if the
requesting user has the 'deletedhistory' right.
* ApiQueryContributions now uses the correct user rights rather than
'hideuser' to determine when to show contributions where the username
was revision-deleted.
* ApiQueryContributions will now indicate when the revision text is
hidden.
* Fix a bug in ApiQueryDeletedrevs found during testing where specifying
the "content" prop along with the "tags" prop or "drtag" parameter
would cause an SQL error.
* Fix various PHP warnings in ApiQueryFilearchive caused by the lack of
ArchivedFile::selectFields() fields.
* ApiQueryImageInfo::getInfo's $metadataOpts parameter has been renamed
$opts, and now may have an option to indicate the user to use for
RevDel visibility checks.
* ApiQueryWatchlist now properly uses the actual user's rights for
checking whether wlprop=patrol is allowed, rather than using the
wlowner's rights.
Bug: 27747
Bug: 27748
Bug: 28261
Bug: 34926
Bug: 48966
Change-Id: Idec2199976f460e1c73a26d0717e9fc4ab8042bb
2013-12-18 21:58:39 +00:00
|
|
|
if ( $n < $wgAPIMaxUncachedDiffs ) {
|
2009-12-09 18:34:32 +00:00
|
|
|
$vals['diff'] = array();
|
2011-11-10 13:06:52 +00:00
|
|
|
$context = new DerivativeContext( $this->getContext() );
|
|
|
|
|
$context->setTitle( $title );
|
2012-08-24 18:49:19 +00:00
|
|
|
$handler = $revision->getContentHandler();
|
2012-03-23 15:18:44 +00:00
|
|
|
|
2010-01-11 15:55:52 +00:00
|
|
|
if ( !is_null( $this->difftotext ) ) {
|
2012-06-13 09:58:05 +00:00
|
|
|
$model = $title->getContentModel();
|
|
|
|
|
|
2012-08-20 19:33:07 +00:00
|
|
|
if ( $this->contentFormat
|
2013-11-14 13:00:02 +00:00
|
|
|
&& !ContentHandler::getForModelID( $model )->isSupportedFormat( $this->contentFormat )
|
|
|
|
|
) {
|
2012-08-20 19:33:07 +00:00
|
|
|
|
2012-06-13 09:58:05 +00:00
|
|
|
$name = $title->getPrefixedDBkey();
|
|
|
|
|
|
2013-04-13 11:36:24 +00:00
|
|
|
$this->dieUsage( "The requested format {$this->contentFormat} is not supported for " .
|
2013-11-14 13:00:02 +00:00
|
|
|
"content model $model used by $name", 'badformat' );
|
2012-06-13 09:58:05 +00:00
|
|
|
}
|
|
|
|
|
|
2013-11-14 13:58:14 +00:00
|
|
|
$difftocontent = ContentHandler::makeContent(
|
|
|
|
|
$this->difftotext,
|
|
|
|
|
$title,
|
|
|
|
|
$model,
|
|
|
|
|
$this->contentFormat
|
|
|
|
|
);
|
2012-06-13 09:58:05 +00:00
|
|
|
|
2012-04-17 19:02:03 +00:00
|
|
|
$engine = $handler->createDifferenceEngine( $context );
|
2012-06-13 09:58:05 +00:00
|
|
|
$engine->setContent( $content, $difftocontent );
|
2009-12-09 18:34:32 +00:00
|
|
|
} else {
|
2012-04-17 19:02:03 +00:00
|
|
|
$engine = $handler->createDifferenceEngine( $context, $revision->getID(), $this->diffto );
|
2009-12-09 18:34:32 +00:00
|
|
|
$vals['diff']['from'] = $engine->getOldid();
|
|
|
|
|
$vals['diff']['to'] = $engine->getNewid();
|
|
|
|
|
}
|
2009-02-28 13:25:21 +00:00
|
|
|
$difftext = $engine->getDiffBody();
|
2010-01-11 15:55:52 +00:00
|
|
|
ApiResult::setContent( $vals['diff'], $difftext );
|
2010-02-24 14:45:19 +00:00
|
|
|
if ( !$engine->wasCacheHit() ) {
|
2009-02-28 13:25:21 +00:00
|
|
|
$n++;
|
2010-02-24 14:45:19 +00:00
|
|
|
}
|
2009-02-28 13:25:21 +00:00
|
|
|
} else {
|
|
|
|
|
$vals['diff']['notcached'] = '';
|
|
|
|
|
}
|
|
|
|
|
}
|
2013-11-14 13:00:02 +00:00
|
|
|
|
Improve API query RevDel handling
* ApiQueryDeletedrevs, ApiQueryFilearchive, ApiQueryRecentChanges, and
ApiQueryWatchlist will now return entires where fields have been
revision-deleted. "Hidden" indicators will be provided as appropriate.
* ApiQueryImageInfo, ApiQueryLogEvents, ApiQueryRevisions,
ApiQueryContributions will now return field values in addition to the
"hidden" indicators when the requesting user has the necessary rights.
* Modules that return "hidden" indicators will now also return a
"suppressed" indicator.
* ApiQueryImageInfo will now return info for DELETED_FILE file revisions
if the requesting user has the 'deletedtext' right.
* ApiQueryLogEvents, when searching by user or title, will now return
entries where the user or action are revision-deleted if the
requesting user has the 'deletedhistory' right.
* ApiQueryContributions now uses the correct user rights rather than
'hideuser' to determine when to show contributions where the username
was revision-deleted.
* ApiQueryContributions will now indicate when the revision text is
hidden.
* Fix a bug in ApiQueryDeletedrevs found during testing where specifying
the "content" prop along with the "tags" prop or "drtag" parameter
would cause an SQL error.
* Fix various PHP warnings in ApiQueryFilearchive caused by the lack of
ArchivedFile::selectFields() fields.
* ApiQueryImageInfo::getInfo's $metadataOpts parameter has been renamed
$opts, and now may have an option to indicate the user to use for
RevDel visibility checks.
* ApiQueryWatchlist now properly uses the actual user's rights for
checking whether wlprop=patrol is allowed, rather than using the
wlowner's rights.
Bug: 27747
Bug: 27748
Bug: 28261
Bug: 34926
Bug: 48966
Change-Id: Idec2199976f460e1c73a26d0717e9fc4ab8042bb
2013-12-18 21:58:39 +00:00
|
|
|
if ( $anyHidden && $revision->isDeleted( Revision::DELETED_RESTRICTED ) ) {
|
|
|
|
|
$vals['suppressed'] = '';
|
|
|
|
|
}
|
|
|
|
|
|
2007-05-20 08:34:47 +00:00
|
|
|
return $vals;
|
|
|
|
|
}
|
|
|
|
|
|
2010-07-23 07:17:56 +00:00
|
|
|
public function getCacheMode( $params ) {
|
|
|
|
|
if ( isset( $params['token'] ) ) {
|
|
|
|
|
return 'private';
|
|
|
|
|
}
|
Improve API query RevDel handling
* ApiQueryDeletedrevs, ApiQueryFilearchive, ApiQueryRecentChanges, and
ApiQueryWatchlist will now return entires where fields have been
revision-deleted. "Hidden" indicators will be provided as appropriate.
* ApiQueryImageInfo, ApiQueryLogEvents, ApiQueryRevisions,
ApiQueryContributions will now return field values in addition to the
"hidden" indicators when the requesting user has the necessary rights.
* Modules that return "hidden" indicators will now also return a
"suppressed" indicator.
* ApiQueryImageInfo will now return info for DELETED_FILE file revisions
if the requesting user has the 'deletedtext' right.
* ApiQueryLogEvents, when searching by user or title, will now return
entries where the user or action are revision-deleted if the
requesting user has the 'deletedhistory' right.
* ApiQueryContributions now uses the correct user rights rather than
'hideuser' to determine when to show contributions where the username
was revision-deleted.
* ApiQueryContributions will now indicate when the revision text is
hidden.
* Fix a bug in ApiQueryDeletedrevs found during testing where specifying
the "content" prop along with the "tags" prop or "drtag" parameter
would cause an SQL error.
* Fix various PHP warnings in ApiQueryFilearchive caused by the lack of
ArchivedFile::selectFields() fields.
* ApiQueryImageInfo::getInfo's $metadataOpts parameter has been renamed
$opts, and now may have an option to indicate the user to use for
RevDel visibility checks.
* ApiQueryWatchlist now properly uses the actual user's rights for
checking whether wlprop=patrol is allowed, rather than using the
wlowner's rights.
Bug: 27747
Bug: 27748
Bug: 28261
Bug: 34926
Bug: 48966
Change-Id: Idec2199976f460e1c73a26d0717e9fc4ab8042bb
2013-12-18 21:58:39 +00:00
|
|
|
if ( $this->userCanSeeRevDel() ) {
|
|
|
|
|
return 'private';
|
|
|
|
|
}
|
2010-07-23 07:17:56 +00:00
|
|
|
if ( !is_null( $params['prop'] ) && in_array( 'parsedcomment', $params['prop'] ) ) {
|
2012-08-29 08:07:10 +00:00
|
|
|
// formatComment() calls wfMessage() among other things
|
2010-07-23 07:17:56 +00:00
|
|
|
return 'anon-public-user-private';
|
2010-07-23 07:33:40 +00:00
|
|
|
}
|
2013-11-14 13:00:02 +00:00
|
|
|
|
2010-07-23 07:17:56 +00:00
|
|
|
return 'public';
|
|
|
|
|
}
|
|
|
|
|
|
2008-01-28 19:05:26 +00:00
|
|
|
public function getAllowedParams() {
|
2010-02-24 14:45:19 +00:00
|
|
|
return array(
|
|
|
|
|
'prop' => array(
|
|
|
|
|
ApiBase::PARAM_ISMULTI => true,
|
|
|
|
|
ApiBase::PARAM_DFLT => 'ids|timestamp|flags|comment|user',
|
|
|
|
|
ApiBase::PARAM_TYPE => array(
|
2007-05-21 06:32:32 +00:00
|
|
|
'ids',
|
|
|
|
|
'flags',
|
2006-10-01 20:17:16 +00:00
|
|
|
'timestamp',
|
|
|
|
|
'user',
|
2010-08-28 00:37:48 +00:00
|
|
|
'userid',
|
2007-08-09 06:38:48 +00:00
|
|
|
'size',
|
2011-12-17 18:27:38 +00:00
|
|
|
'sha1',
|
2012-06-13 09:58:05 +00:00
|
|
|
'contentmodel',
|
2006-10-01 20:17:16 +00:00
|
|
|
'comment',
|
2010-01-31 20:59:50 +00:00
|
|
|
'parsedcomment',
|
2007-08-09 06:38:48 +00:00
|
|
|
'content',
|
2009-11-01 10:42:41 +00:00
|
|
|
'tags'
|
2006-10-01 20:17:16 +00:00
|
|
|
)
|
|
|
|
|
),
|
2010-02-24 14:45:19 +00:00
|
|
|
'limit' => array(
|
|
|
|
|
ApiBase::PARAM_TYPE => 'limit',
|
|
|
|
|
ApiBase::PARAM_MIN => 1,
|
|
|
|
|
ApiBase::PARAM_MAX => ApiBase::LIMIT_BIG1,
|
|
|
|
|
ApiBase::PARAM_MAX2 => ApiBase::LIMIT_BIG2
|
2006-09-27 05:13:48 +00:00
|
|
|
),
|
2010-02-24 14:45:19 +00:00
|
|
|
'startid' => array(
|
|
|
|
|
ApiBase::PARAM_TYPE => 'integer'
|
2006-10-16 00:08:03 +00:00
|
|
|
),
|
2010-02-24 14:45:19 +00:00
|
|
|
'endid' => array(
|
|
|
|
|
ApiBase::PARAM_TYPE => 'integer'
|
2006-10-16 00:08:03 +00:00
|
|
|
),
|
2010-02-24 14:45:19 +00:00
|
|
|
'start' => array(
|
|
|
|
|
ApiBase::PARAM_TYPE => 'timestamp'
|
2006-09-26 05:43:02 +00:00
|
|
|
),
|
2010-02-24 14:45:19 +00:00
|
|
|
'end' => array(
|
|
|
|
|
ApiBase::PARAM_TYPE => 'timestamp'
|
2006-09-26 05:43:02 +00:00
|
|
|
),
|
2010-02-24 14:45:19 +00:00
|
|
|
'dir' => array(
|
|
|
|
|
ApiBase::PARAM_DFLT => 'older',
|
|
|
|
|
ApiBase::PARAM_TYPE => array(
|
2006-09-26 05:43:02 +00:00
|
|
|
'newer',
|
|
|
|
|
'older'
|
|
|
|
|
)
|
2007-05-19 04:13:48 +00:00
|
|
|
),
|
|
|
|
|
'user' => array(
|
2010-02-24 14:45:19 +00:00
|
|
|
ApiBase::PARAM_TYPE => 'user'
|
2007-05-19 04:13:48 +00:00
|
|
|
),
|
|
|
|
|
'excludeuser' => array(
|
2010-02-24 14:45:19 +00:00
|
|
|
ApiBase::PARAM_TYPE => 'user'
|
2007-09-25 18:36:25 +00:00
|
|
|
),
|
2009-11-02 08:29:26 +00:00
|
|
|
'tag' => null,
|
2007-09-25 18:36:25 +00:00
|
|
|
'expandtemplates' => false,
|
2008-11-21 13:55:27 +00:00
|
|
|
'generatexml' => false,
|
2010-10-23 16:41:20 +00:00
|
|
|
'parse' => false,
|
2008-12-03 19:01:30 +00:00
|
|
|
'section' => null,
|
2007-12-01 15:08:57 +00:00
|
|
|
'token' => array(
|
2010-02-24 14:45:19 +00:00
|
|
|
ApiBase::PARAM_TYPE => array_keys( $this->getTokenFunctions() ),
|
|
|
|
|
ApiBase::PARAM_ISMULTI => true
|
2007-12-01 15:08:57 +00:00
|
|
|
),
|
* API: BREAKING CHANGE: (bug 11430) Return fewer results than the limit in some cases to prevent running out of memory
* This means queries could possibly return fewer results than the limit and still set a query-continue
* Add iicontinue, rvcontinue, cicontinue, incontinue, amfrom to faciliate query-continue for these modules
* Implemented by blocking additions to the ApiResult object if they would make it too large
** Important things like query-continue values and warnings are exempt from this check
** RSS feeds and exported XML are also exempted (size-checking them would be too messy)
** Result size is checked against $wgAPIMaxResultSize, which defaults to 8 MB
For those who really care, per-file details follow:
ApiResult.php:
* Introduced ApiResult::$mSize which keeps track of the result size.
* Introduced ApiResult::size() which calculates an array's size
(which is the sum of the strlen()s of its elements).
* ApiResult::addValue() now checks that the result size stays below
$wgAPIMaxResultSize. If the item won't fit, it won't be added and addValue()
will return false. Callers should check the return value and set a
query-continue if it's false.
* Closed the back door that is ApiResult::getData(): callers can't manipulate
the data array directly anymore so they can't bypass the result size limit.
* Added ApiResult::setIndexedTagName_internal() which will call
setIndexedTagName() on an array already in the result. This is needed for the
'new' order of adding results, which means addValue()ing one result at a time
until you hit the limit or run out, then calling this function to set the tag
name.
* Added ApiResult::disableSizeCheck() and enableSizeCheck() which disable and
enable size checking in addValue(). This is used for stuff like query-continue
elements and warnings which shouldn't count towards the result size.
* Added ApiResult::unsetValue() which removes an element from the result and
decreases $mSize.
ApiBase.php:
* Like ApiResult::getData(), ApiBase::getResultData() no longer returns a
reference.
* Use ApiResult::disableSizeCheck() in ApiBase::setWarning()
ApiQueryBase.php:
* Added ApiQueryBase::addPageSubItem(), which adds page subitems one item
at a time.
* addPageSubItem() and addPageSubItems() now return whether the subitem
fit in the result.
* Use ApiResult::disableSizeCheck() in setContinueEnumParameter()
ApiMain.php:
* Use ApiResult::disableSizeCheck() in ApiMain::substituteResultWithError()
* Use getParameter() rather than $mRequest to obtain requestid
DefaultSettings.php:
* Added $wgAPIMaxResultSize, with a default value of 8 MB
ApiQuery*.php:
* Added results one at a time, and set a query-continue if the result is full.
ApiQueryLangLinks.php and friends:
* Migrated from addPageSubItems() to addPageSubItem(). This eliminates the
need for $lastId.
ApiQueryAllLinks.php, ApiQueryWatchlist.php, ApiQueryAllimages.php, ApiQuerySearch.php:
* Renamed $data to something more appropriate ($pageids, $ids or $titles)
ApiQuerySiteinfo.php:
* Abuse siprop as a query-continue parameter and set it to all props that
couldn't be processed.
ApiQueryRandom.php:
* Doesn't do continuations, because the result is supposed to be random.
* Be smart enough to not run the second query if the results of the first
didn't fit.
ApiQueryImageInfo.php, ApiQueryRevisions.php, ApiQueryCategoryInfo.php, ApiQueryInfo.php:
* Added continue parameter which basically skips the first so many items
ApiQueryBacklinks.php:
* Throw the result in a big array first and addValue() that one element at a time if necessary
** This is necessary because the results aren't retrieved in order
* Introduced $this->pageMap to map namespace and title to page ID
* Rewritten extractRowInfo() and extractRedirRowInfo() a little
* Declared all private member variables explicitly
ApiQueryDeletedrevs.php:
* Use a pagemap just like in Backlinks
* Introduce fake page IDs and keep track of them so we know where to add what
** This doesn't change the output format, because the fake page IDs start at 0 and are consecutive
ApiQueryAllmessages.php:
* Add amfrom to facilitate query-continue
ApiQueryUsers.php:
* Rewrite: put the getOtherUsersInfo() code in execute()
2009-02-05 14:30:59 +00:00
|
|
|
'continue' => null,
|
2009-02-28 13:25:21 +00:00
|
|
|
'diffto' => null,
|
2009-12-09 18:34:32 +00:00
|
|
|
'difftotext' => null,
|
2012-06-13 09:58:05 +00:00
|
|
|
'contentformat' => array(
|
2012-06-25 21:30:51 +00:00
|
|
|
ApiBase::PARAM_TYPE => ContentHandler::getAllContentFormats(),
|
2012-06-13 09:58:05 +00:00
|
|
|
ApiBase::PARAM_DFLT => null
|
|
|
|
|
),
|
2006-09-26 05:43:02 +00:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2008-01-28 19:05:26 +00:00
|
|
|
public function getParamDescription() {
|
2010-05-11 22:30:18 +00:00
|
|
|
$p = $this->getModulePrefix();
|
2013-11-14 13:00:02 +00:00
|
|
|
|
2010-02-24 14:45:19 +00:00
|
|
|
return array(
|
2010-06-23 19:36:26 +00:00
|
|
|
'prop' => array(
|
|
|
|
|
'Which properties to get for each revision:',
|
|
|
|
|
' ids - The ID of the revision',
|
|
|
|
|
' flags - Revision flags (minor)',
|
|
|
|
|
' timestamp - The timestamp of the revision',
|
2010-08-28 00:37:48 +00:00
|
|
|
' user - User that made the revision',
|
2010-09-27 13:06:35 +00:00
|
|
|
' userid - User id of revision creator',
|
2011-12-17 18:27:38 +00:00
|
|
|
' size - Length (bytes) of the revision',
|
2011-12-20 21:29:24 +00:00
|
|
|
' sha1 - SHA-1 (base 16) of the revision',
|
2012-06-13 09:58:05 +00:00
|
|
|
' contentmodel - Content model id',
|
2010-06-23 19:36:26 +00:00
|
|
|
' comment - Comment by the user for revision',
|
|
|
|
|
' parsedcomment - Parsed comment by the user for the revision',
|
|
|
|
|
' content - Text of the revision',
|
|
|
|
|
' tags - Tags for the revision',
|
|
|
|
|
),
|
2010-01-31 19:46:23 +00:00
|
|
|
'limit' => 'Limit how many revisions will be returned (enum)',
|
|
|
|
|
'startid' => 'From which revision id to start enumeration (enum)',
|
|
|
|
|
'endid' => 'Stop revision enumeration on this revid (enum)',
|
|
|
|
|
'start' => 'From which revision timestamp to start enumeration (enum)',
|
|
|
|
|
'end' => 'Enumerate up to this timestamp (enum)',
|
2011-10-20 14:28:41 +00:00
|
|
|
'dir' => $this->getDirectionDescription( $p, ' (enum)' ),
|
|
|
|
|
'user' => 'Only include revisions made by user (enum)',
|
|
|
|
|
'excludeuser' => 'Exclude revisions made by user (enum)',
|
2012-10-13 18:01:38 +00:00
|
|
|
'expandtemplates' => "Expand templates in revision content (requires {$p}prop=content)",
|
|
|
|
|
'generatexml' => "Generate XML parse tree for revision content (requires {$p}prop=content)",
|
|
|
|
|
'parse' => array( "Parse revision content (requires {$p}prop=content).",
|
|
|
|
|
'For performance reasons if this option is used, rvlimit is enforced to 1.' ),
|
2010-05-10 18:27:58 +00:00
|
|
|
'section' => 'Only retrieve the content of this section number',
|
2007-12-01 15:08:57 +00:00
|
|
|
'token' => 'Which tokens to obtain for each revision',
|
* API: BREAKING CHANGE: (bug 11430) Return fewer results than the limit in some cases to prevent running out of memory
* This means queries could possibly return fewer results than the limit and still set a query-continue
* Add iicontinue, rvcontinue, cicontinue, incontinue, amfrom to faciliate query-continue for these modules
* Implemented by blocking additions to the ApiResult object if they would make it too large
** Important things like query-continue values and warnings are exempt from this check
** RSS feeds and exported XML are also exempted (size-checking them would be too messy)
** Result size is checked against $wgAPIMaxResultSize, which defaults to 8 MB
For those who really care, per-file details follow:
ApiResult.php:
* Introduced ApiResult::$mSize which keeps track of the result size.
* Introduced ApiResult::size() which calculates an array's size
(which is the sum of the strlen()s of its elements).
* ApiResult::addValue() now checks that the result size stays below
$wgAPIMaxResultSize. If the item won't fit, it won't be added and addValue()
will return false. Callers should check the return value and set a
query-continue if it's false.
* Closed the back door that is ApiResult::getData(): callers can't manipulate
the data array directly anymore so they can't bypass the result size limit.
* Added ApiResult::setIndexedTagName_internal() which will call
setIndexedTagName() on an array already in the result. This is needed for the
'new' order of adding results, which means addValue()ing one result at a time
until you hit the limit or run out, then calling this function to set the tag
name.
* Added ApiResult::disableSizeCheck() and enableSizeCheck() which disable and
enable size checking in addValue(). This is used for stuff like query-continue
elements and warnings which shouldn't count towards the result size.
* Added ApiResult::unsetValue() which removes an element from the result and
decreases $mSize.
ApiBase.php:
* Like ApiResult::getData(), ApiBase::getResultData() no longer returns a
reference.
* Use ApiResult::disableSizeCheck() in ApiBase::setWarning()
ApiQueryBase.php:
* Added ApiQueryBase::addPageSubItem(), which adds page subitems one item
at a time.
* addPageSubItem() and addPageSubItems() now return whether the subitem
fit in the result.
* Use ApiResult::disableSizeCheck() in setContinueEnumParameter()
ApiMain.php:
* Use ApiResult::disableSizeCheck() in ApiMain::substituteResultWithError()
* Use getParameter() rather than $mRequest to obtain requestid
DefaultSettings.php:
* Added $wgAPIMaxResultSize, with a default value of 8 MB
ApiQuery*.php:
* Added results one at a time, and set a query-continue if the result is full.
ApiQueryLangLinks.php and friends:
* Migrated from addPageSubItems() to addPageSubItem(). This eliminates the
need for $lastId.
ApiQueryAllLinks.php, ApiQueryWatchlist.php, ApiQueryAllimages.php, ApiQuerySearch.php:
* Renamed $data to something more appropriate ($pageids, $ids or $titles)
ApiQuerySiteinfo.php:
* Abuse siprop as a query-continue parameter and set it to all props that
couldn't be processed.
ApiQueryRandom.php:
* Doesn't do continuations, because the result is supposed to be random.
* Be smart enough to not run the second query if the results of the first
didn't fit.
ApiQueryImageInfo.php, ApiQueryRevisions.php, ApiQueryCategoryInfo.php, ApiQueryInfo.php:
* Added continue parameter which basically skips the first so many items
ApiQueryBacklinks.php:
* Throw the result in a big array first and addValue() that one element at a time if necessary
** This is necessary because the results aren't retrieved in order
* Introduced $this->pageMap to map namespace and title to page ID
* Rewritten extractRowInfo() and extractRedirRowInfo() a little
* Declared all private member variables explicitly
ApiQueryDeletedrevs.php:
* Use a pagemap just like in Backlinks
* Introduce fake page IDs and keep track of them so we know where to add what
** This doesn't change the output format, because the fake page IDs start at 0 and are consecutive
ApiQueryAllmessages.php:
* Add amfrom to facilitate query-continue
ApiQueryUsers.php:
* Rewrite: put the getOtherUsersInfo() code in execute()
2009-02-05 14:30:59 +00:00
|
|
|
'continue' => 'When more results are available, use this to continue',
|
2010-01-11 15:55:52 +00:00
|
|
|
'diffto' => array( 'Revision ID to diff each revision to.',
|
2010-05-11 22:30:18 +00:00
|
|
|
'Use "prev", "next" and "cur" for the previous, next and current revision respectively' ),
|
2013-11-14 13:58:14 +00:00
|
|
|
'difftotext' => array(
|
|
|
|
|
'Text to diff each revision to. Only diffs a limited number of revisions.',
|
|
|
|
|
"Overrides {$p}diffto. If {$p}section is set, only that section will be",
|
|
|
|
|
'diffed against this text',
|
|
|
|
|
),
|
2009-11-02 08:29:26 +00:00
|
|
|
'tag' => 'Only list revisions tagged with this tag',
|
2012-06-13 09:58:05 +00:00
|
|
|
'contentformat' => 'Serialization format used for difftotext and expected for output of content',
|
2006-10-01 20:17:16 +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() {
|
|
|
|
|
$props = array(
|
|
|
|
|
'' => array(),
|
|
|
|
|
'ids' => array(
|
|
|
|
|
'revid' => 'integer',
|
|
|
|
|
'parentid' => array(
|
|
|
|
|
ApiBase::PROP_TYPE => 'integer',
|
|
|
|
|
ApiBase::PROP_NULLABLE => true
|
|
|
|
|
)
|
|
|
|
|
),
|
|
|
|
|
'flags' => array(
|
|
|
|
|
'minor' => 'boolean'
|
|
|
|
|
),
|
|
|
|
|
'user' => array(
|
|
|
|
|
'userhidden' => 'boolean',
|
|
|
|
|
'user' => 'string',
|
|
|
|
|
'anon' => 'boolean'
|
|
|
|
|
),
|
|
|
|
|
'userid' => array(
|
|
|
|
|
'userhidden' => 'boolean',
|
|
|
|
|
'userid' => 'integer',
|
|
|
|
|
'anon' => 'boolean'
|
|
|
|
|
),
|
|
|
|
|
'timestamp' => array(
|
|
|
|
|
'timestamp' => 'timestamp'
|
|
|
|
|
),
|
|
|
|
|
'size' => array(
|
|
|
|
|
'size' => 'integer'
|
|
|
|
|
),
|
|
|
|
|
'sha1' => array(
|
|
|
|
|
'sha1' => 'string'
|
|
|
|
|
),
|
|
|
|
|
'comment' => array(
|
|
|
|
|
'commenthidden' => 'boolean',
|
|
|
|
|
'comment' => array(
|
|
|
|
|
ApiBase::PROP_TYPE => 'string',
|
|
|
|
|
ApiBase::PROP_NULLABLE => true
|
|
|
|
|
)
|
|
|
|
|
),
|
|
|
|
|
'parsedcomment' => array(
|
|
|
|
|
'commenthidden' => 'boolean',
|
|
|
|
|
'parsedcomment' => array(
|
|
|
|
|
ApiBase::PROP_TYPE => 'string',
|
|
|
|
|
ApiBase::PROP_NULLABLE => true
|
|
|
|
|
)
|
|
|
|
|
),
|
|
|
|
|
'content' => array(
|
|
|
|
|
'*' => array(
|
|
|
|
|
ApiBase::PROP_TYPE => 'string',
|
|
|
|
|
ApiBase::PROP_NULLABLE => true
|
|
|
|
|
),
|
2012-12-13 16:50:45 +00:00
|
|
|
'texthidden' => 'boolean',
|
|
|
|
|
'textmissing' => 'boolean',
|
2012-10-31 18:44:48 +00:00
|
|
|
),
|
|
|
|
|
'contentmodel' => array(
|
|
|
|
|
'contentmodel' => 'string'
|
|
|
|
|
),
|
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
|
|
|
);
|
|
|
|
|
|
|
|
|
|
self::addTokenProperties( $props, $this->getTokenFunctions() );
|
|
|
|
|
|
|
|
|
|
return $props;
|
|
|
|
|
}
|
|
|
|
|
|
2008-01-28 19:05:26 +00:00
|
|
|
public function getDescription() {
|
2010-02-24 14:45:19 +00:00
|
|
|
return array(
|
2014-03-09 20:22:47 +00:00
|
|
|
'Get revision information.',
|
2011-04-25 14:05:57 +00:00
|
|
|
'May be used in several ways:',
|
2014-03-09 20:22:47 +00:00
|
|
|
' 1) Get data about a set of pages (last revision), by setting titles or pageids parameter.',
|
|
|
|
|
' 2) Get revisions for one given page, by using titles/pageids with start/end/limit params.',
|
|
|
|
|
' 3) Get data about a set of revisions by setting their IDs with revids parameter.',
|
|
|
|
|
'All parameters marked as (enum) may only be used with a single page (#2).'
|
2006-09-30 08:06:27 +00:00
|
|
|
);
|
2006-09-26 05:43:02 +00:00
|
|
|
}
|
2010-02-24 14:45:19 +00:00
|
|
|
|
2010-02-14 14:29:24 +00:00
|
|
|
public function getPossibleErrors() {
|
2010-02-13 00:28:27 +00:00
|
|
|
return array_merge( parent::getPossibleErrors(), array(
|
|
|
|
|
array( 'nosuchrevid', 'diffto' ),
|
2013-11-14 13:58:14 +00:00
|
|
|
array(
|
|
|
|
|
'code' => 'revids',
|
|
|
|
|
'info' => 'The revids= parameter may not be used with the list options '
|
|
|
|
|
. '(limit, startid, endid, dirNewer, start, end).'
|
|
|
|
|
),
|
|
|
|
|
array(
|
|
|
|
|
'code' => 'multpages',
|
|
|
|
|
'info' => 'titles, pageids or a generator was used to supply multiple pages, '
|
|
|
|
|
. ' but the limit, startid, endid, dirNewer, user, excludeuser, '
|
|
|
|
|
. 'start and end parameters may only be used on a single page.'
|
|
|
|
|
),
|
|
|
|
|
array(
|
|
|
|
|
'code' => 'diffto',
|
|
|
|
|
'info' => 'rvdiffto must be set to a non-negative number, "prev", "next" or "cur"'
|
|
|
|
|
),
|
2010-02-13 01:28:26 +00:00
|
|
|
array( 'code' => 'badparams', 'info' => 'start and startid cannot be used together' ),
|
|
|
|
|
array( 'code' => 'badparams', 'info' => 'end and endid cannot be used together' ),
|
|
|
|
|
array( 'code' => 'badparams', 'info' => 'user and excludeuser cannot be used together' ),
|
|
|
|
|
array( 'code' => 'nosuchsection', 'info' => 'There is no section section in rID' ),
|
2012-08-20 19:33:07 +00:00
|
|
|
array( 'code' => 'badformat', 'info' => 'The requested serialization format can not be applied '
|
2013-11-14 13:00:02 +00:00
|
|
|
. ' to the page\'s content model' ),
|
2010-02-14 14:29:24 +00:00
|
|
|
) );
|
2010-02-13 00:28:27 +00:00
|
|
|
}
|
2006-09-26 05:43:02 +00:00
|
|
|
|
2011-08-17 22:24:21 +00:00
|
|
|
public function getExamples() {
|
2010-02-24 14:45:19 +00:00
|
|
|
return array(
|
2011-12-27 16:22:35 +00:00
|
|
|
'Get data with content for the last revision of titles "API" and "Main Page"',
|
2013-11-14 13:58:14 +00:00
|
|
|
' api.php?action=query&prop=revisions&titles=API|Main%20Page&' .
|
|
|
|
|
'rvprop=timestamp|user|comment|content',
|
2011-12-27 16:22:35 +00:00
|
|
|
'Get last 5 revisions of the "Main Page"',
|
2013-11-14 13:58:14 +00:00
|
|
|
' api.php?action=query&prop=revisions&titles=Main%20Page&rvlimit=5&' .
|
|
|
|
|
'rvprop=timestamp|user|comment',
|
2011-12-27 16:22:35 +00:00
|
|
|
'Get first 5 revisions of the "Main Page"',
|
2013-11-14 13:58:14 +00:00
|
|
|
' api.php?action=query&prop=revisions&titles=Main%20Page&rvlimit=5&' .
|
|
|
|
|
'rvprop=timestamp|user|comment&rvdir=newer',
|
2011-12-27 16:22:35 +00:00
|
|
|
'Get first 5 revisions of the "Main Page" made after 2006-05-01',
|
2013-11-14 13:58:14 +00:00
|
|
|
' api.php?action=query&prop=revisions&titles=Main%20Page&rvlimit=5&' .
|
|
|
|
|
'rvprop=timestamp|user|comment&rvdir=newer&rvstart=20060501000000',
|
2007-05-19 04:13:48 +00:00
|
|
|
'Get first 5 revisions of the "Main Page" that were not made made by anonymous user "127.0.0.1"',
|
2013-11-14 13:58:14 +00:00
|
|
|
' api.php?action=query&prop=revisions&titles=Main%20Page&rvlimit=5&' .
|
|
|
|
|
'rvprop=timestamp|user|comment&rvexcludeuser=127.0.0.1',
|
2007-05-19 04:13:48 +00:00
|
|
|
'Get first 5 revisions of the "Main Page" that were made by the user "MediaWiki default"',
|
2013-11-14 13:58:14 +00:00
|
|
|
' api.php?action=query&prop=revisions&titles=Main%20Page&rvlimit=5&' .
|
|
|
|
|
'rvprop=timestamp|user|comment&rvuser=MediaWiki%20default',
|
2006-09-26 05:43:02 +00:00
|
|
|
);
|
|
|
|
|
}
|
2006-10-01 21:20:55 +00:00
|
|
|
|
2011-07-17 16:51:11 +00:00
|
|
|
public function getHelpUrls() {
|
2011-11-28 15:43:11 +00:00
|
|
|
return 'https://www.mediawiki.org/wiki/API:Properties#revisions_.2F_rv';
|
2011-07-17 16:51:11 +00:00
|
|
|
}
|
2006-09-26 05:43:02 +00:00
|
|
|
}
|