<?php
-
/**
- * Created on Sep 7, 2006
- *
* API for MediaWiki 1.8+
*
+ * Created on Sep 7, 2006
+ *
* Copyright © 2006 Yuri Astrakhan <Firstname><Lastname>@gmail.com
*
* This program is free software; you can redistribute it and/or modify
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* http://www.gnu.org/copyleft/gpl.html
+ *
+ * @file
*/
if ( !defined( 'MEDIAWIKI' ) ) {
}
private $fld_ids = false, $fld_flags = false, $fld_timestamp = false, $fld_size = false,
- $fld_comment = false, $fld_parsedcomment = false, $fld_user = false, $fld_content = false, $fld_tags = false;
+ $fld_comment = false, $fld_parsedcomment = false, $fld_user = false, $fld_userid = false,
+ $fld_content = false, $fld_tags = false;
protected function getTokenFunctions() {
// tokenname => function
}
$db = $this->getDB();
- $this->addTables( array( 'page', 'revision' ) );
+ $this->addTables( 'page' );
$this->addFields( Revision::selectFields() );
$this->addWhere( 'page_id = rev_page' );
$this->fld_comment = isset ( $prop['comment'] );
$this->fld_parsedcomment = isset ( $prop['parsedcomment'] );
$this->fld_size = isset ( $prop['size'] );
+ $this->fld_userid = isset( $prop['userid'] );
$this->fld_user = isset ( $prop['user'] );
$this->token = $params['token'];
}
}
+ //Bug 24166 - API error when using rvprop=tags
+ $this->addTables( 'revision' );
+
$userMax = ( $this->fld_content ? ApiBase::LIMIT_SML1 : ApiBase::LIMIT_BIG1 );
$botMax = ( $this->fld_content ? ApiBase::LIMIT_SML2 : ApiBase::LIMIT_BIG2 );
$limit = $params['limit'];
if ( $limit == 'max' ) {
$limit = $this->getMain()->canApiHighLimits() ? $botMax : $userMax;
- $this->getResult()->addValue( 'limits', $this->getModuleName(), $limit );
+ $this->getResult()->setParsedLimit( $this->getModuleName(), $limit );
}
if ( $enumRevMode ) {
$this->addOption( 'LIMIT', $limit + 1 );
$this->addOption( 'USE INDEX', $index );
- $data = array();
$count = 0;
$res = $this->select( __METHOD__ );
$vals['minor'] = '';
}
- if ( $this->fld_user ) {
+ if ( $this->fld_user || $this->fld_userid ) {
if ( $revision->isDeleted( Revision::DELETED_USER ) ) {
$vals['userhidden'] = '';
} else {
- $vals['user'] = $revision->getUserText();
+ if ( $this->fld_user ) {
+ $vals['user'] = $revision->getUserText();
+ }
+ if ( $this->fld_userid ) {
+ $user = User::newFromText( $revision->getUserText() );
+ $vals['userid'] = $user->getId();
+ }
if ( !$revision->getUser() ) {
$vals['anon'] = '';
}
$vals['commenthidden'] = '';
} else {
$comment = $revision->getComment();
-
+
if ( $this->fld_comment ) {
$vals['comment'] = $comment;
}
}
if ( !is_null( $this->token ) ) {
- // Don't cache tokens
- $this->getMain()->setCachePrivate();
-
$tokenFunctions = $this->getTokenFunctions();
foreach ( $this->token as $t ) {
$val = call_user_func( $tokenFunctions[$t], $title->getArticleID(), $title, $revision );
}
$text = null;
+ global $wgParser;
if ( $this->fld_content || !is_null( $this->difftotext ) ) {
$text = $revision->getText();
// Expand templates after getting section content because
// template-added sections don't count and Parser::preprocess()
// will have less input
if ( $this->section !== false ) {
- global $wgParser;
-
$text = $wgParser->getSection( $text, $this->section, false );
if ( $text === false ) {
$this->dieUsage( "There is no section {$this->section} in r" . $revision->getId(), 'nosuchsection' );
}
if ( $this->fld_content && !$revision->isDeleted( Revision::DELETED_TEXT ) ) {
if ( $this->generateXML ) {
- global $wgParser;
$wgParser->startExternalParse( $title, new ParserOptions(), OT_PREPROCESS );
$dom = $wgParser->preprocessToDom( $text );
if ( is_callable( array( $dom, 'saveXML' ) ) ) {
return $vals;
}
+ public function getCacheMode( $params ) {
+ if ( isset( $params['token'] ) ) {
+ return 'private';
+ }
+ if ( !is_null( $params['prop'] ) && in_array( 'parsedcomment', $params['prop'] ) ) {
+ // formatComment() calls wfMsg() among other things
+ return 'anon-public-user-private';
+ }
+ return 'public';
+ }
+
public function getAllowedParams() {
return array(
'prop' => array(
'flags',
'timestamp',
'user',
+ 'userid',
'size',
'comment',
'parsedcomment',
' ids - The ID of the revision',
' flags - Revision flags (minor)',
' timestamp - The timestamp of the revision',
- ' user - Gives user to make the revision',
+ ' user - User that made the revision',
+ ' userid - User id of revision creator',
' size - Length of the revision',
' comment - Comment by the user for revision',
' parsedcomment - Parsed comment by the user for the revision',