MediaWiki  master
ApiQueryRecentChanges.php
Go to the documentation of this file.
00001 <?php
00033 class ApiQueryRecentChanges extends ApiQueryGeneratorBase {
00034 
00035         public function __construct( $query, $moduleName ) {
00036                 parent::__construct( $query, $moduleName, 'rc' );
00037         }
00038 
00039         private $fld_comment = false, $fld_parsedcomment = false, $fld_user = false, $fld_userid = false,
00040                         $fld_flags = false, $fld_timestamp = false, $fld_title = false, $fld_ids = false,
00041                         $fld_sizes = false, $fld_redirect = false, $fld_patrolled = false, $fld_loginfo = false,
00042                         $fld_tags = false, $token = array();
00043 
00044         private $tokenFunctions;
00045 
00052         protected function getTokenFunctions() {
00053                 // Don't call the hooks twice
00054                 if ( isset( $this->tokenFunctions ) ) {
00055                         return $this->tokenFunctions;
00056                 }
00057 
00058                 // If we're in JSON callback mode, no tokens can be obtained
00059                 if ( !is_null( $this->getMain()->getRequest()->getVal( 'callback' ) ) ) {
00060                         return array();
00061                 }
00062 
00063                 $this->tokenFunctions = array(
00064                         'patrol' => array( 'ApiQueryRecentChanges', 'getPatrolToken' )
00065                 );
00066                 wfRunHooks( 'APIQueryRecentChangesTokens', array( &$this->tokenFunctions ) );
00067                 return $this->tokenFunctions;
00068         }
00069 
00076         public static function getPatrolToken( $pageid, $title, $rc = null ) {
00077                 global $wgUser;
00078 
00079                 $validTokenUser = false;
00080 
00081                 if ( $rc ) {
00082                         if ( ( $wgUser->useRCPatrol() && $rc->getAttribute( 'rc_type' ) == RC_EDIT ) ||
00083                                 ( $wgUser->useNPPatrol() && $rc->getAttribute( 'rc_type' ) == RC_NEW ) )
00084                         {
00085                                 $validTokenUser = true;
00086                         }
00087                 } else {
00088                         if ( $wgUser->useRCPatrol() || $wgUser->useNPPatrol() ) {
00089                                 $validTokenUser = true;
00090                         }
00091                 }
00092 
00093                 if ( $validTokenUser ) {
00094                         // The patrol token is always the same, let's exploit that
00095                         static $cachedPatrolToken = null;
00096                         if ( is_null( $cachedPatrolToken ) ) {
00097                                 $cachedPatrolToken = $wgUser->getEditToken( 'patrol' );
00098                         }
00099                         return $cachedPatrolToken;
00100                 } else {
00101                         return false;
00102                 }
00103 
00104         }
00105 
00110         public function initProperties( $prop ) {
00111                 $this->fld_comment = isset( $prop['comment'] );
00112                 $this->fld_parsedcomment = isset( $prop['parsedcomment'] );
00113                 $this->fld_user = isset( $prop['user'] );
00114                 $this->fld_userid = isset( $prop['userid'] );
00115                 $this->fld_flags = isset( $prop['flags'] );
00116                 $this->fld_timestamp = isset( $prop['timestamp'] );
00117                 $this->fld_title = isset( $prop['title'] );
00118                 $this->fld_ids = isset( $prop['ids'] );
00119                 $this->fld_sizes = isset( $prop['sizes'] );
00120                 $this->fld_redirect = isset( $prop['redirect'] );
00121                 $this->fld_patrolled = isset( $prop['patrolled'] );
00122                 $this->fld_loginfo = isset( $prop['loginfo'] );
00123                 $this->fld_tags = isset( $prop['tags'] );
00124         }
00125 
00126         public function execute() {
00127                 $this->run();
00128         }
00129 
00130         public function executeGenerator( $resultPageSet ) {
00131                 $this->run( $resultPageSet );
00132         }
00133 
00139         public function run( $resultPageSet = null ) {
00140                 $user = $this->getUser();
00141                 /* Get the parameters of the request. */
00142                 $params = $this->extractRequestParams();
00143 
00144                 /* Build our basic query. Namely, something along the lines of:
00145                  * SELECT * FROM recentchanges WHERE rc_timestamp > $start
00146                  *              AND rc_timestamp < $end AND rc_namespace = $namespace
00147                  *              AND rc_deleted = 0
00148                  */
00149                 $this->addTables( 'recentchanges' );
00150                 $index = array( 'recentchanges' => 'rc_timestamp' ); // May change
00151                 $this->addTimestampWhereRange( 'rc_timestamp', $params['dir'], $params['start'], $params['end'] );
00152                 $this->addWhereFld( 'rc_namespace', $params['namespace'] );
00153                 $this->addWhereFld( 'rc_deleted', 0 );
00154 
00155                 if ( !is_null( $params['type'] ) ) {
00156                         $this->addWhereFld( 'rc_type', $this->parseRCType( $params['type'] ) );
00157                 }
00158 
00159                 if ( !is_null( $params['show'] ) ) {
00160                         $show = array_flip( $params['show'] );
00161 
00162                         /* Check for conflicting parameters. */
00163                         if ( ( isset( $show['minor'] ) && isset( $show['!minor'] ) )
00164                                         || ( isset( $show['bot'] ) && isset( $show['!bot'] ) )
00165                                         || ( isset( $show['anon'] ) && isset( $show['!anon'] ) )
00166                                         || ( isset( $show['redirect'] ) && isset( $show['!redirect'] ) )
00167                                         || ( isset( $show['patrolled'] ) && isset( $show['!patrolled'] ) )
00168                         ) {
00169                                 $this->dieUsageMsg( 'show' );
00170                         }
00171 
00172                         // Check permissions
00173                         if ( isset( $show['patrolled'] ) || isset( $show['!patrolled'] ) ) {
00174                                 if ( !$user->useRCPatrol() && !$user->useNPPatrol() ) {
00175                                         $this->dieUsage( 'You need the patrol right to request the patrolled flag', 'permissiondenied' );
00176                                 }
00177                         }
00178 
00179                         /* Add additional conditions to query depending upon parameters. */
00180                         $this->addWhereIf( 'rc_minor = 0', isset( $show['!minor'] ) );
00181                         $this->addWhereIf( 'rc_minor != 0', isset( $show['minor'] ) );
00182                         $this->addWhereIf( 'rc_bot = 0', isset( $show['!bot'] ) );
00183                         $this->addWhereIf( 'rc_bot != 0', isset( $show['bot'] ) );
00184                         $this->addWhereIf( 'rc_user = 0', isset( $show['anon'] ) );
00185                         $this->addWhereIf( 'rc_user != 0', isset( $show['!anon'] ) );
00186                         $this->addWhereIf( 'rc_patrolled = 0', isset( $show['!patrolled'] ) );
00187                         $this->addWhereIf( 'rc_patrolled != 0', isset( $show['patrolled'] ) );
00188                         $this->addWhereIf( 'page_is_redirect = 1', isset( $show['redirect'] ) );
00189 
00190                         // Don't throw log entries out the window here
00191                         $this->addWhereIf( 'page_is_redirect = 0 OR page_is_redirect IS NULL', isset( $show['!redirect'] ) );
00192                 }
00193 
00194                 if ( !is_null( $params['user'] ) && !is_null( $params['excludeuser'] ) ) {
00195                         $this->dieUsage( 'user and excludeuser cannot be used together', 'user-excludeuser' );
00196                 }
00197 
00198                 if ( !is_null( $params['user'] ) ) {
00199                         $this->addWhereFld( 'rc_user_text', $params['user'] );
00200                         $index['recentchanges'] = 'rc_user_text';
00201                 }
00202 
00203                 if ( !is_null( $params['excludeuser'] ) ) {
00204                         // We don't use the rc_user_text index here because
00205                         // * it would require us to sort by rc_user_text before rc_timestamp
00206                         // * the != condition doesn't throw out too many rows anyway
00207                         $this->addWhere( 'rc_user_text != ' . $this->getDB()->addQuotes( $params['excludeuser'] ) );
00208                 }
00209 
00210                 /* Add the fields we're concerned with to our query. */
00211                 $this->addFields( array(
00212                         'rc_timestamp',
00213                         'rc_namespace',
00214                         'rc_title',
00215                         'rc_cur_id',
00216                         'rc_type',
00217                         'rc_deleted'
00218                 ) );
00219 
00220                 $showRedirects = false;
00221                 /* Determine what properties we need to display. */
00222                 if ( !is_null( $params['prop'] ) ) {
00223                         $prop = array_flip( $params['prop'] );
00224 
00225                         /* Set up internal members based upon params. */
00226                         $this->initProperties( $prop );
00227 
00228                         if ( $this->fld_patrolled && !$user->useRCPatrol() && !$user->useNPPatrol() ) {
00229                                 $this->dieUsage( 'You need the patrol right to request the patrolled flag', 'permissiondenied' );
00230                         }
00231 
00232                         /* Add fields to our query if they are specified as a needed parameter. */
00233                         $this->addFieldsIf( array( 'rc_id', 'rc_this_oldid', 'rc_last_oldid' ), $this->fld_ids );
00234                         $this->addFieldsIf( 'rc_comment', $this->fld_comment || $this->fld_parsedcomment );
00235                         $this->addFieldsIf( 'rc_user', $this->fld_user );
00236                         $this->addFieldsIf( 'rc_user_text', $this->fld_user || $this->fld_userid );
00237                         $this->addFieldsIf( array( 'rc_minor', 'rc_type', 'rc_bot' ) , $this->fld_flags );
00238                         $this->addFieldsIf( array( 'rc_old_len', 'rc_new_len' ), $this->fld_sizes );
00239                         $this->addFieldsIf( 'rc_patrolled', $this->fld_patrolled );
00240                         $this->addFieldsIf( array( 'rc_logid', 'rc_log_type', 'rc_log_action', 'rc_params' ), $this->fld_loginfo );
00241                         $showRedirects = $this->fld_redirect || isset( $show['redirect'] ) || isset( $show['!redirect'] );
00242                 }
00243 
00244                 if ( $this->fld_tags ) {
00245                         $this->addTables( 'tag_summary' );
00246                         $this->addJoinConds( array( 'tag_summary' => array( 'LEFT JOIN', array( 'rc_id=ts_rc_id' ) ) ) );
00247                         $this->addFields( 'ts_tags' );
00248                 }
00249 
00250                 if ( $params['toponly'] || $showRedirects ) {
00251                         $this->addTables( 'page' );
00252                         $this->addJoinConds( array( 'page' => array( 'LEFT JOIN', array( 'rc_namespace=page_namespace', 'rc_title=page_title' ) ) ) );
00253                         $this->addFields( 'page_is_redirect' );
00254 
00255                         if ( $params['toponly'] ) {
00256                                 $this->addWhere( 'rc_this_oldid = page_latest' );
00257                         }
00258                 }
00259 
00260                 if ( !is_null( $params['tag'] ) ) {
00261                         $this->addTables( 'change_tag' );
00262                         $this->addJoinConds( array( 'change_tag' => array( 'INNER JOIN', array( 'rc_id=ct_rc_id' ) ) ) );
00263                         $this->addWhereFld( 'ct_tag' , $params['tag'] );
00264                         global $wgOldChangeTagsIndex;
00265                         $index['change_tag'] = $wgOldChangeTagsIndex ? 'ct_tag' : 'change_tag_tag_id';
00266                 }
00267 
00268                 $this->token = $params['token'];
00269                 $this->addOption( 'LIMIT', $params['limit'] + 1 );
00270                 $this->addOption( 'USE INDEX', $index );
00271 
00272                 $count = 0;
00273                 /* Perform the actual query. */
00274                 $res = $this->select( __METHOD__ );
00275 
00276                 $titles = array();
00277 
00278                 $result = $this->getResult();
00279 
00280                 /* Iterate through the rows, adding data extracted from them to our query result. */
00281                 foreach ( $res as $row ) {
00282                         if ( ++ $count > $params['limit'] ) {
00283                                 // We've reached the one extra which shows that there are additional pages to be had. Stop here...
00284                                 $this->setContinueEnumParameter( 'start', wfTimestamp( TS_ISO_8601, $row->rc_timestamp ) );
00285                                 break;
00286                         }
00287 
00288                         if ( is_null( $resultPageSet ) ) {
00289                                 /* Extract the data from a single row. */
00290                                 $vals = $this->extractRowInfo( $row );
00291 
00292                                 /* Add that row's data to our final output. */
00293                                 if ( !$vals ) {
00294                                         continue;
00295                                 }
00296                                 $fit = $result->addValue( array( 'query', $this->getModuleName() ), null, $vals );
00297                                 if ( !$fit ) {
00298                                         $this->setContinueEnumParameter( 'start', wfTimestamp( TS_ISO_8601, $row->rc_timestamp ) );
00299                                         break;
00300                                 }
00301                         } else {
00302                                 $titles[] = Title::makeTitle( $row->rc_namespace, $row->rc_title );
00303                         }
00304                 }
00305 
00306                 if ( is_null( $resultPageSet ) ) {
00307                         /* Format the result */
00308                         $result->setIndexedTagName_internal( array( 'query', $this->getModuleName() ), 'rc' );
00309                 } else {
00310                         $resultPageSet->populateFromTitles( $titles );
00311                 }
00312         }
00313 
00321         public function extractRowInfo( $row ) {
00322                 /* Determine the title of the page that has been changed. */
00323                 $title = Title::makeTitle( $row->rc_namespace, $row->rc_title );
00324 
00325                 /* Our output data. */
00326                 $vals = array();
00327 
00328                 $type = intval( $row->rc_type );
00329 
00330                 /* Determine what kind of change this was. */
00331                 switch ( $type ) {
00332                         case RC_EDIT:
00333                                 $vals['type'] = 'edit';
00334                                 break;
00335                         case RC_NEW:
00336                                 $vals['type'] = 'new';
00337                                 break;
00338                         case RC_MOVE:
00339                                 $vals['type'] = 'move';
00340                                 break;
00341                         case RC_LOG:
00342                                 $vals['type'] = 'log';
00343                                 break;
00344                         case RC_MOVE_OVER_REDIRECT:
00345                                 $vals['type'] = 'move over redirect';
00346                                 break;
00347                         default:
00348                                 $vals['type'] = $type;
00349                 }
00350 
00351                 /* Create a new entry in the result for the title. */
00352                 if ( $this->fld_title ) {
00353                         ApiQueryBase::addTitleInfo( $vals, $title );
00354                 }
00355 
00356                 /* Add ids, such as rcid, pageid, revid, and oldid to the change's info. */
00357                 if ( $this->fld_ids ) {
00358                         $vals['rcid'] = intval( $row->rc_id );
00359                         $vals['pageid'] = intval( $row->rc_cur_id );
00360                         $vals['revid'] = intval( $row->rc_this_oldid );
00361                         $vals['old_revid'] = intval( $row->rc_last_oldid );
00362                 }
00363 
00364                 /* Add user data and 'anon' flag, if use is anonymous. */
00365                 if ( $this->fld_user || $this->fld_userid ) {
00366 
00367                         if ( $this->fld_user ) {
00368                                 $vals['user'] = $row->rc_user_text;
00369                         }
00370 
00371                         if ( $this->fld_userid ) {
00372                                 $vals['userid'] = $row->rc_user;
00373                         }
00374 
00375                         if ( !$row->rc_user ) {
00376                                 $vals['anon'] = '';
00377                         }
00378                 }
00379 
00380                 /* Add flags, such as new, minor, bot. */
00381                 if ( $this->fld_flags ) {
00382                         if ( $row->rc_bot ) {
00383                                 $vals['bot'] = '';
00384                         }
00385                         if ( $row->rc_type == RC_NEW ) {
00386                                 $vals['new'] = '';
00387                         }
00388                         if ( $row->rc_minor ) {
00389                                 $vals['minor'] = '';
00390                         }
00391                 }
00392 
00393                 /* Add sizes of each revision. (Only available on 1.10+) */
00394                 if ( $this->fld_sizes ) {
00395                         $vals['oldlen'] = intval( $row->rc_old_len );
00396                         $vals['newlen'] = intval( $row->rc_new_len );
00397                 }
00398 
00399                 /* Add the timestamp. */
00400                 if ( $this->fld_timestamp ) {
00401                         $vals['timestamp'] = wfTimestamp( TS_ISO_8601, $row->rc_timestamp );
00402                 }
00403 
00404                 /* Add edit summary / log summary. */
00405                 if ( $this->fld_comment && isset( $row->rc_comment ) ) {
00406                         $vals['comment'] = $row->rc_comment;
00407                 }
00408 
00409                 if ( $this->fld_parsedcomment && isset( $row->rc_comment ) ) {
00410                         $vals['parsedcomment'] = Linker::formatComment( $row->rc_comment, $title );
00411                 }
00412 
00413                 if ( $this->fld_redirect ) {
00414                         if ( $row->page_is_redirect ) {
00415                                 $vals['redirect'] = '';
00416                         }
00417                 }
00418 
00419                 /* Add the patrolled flag */
00420                 if ( $this->fld_patrolled && $row->rc_patrolled == 1 ) {
00421                         $vals['patrolled'] = '';
00422                 }
00423 
00424                 if ( $this->fld_loginfo && $row->rc_type == RC_LOG ) {
00425                         $vals['logid'] = intval( $row->rc_logid );
00426                         $vals['logtype'] = $row->rc_log_type;
00427                         $vals['logaction'] = $row->rc_log_action;
00428                         $logEntry = DatabaseLogEntry::newFromRow( (array)$row );
00429                         ApiQueryLogEvents::addLogParams(
00430                                 $this->getResult(),
00431                                 $vals,
00432                                 $logEntry->getParameters(),
00433                                 $logEntry->getType(),
00434                                 $logEntry->getSubtype(),
00435                                 $logEntry->getTimestamp()
00436                         );
00437                 }
00438 
00439                 if ( $this->fld_tags ) {
00440                         if ( $row->ts_tags ) {
00441                                 $tags = explode( ',', $row->ts_tags );
00442                                 $this->getResult()->setIndexedTagName( $tags, 'tag' );
00443                                 $vals['tags'] = $tags;
00444                         } else {
00445                                 $vals['tags'] = array();
00446                         }
00447                 }
00448 
00449                 if ( !is_null( $this->token ) ) {
00450                         $tokenFunctions = $this->getTokenFunctions();
00451                         foreach ( $this->token as $t ) {
00452                                 $val = call_user_func( $tokenFunctions[$t], $row->rc_cur_id,
00453                                         $title, RecentChange::newFromRow( $row ) );
00454                                 if ( $val === false ) {
00455                                         $this->setWarning( "Action '$t' is not allowed for the current user" );
00456                                 } else {
00457                                         $vals[$t . 'token'] = $val;
00458                                 }
00459                         }
00460                 }
00461 
00462                 return $vals;
00463         }
00464 
00465         private function parseRCType( $type ) {
00466                 if ( is_array( $type ) ) {
00467                         $retval = array();
00468                         foreach ( $type as $t ) {
00469                                 $retval[] = $this->parseRCType( $t );
00470                         }
00471                         return $retval;
00472                 }
00473                 switch( $type ) {
00474                         case 'edit':
00475                                 return RC_EDIT;
00476                         case 'new':
00477                                 return RC_NEW;
00478                         case 'log':
00479                                 return RC_LOG;
00480                 }
00481         }
00482 
00483         public function getCacheMode( $params ) {
00484                 if ( isset( $params['show'] ) ) {
00485                         foreach ( $params['show'] as $show ) {
00486                                 if ( $show === 'patrolled' || $show === '!patrolled' ) {
00487                                         return 'private';
00488                                 }
00489                         }
00490                 }
00491                 if ( isset( $params['token'] ) ) {
00492                         return 'private';
00493                 }
00494                 if ( !is_null( $params['prop'] ) && in_array( 'parsedcomment', $params['prop'] ) ) {
00495                         // formatComment() calls wfMessage() among other things
00496                         return 'anon-public-user-private';
00497                 }
00498                 return 'public';
00499         }
00500 
00501         public function getAllowedParams() {
00502                 return array(
00503                         'start' => array(
00504                                 ApiBase::PARAM_TYPE => 'timestamp'
00505                         ),
00506                         'end' => array(
00507                                 ApiBase::PARAM_TYPE => 'timestamp'
00508                         ),
00509                         'dir' => array(
00510                                 ApiBase::PARAM_DFLT => 'older',
00511                                 ApiBase::PARAM_TYPE => array(
00512                                         'newer',
00513                                         'older'
00514                                 )
00515                         ),
00516                         'namespace' => array(
00517                                 ApiBase::PARAM_ISMULTI => true,
00518                                 ApiBase::PARAM_TYPE => 'namespace'
00519                         ),
00520                         'user' => array(
00521                                 ApiBase::PARAM_TYPE => 'user'
00522                         ),
00523                         'excludeuser' => array(
00524                                 ApiBase::PARAM_TYPE => 'user'
00525                         ),
00526                         'tag' => null,
00527                         'prop' => array(
00528                                 ApiBase::PARAM_ISMULTI => true,
00529                                 ApiBase::PARAM_DFLT => 'title|timestamp|ids',
00530                                 ApiBase::PARAM_TYPE => array(
00531                                         'user',
00532                                         'userid',
00533                                         'comment',
00534                                         'parsedcomment',
00535                                         'flags',
00536                                         'timestamp',
00537                                         'title',
00538                                         'ids',
00539                                         'sizes',
00540                                         'redirect',
00541                                         'patrolled',
00542                                         'loginfo',
00543                                         'tags'
00544                                 )
00545                         ),
00546                         'token' => array(
00547                                 ApiBase::PARAM_TYPE => array_keys( $this->getTokenFunctions() ),
00548                                 ApiBase::PARAM_ISMULTI => true
00549                         ),
00550                         'show' => array(
00551                                 ApiBase::PARAM_ISMULTI => true,
00552                                 ApiBase::PARAM_TYPE => array(
00553                                         'minor',
00554                                         '!minor',
00555                                         'bot',
00556                                         '!bot',
00557                                         'anon',
00558                                         '!anon',
00559                                         'redirect',
00560                                         '!redirect',
00561                                         'patrolled',
00562                                         '!patrolled'
00563                                 )
00564                         ),
00565                         'limit' => array(
00566                                 ApiBase::PARAM_DFLT => 10,
00567                                 ApiBase::PARAM_TYPE => 'limit',
00568                                 ApiBase::PARAM_MIN => 1,
00569                                 ApiBase::PARAM_MAX => ApiBase::LIMIT_BIG1,
00570                                 ApiBase::PARAM_MAX2 => ApiBase::LIMIT_BIG2
00571                         ),
00572                         'type' => array(
00573                                 ApiBase::PARAM_ISMULTI => true,
00574                                 ApiBase::PARAM_TYPE => array(
00575                                         'edit',
00576                                         'new',
00577                                         'log'
00578                                 )
00579                         ),
00580                         'toponly' => false,
00581                 );
00582         }
00583 
00584         public function getParamDescription() {
00585                 $p = $this->getModulePrefix();
00586                 return array(
00587                         'start' => 'The timestamp to start enumerating from',
00588                         'end' => 'The timestamp to end enumerating',
00589                         'dir' => $this->getDirectionDescription( $p ),
00590                         'namespace' => 'Filter log entries to only this namespace(s)',
00591                         'user' => 'Only list changes by this user',
00592                         'excludeuser' => 'Don\'t list changes by this user',
00593                         'prop' => array(
00594                                 'Include additional pieces of information',
00595                                 ' user           - Adds the user responsible for the edit and tags if they are an IP',
00596                                 ' userid         - Adds the user id responsible for the edit',
00597                                 ' comment        - Adds the comment for the edit',
00598                                 ' parsedcomment  - Adds the parsed comment for the edit',
00599                                 ' flags          - Adds flags for the edit',
00600                                 ' timestamp      - Adds timestamp of the edit',
00601                                 ' title          - Adds the page title of the edit',
00602                                 ' ids            - Adds the page ID, recent changes ID and the new and old revision ID',
00603                                 ' sizes          - Adds the new and old page length in bytes',
00604                                 ' redirect       - Tags edit if page is a redirect',
00605                                 ' patrolled      - Tags edits that have been patrolled',
00606                                 ' loginfo        - Adds log information (logid, logtype, etc) to log entries',
00607                                 ' tags           - Lists tags for the entry',
00608                         ),
00609                         'token' => 'Which tokens to obtain for each change',
00610                         'show' => array(
00611                                 'Show only items that meet this criteria.',
00612                                 "For example, to see only minor edits done by logged-in users, set {$p}show=minor|!anon"
00613                         ),
00614                         'type' => 'Which types of changes to show',
00615                         'limit' => 'How many total changes to return',
00616                         'tag' => 'Only list changes tagged with this tag',
00617                         'toponly' => 'Only list changes which are the latest revision',
00618                 );
00619         }
00620 
00621         public function getResultProperties() {
00622                 global $wgLogTypes;
00623                 $props = array(
00624                         '' => array(
00625                                 'type' => array(
00626                                         ApiBase::PROP_TYPE => array(
00627                                                 'edit',
00628                                                 'new',
00629                                                 'move',
00630                                                 'log',
00631                                                 'move over redirect'
00632                                         )
00633                                 )
00634                         ),
00635                         'title' => array(
00636                                 'ns' => 'namespace',
00637                                 'title' => 'string',
00638                                 'new_ns' => array(
00639                                         ApiBase::PROP_TYPE => 'namespace',
00640                                         ApiBase::PROP_NULLABLE => true
00641                                 ),
00642                                 'new_title' => array(
00643                                         ApiBase::PROP_TYPE => 'string',
00644                                         ApiBase::PROP_NULLABLE => true
00645                                 )
00646                         ),
00647                         'ids' => array(
00648                                 'rcid' => 'integer',
00649                                 'pageid' => 'integer',
00650                                 'revid' => 'integer',
00651                                 'old_revid' => 'integer'
00652                         ),
00653                         'user' => array(
00654                                 'user' => 'string',
00655                                 'anon' => 'boolean'
00656                         ),
00657                         'userid' => array(
00658                                 'userid' => 'integer',
00659                                 'anon' => 'boolean'
00660                         ),
00661                         'flags' => array(
00662                                 'bot' => 'boolean',
00663                                 'new' => 'boolean',
00664                                 'minor' => 'boolean'
00665                         ),
00666                         'sizes' => array(
00667                                 'oldlen' => 'integer',
00668                                 'newlen' => 'integer'
00669                         ),
00670                         'timestamp' => array(
00671                                 'timestamp' => 'timestamp'
00672                         ),
00673                         'comment' => array(
00674                                 'comment' => array(
00675                                         ApiBase::PROP_TYPE => 'string',
00676                                         ApiBase::PROP_NULLABLE => true
00677                                 )
00678                         ),
00679                         'parsedcomment' => array(
00680                                 'parsedcomment' => array(
00681                                         ApiBase::PROP_TYPE => 'string',
00682                                         ApiBase::PROP_NULLABLE => true
00683                                 )
00684                         ),
00685                         'redirect' => array(
00686                                 'redirect' => 'boolean'
00687                         ),
00688                         'patrolled' => array(
00689                                 'patrolled' => 'boolean'
00690                         ),
00691                         'loginfo' => array(
00692                                 'logid' => array(
00693                                         ApiBase::PROP_TYPE => 'integer',
00694                                         ApiBase::PROP_NULLABLE => true
00695                                 ),
00696                                 'logtype' => array(
00697                                         ApiBase::PROP_TYPE => $wgLogTypes,
00698                                         ApiBase::PROP_NULLABLE => true
00699                                 ),
00700                                 'logaction' => array(
00701                                         ApiBase::PROP_TYPE => 'string',
00702                                         ApiBase::PROP_NULLABLE => true
00703                                 )
00704                         )
00705                 );
00706 
00707                 self::addTokenProperties( $props, $this->getTokenFunctions() );
00708 
00709                 return $props;
00710         }
00711 
00712         public function getDescription() {
00713                 return 'Enumerate recent changes';
00714         }
00715 
00716         public function getPossibleErrors() {
00717                 return array_merge( parent::getPossibleErrors(), array(
00718                         array( 'show' ),
00719                         array( 'code' => 'permissiondenied', 'info' => 'You need the patrol right to request the patrolled flag' ),
00720                         array( 'code' => 'user-excludeuser', 'info' => 'user and excludeuser cannot be used together' ),
00721                 ) );
00722         }
00723 
00724         public function getExamples() {
00725                 return array(
00726                         'api.php?action=query&list=recentchanges'
00727                 );
00728         }
00729 
00730         public function getHelpUrls() {
00731                 return 'https://www.mediawiki.org/wiki/API:Recentchanges';
00732         }
00733 
00734         public function getVersion() {
00735                 return __CLASS__ . ': $Id$';
00736         }
00737 }