MediaWiki
REL1_20
|
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_moved_to_ns', 00218 'rc_moved_to_title', 00219 'rc_deleted' 00220 ) ); 00221 00222 $showRedirects = false; 00223 /* Determine what properties we need to display. */ 00224 if ( !is_null( $params['prop'] ) ) { 00225 $prop = array_flip( $params['prop'] ); 00226 00227 /* Set up internal members based upon params. */ 00228 $this->initProperties( $prop ); 00229 00230 if ( $this->fld_patrolled && !$user->useRCPatrol() && !$user->useNPPatrol() ) { 00231 $this->dieUsage( 'You need the patrol right to request the patrolled flag', 'permissiondenied' ); 00232 } 00233 00234 /* Add fields to our query if they are specified as a needed parameter. */ 00235 $this->addFieldsIf( array( 'rc_id', 'rc_this_oldid', 'rc_last_oldid' ), $this->fld_ids ); 00236 $this->addFieldsIf( 'rc_comment', $this->fld_comment || $this->fld_parsedcomment ); 00237 $this->addFieldsIf( 'rc_user', $this->fld_user ); 00238 $this->addFieldsIf( 'rc_user_text', $this->fld_user || $this->fld_userid ); 00239 $this->addFieldsIf( array( 'rc_minor', 'rc_type', 'rc_bot' ) , $this->fld_flags ); 00240 $this->addFieldsIf( array( 'rc_old_len', 'rc_new_len' ), $this->fld_sizes ); 00241 $this->addFieldsIf( 'rc_patrolled', $this->fld_patrolled ); 00242 $this->addFieldsIf( array( 'rc_logid', 'rc_log_type', 'rc_log_action', 'rc_params' ), $this->fld_loginfo ); 00243 $showRedirects = $this->fld_redirect || isset( $show['redirect'] ) || isset( $show['!redirect'] ); 00244 } 00245 00246 if ( $this->fld_tags ) { 00247 $this->addTables( 'tag_summary' ); 00248 $this->addJoinConds( array( 'tag_summary' => array( 'LEFT JOIN', array( 'rc_id=ts_rc_id' ) ) ) ); 00249 $this->addFields( 'ts_tags' ); 00250 } 00251 00252 if ( $params['toponly'] || $showRedirects ) { 00253 $this->addTables( 'page' ); 00254 $this->addJoinConds( array( 'page' => array( 'LEFT JOIN', array( 'rc_namespace=page_namespace', 'rc_title=page_title' ) ) ) ); 00255 $this->addFields( 'page_is_redirect' ); 00256 00257 if ( $params['toponly'] ) { 00258 $this->addWhere( 'rc_this_oldid = page_latest' ); 00259 } 00260 } 00261 00262 if ( !is_null( $params['tag'] ) ) { 00263 $this->addTables( 'change_tag' ); 00264 $this->addJoinConds( array( 'change_tag' => array( 'INNER JOIN', array( 'rc_id=ct_rc_id' ) ) ) ); 00265 $this->addWhereFld( 'ct_tag' , $params['tag'] ); 00266 global $wgOldChangeTagsIndex; 00267 $index['change_tag'] = $wgOldChangeTagsIndex ? 'ct_tag' : 'change_tag_tag_id'; 00268 } 00269 00270 $this->token = $params['token']; 00271 $this->addOption( 'LIMIT', $params['limit'] + 1 ); 00272 $this->addOption( 'USE INDEX', $index ); 00273 00274 $count = 0; 00275 /* Perform the actual query. */ 00276 $res = $this->select( __METHOD__ ); 00277 00278 $titles = array(); 00279 00280 $result = $this->getResult(); 00281 00282 /* Iterate through the rows, adding data extracted from them to our query result. */ 00283 foreach ( $res as $row ) { 00284 if ( ++ $count > $params['limit'] ) { 00285 // We've reached the one extra which shows that there are additional pages to be had. Stop here... 00286 $this->setContinueEnumParameter( 'start', wfTimestamp( TS_ISO_8601, $row->rc_timestamp ) ); 00287 break; 00288 } 00289 00290 if ( is_null( $resultPageSet ) ) { 00291 /* Extract the data from a single row. */ 00292 $vals = $this->extractRowInfo( $row ); 00293 00294 /* Add that row's data to our final output. */ 00295 if ( !$vals ) { 00296 continue; 00297 } 00298 $fit = $result->addValue( array( 'query', $this->getModuleName() ), null, $vals ); 00299 if ( !$fit ) { 00300 $this->setContinueEnumParameter( 'start', wfTimestamp( TS_ISO_8601, $row->rc_timestamp ) ); 00301 break; 00302 } 00303 } else { 00304 $titles[] = Title::makeTitle( $row->rc_namespace, $row->rc_title ); 00305 } 00306 } 00307 00308 if ( is_null( $resultPageSet ) ) { 00309 /* Format the result */ 00310 $result->setIndexedTagName_internal( array( 'query', $this->getModuleName() ), 'rc' ); 00311 } else { 00312 $resultPageSet->populateFromTitles( $titles ); 00313 } 00314 } 00315 00323 public function extractRowInfo( $row ) { 00324 /* If page was moved somewhere, get the title of the move target. */ 00325 $movedToTitle = false; 00326 if ( isset( $row->rc_moved_to_title ) && $row->rc_moved_to_title !== '' ) { 00327 $movedToTitle = Title::makeTitle( $row->rc_moved_to_ns, $row->rc_moved_to_title ); 00328 } 00329 00330 /* Determine the title of the page that has been changed. */ 00331 $title = Title::makeTitle( $row->rc_namespace, $row->rc_title ); 00332 00333 /* Our output data. */ 00334 $vals = array(); 00335 00336 $type = intval( $row->rc_type ); 00337 00338 /* Determine what kind of change this was. */ 00339 switch ( $type ) { 00340 case RC_EDIT: 00341 $vals['type'] = 'edit'; 00342 break; 00343 case RC_NEW: 00344 $vals['type'] = 'new'; 00345 break; 00346 case RC_MOVE: 00347 $vals['type'] = 'move'; 00348 break; 00349 case RC_LOG: 00350 $vals['type'] = 'log'; 00351 break; 00352 case RC_MOVE_OVER_REDIRECT: 00353 $vals['type'] = 'move over redirect'; 00354 break; 00355 default: 00356 $vals['type'] = $type; 00357 } 00358 00359 /* Create a new entry in the result for the title. */ 00360 if ( $this->fld_title ) { 00361 ApiQueryBase::addTitleInfo( $vals, $title ); 00362 if ( $movedToTitle ) { 00363 ApiQueryBase::addTitleInfo( $vals, $movedToTitle, 'new_' ); 00364 } 00365 } 00366 00367 /* Add ids, such as rcid, pageid, revid, and oldid to the change's info. */ 00368 if ( $this->fld_ids ) { 00369 $vals['rcid'] = intval( $row->rc_id ); 00370 $vals['pageid'] = intval( $row->rc_cur_id ); 00371 $vals['revid'] = intval( $row->rc_this_oldid ); 00372 $vals['old_revid'] = intval( $row->rc_last_oldid ); 00373 } 00374 00375 /* Add user data and 'anon' flag, if use is anonymous. */ 00376 if ( $this->fld_user || $this->fld_userid ) { 00377 00378 if ( $this->fld_user ) { 00379 $vals['user'] = $row->rc_user_text; 00380 } 00381 00382 if ( $this->fld_userid ) { 00383 $vals['userid'] = $row->rc_user; 00384 } 00385 00386 if ( !$row->rc_user ) { 00387 $vals['anon'] = ''; 00388 } 00389 } 00390 00391 /* Add flags, such as new, minor, bot. */ 00392 if ( $this->fld_flags ) { 00393 if ( $row->rc_bot ) { 00394 $vals['bot'] = ''; 00395 } 00396 if ( $row->rc_type == RC_NEW ) { 00397 $vals['new'] = ''; 00398 } 00399 if ( $row->rc_minor ) { 00400 $vals['minor'] = ''; 00401 } 00402 } 00403 00404 /* Add sizes of each revision. (Only available on 1.10+) */ 00405 if ( $this->fld_sizes ) { 00406 $vals['oldlen'] = intval( $row->rc_old_len ); 00407 $vals['newlen'] = intval( $row->rc_new_len ); 00408 } 00409 00410 /* Add the timestamp. */ 00411 if ( $this->fld_timestamp ) { 00412 $vals['timestamp'] = wfTimestamp( TS_ISO_8601, $row->rc_timestamp ); 00413 } 00414 00415 /* Add edit summary / log summary. */ 00416 if ( $this->fld_comment && isset( $row->rc_comment ) ) { 00417 $vals['comment'] = $row->rc_comment; 00418 } 00419 00420 if ( $this->fld_parsedcomment && isset( $row->rc_comment ) ) { 00421 $vals['parsedcomment'] = Linker::formatComment( $row->rc_comment, $title ); 00422 } 00423 00424 if ( $this->fld_redirect ) { 00425 if ( $row->page_is_redirect ) { 00426 $vals['redirect'] = ''; 00427 } 00428 } 00429 00430 /* Add the patrolled flag */ 00431 if ( $this->fld_patrolled && $row->rc_patrolled == 1 ) { 00432 $vals['patrolled'] = ''; 00433 } 00434 00435 if ( $this->fld_loginfo && $row->rc_type == RC_LOG ) { 00436 $vals['logid'] = intval( $row->rc_logid ); 00437 $vals['logtype'] = $row->rc_log_type; 00438 $vals['logaction'] = $row->rc_log_action; 00439 $logEntry = DatabaseLogEntry::newFromRow( (array)$row ); 00440 ApiQueryLogEvents::addLogParams( 00441 $this->getResult(), 00442 $vals, 00443 $logEntry->getParameters(), 00444 $logEntry->getType(), 00445 $logEntry->getSubtype(), 00446 $logEntry->getTimestamp() 00447 ); 00448 } 00449 00450 if ( $this->fld_tags ) { 00451 if ( $row->ts_tags ) { 00452 $tags = explode( ',', $row->ts_tags ); 00453 $this->getResult()->setIndexedTagName( $tags, 'tag' ); 00454 $vals['tags'] = $tags; 00455 } else { 00456 $vals['tags'] = array(); 00457 } 00458 } 00459 00460 if ( !is_null( $this->token ) ) { 00461 $tokenFunctions = $this->getTokenFunctions(); 00462 foreach ( $this->token as $t ) { 00463 $val = call_user_func( $tokenFunctions[$t], $row->rc_cur_id, 00464 $title, RecentChange::newFromRow( $row ) ); 00465 if ( $val === false ) { 00466 $this->setWarning( "Action '$t' is not allowed for the current user" ); 00467 } else { 00468 $vals[$t . 'token'] = $val; 00469 } 00470 } 00471 } 00472 00473 return $vals; 00474 } 00475 00476 private function parseRCType( $type ) { 00477 if ( is_array( $type ) ) { 00478 $retval = array(); 00479 foreach ( $type as $t ) { 00480 $retval[] = $this->parseRCType( $t ); 00481 } 00482 return $retval; 00483 } 00484 switch( $type ) { 00485 case 'edit': 00486 return RC_EDIT; 00487 case 'new': 00488 return RC_NEW; 00489 case 'log': 00490 return RC_LOG; 00491 } 00492 } 00493 00494 public function getCacheMode( $params ) { 00495 if ( isset( $params['show'] ) ) { 00496 foreach ( $params['show'] as $show ) { 00497 if ( $show === 'patrolled' || $show === '!patrolled' ) { 00498 return 'private'; 00499 } 00500 } 00501 } 00502 if ( isset( $params['token'] ) ) { 00503 return 'private'; 00504 } 00505 if ( !is_null( $params['prop'] ) && in_array( 'parsedcomment', $params['prop'] ) ) { 00506 // formatComment() calls wfMessage() among other things 00507 return 'anon-public-user-private'; 00508 } 00509 return 'public'; 00510 } 00511 00512 public function getAllowedParams() { 00513 return array( 00514 'start' => array( 00515 ApiBase::PARAM_TYPE => 'timestamp' 00516 ), 00517 'end' => array( 00518 ApiBase::PARAM_TYPE => 'timestamp' 00519 ), 00520 'dir' => array( 00521 ApiBase::PARAM_DFLT => 'older', 00522 ApiBase::PARAM_TYPE => array( 00523 'newer', 00524 'older' 00525 ) 00526 ), 00527 'namespace' => array( 00528 ApiBase::PARAM_ISMULTI => true, 00529 ApiBase::PARAM_TYPE => 'namespace' 00530 ), 00531 'user' => array( 00532 ApiBase::PARAM_TYPE => 'user' 00533 ), 00534 'excludeuser' => array( 00535 ApiBase::PARAM_TYPE => 'user' 00536 ), 00537 'tag' => null, 00538 'prop' => array( 00539 ApiBase::PARAM_ISMULTI => true, 00540 ApiBase::PARAM_DFLT => 'title|timestamp|ids', 00541 ApiBase::PARAM_TYPE => array( 00542 'user', 00543 'userid', 00544 'comment', 00545 'parsedcomment', 00546 'flags', 00547 'timestamp', 00548 'title', 00549 'ids', 00550 'sizes', 00551 'redirect', 00552 'patrolled', 00553 'loginfo', 00554 'tags' 00555 ) 00556 ), 00557 'token' => array( 00558 ApiBase::PARAM_TYPE => array_keys( $this->getTokenFunctions() ), 00559 ApiBase::PARAM_ISMULTI => true 00560 ), 00561 'show' => array( 00562 ApiBase::PARAM_ISMULTI => true, 00563 ApiBase::PARAM_TYPE => array( 00564 'minor', 00565 '!minor', 00566 'bot', 00567 '!bot', 00568 'anon', 00569 '!anon', 00570 'redirect', 00571 '!redirect', 00572 'patrolled', 00573 '!patrolled' 00574 ) 00575 ), 00576 'limit' => array( 00577 ApiBase::PARAM_DFLT => 10, 00578 ApiBase::PARAM_TYPE => 'limit', 00579 ApiBase::PARAM_MIN => 1, 00580 ApiBase::PARAM_MAX => ApiBase::LIMIT_BIG1, 00581 ApiBase::PARAM_MAX2 => ApiBase::LIMIT_BIG2 00582 ), 00583 'type' => array( 00584 ApiBase::PARAM_ISMULTI => true, 00585 ApiBase::PARAM_TYPE => array( 00586 'edit', 00587 'new', 00588 'log' 00589 ) 00590 ), 00591 'toponly' => false, 00592 ); 00593 } 00594 00595 public function getParamDescription() { 00596 $p = $this->getModulePrefix(); 00597 return array( 00598 'start' => 'The timestamp to start enumerating from', 00599 'end' => 'The timestamp to end enumerating', 00600 'dir' => $this->getDirectionDescription( $p ), 00601 'namespace' => 'Filter log entries to only this namespace(s)', 00602 'user' => 'Only list changes by this user', 00603 'excludeuser' => 'Don\'t list changes by this user', 00604 'prop' => array( 00605 'Include additional pieces of information', 00606 ' user - Adds the user responsible for the edit and tags if they are an IP', 00607 ' userid - Adds the user id responsible for the edit', 00608 ' comment - Adds the comment for the edit', 00609 ' parsedcomment - Adds the parsed comment for the edit', 00610 ' flags - Adds flags for the edit', 00611 ' timestamp - Adds timestamp of the edit', 00612 ' title - Adds the page title of the edit', 00613 ' ids - Adds the page ID, recent changes ID and the new and old revision ID', 00614 ' sizes - Adds the new and old page length in bytes', 00615 ' redirect - Tags edit if page is a redirect', 00616 ' patrolled - Tags edits that have been patrolled', 00617 ' loginfo - Adds log information (logid, logtype, etc) to log entries', 00618 ' tags - Lists tags for the entry', 00619 ), 00620 'token' => 'Which tokens to obtain for each change', 00621 'show' => array( 00622 'Show only items that meet this criteria.', 00623 "For example, to see only minor edits done by logged-in users, set {$p}show=minor|!anon" 00624 ), 00625 'type' => 'Which types of changes to show', 00626 'limit' => 'How many total changes to return', 00627 'tag' => 'Only list changes tagged with this tag', 00628 'toponly' => 'Only list changes which are the latest revision', 00629 ); 00630 } 00631 00632 public function getResultProperties() { 00633 global $wgLogTypes; 00634 $props = array( 00635 '' => array( 00636 'type' => array( 00637 ApiBase::PROP_TYPE => array( 00638 'edit', 00639 'new', 00640 'move', 00641 'log', 00642 'move over redirect' 00643 ) 00644 ) 00645 ), 00646 'title' => array( 00647 'ns' => 'namespace', 00648 'title' => 'string', 00649 'new_ns' => array( 00650 ApiBase::PROP_TYPE => 'namespace', 00651 ApiBase::PROP_NULLABLE => true 00652 ), 00653 'new_title' => array( 00654 ApiBase::PROP_TYPE => 'string', 00655 ApiBase::PROP_NULLABLE => true 00656 ) 00657 ), 00658 'ids' => array( 00659 'rcid' => 'integer', 00660 'pageid' => 'integer', 00661 'revid' => 'integer', 00662 'old_revid' => 'integer' 00663 ), 00664 'user' => array( 00665 'user' => 'string', 00666 'anon' => 'boolean' 00667 ), 00668 'userid' => array( 00669 'userid' => 'integer', 00670 'anon' => 'boolean' 00671 ), 00672 'flags' => array( 00673 'bot' => 'boolean', 00674 'new' => 'boolean', 00675 'minor' => 'boolean' 00676 ), 00677 'sizes' => array( 00678 'oldlen' => 'integer', 00679 'newlen' => 'integer' 00680 ), 00681 'timestamp' => array( 00682 'timestamp' => 'timestamp' 00683 ), 00684 'comment' => array( 00685 'comment' => array( 00686 ApiBase::PROP_TYPE => 'string', 00687 ApiBase::PROP_NULLABLE => true 00688 ) 00689 ), 00690 'parsedcomment' => array( 00691 'parsedcomment' => array( 00692 ApiBase::PROP_TYPE => 'string', 00693 ApiBase::PROP_NULLABLE => true 00694 ) 00695 ), 00696 'redirect' => array( 00697 'redirect' => 'boolean' 00698 ), 00699 'patrolled' => array( 00700 'patrolled' => 'boolean' 00701 ), 00702 'loginfo' => array( 00703 'logid' => array( 00704 ApiBase::PROP_TYPE => 'integer', 00705 ApiBase::PROP_NULLABLE => true 00706 ), 00707 'logtype' => array( 00708 ApiBase::PROP_TYPE => $wgLogTypes, 00709 ApiBase::PROP_NULLABLE => true 00710 ), 00711 'logaction' => array( 00712 ApiBase::PROP_TYPE => 'string', 00713 ApiBase::PROP_NULLABLE => true 00714 ) 00715 ) 00716 ); 00717 00718 self::addTokenProperties( $props, $this->getTokenFunctions() ); 00719 00720 return $props; 00721 } 00722 00723 public function getDescription() { 00724 return 'Enumerate recent changes'; 00725 } 00726 00727 public function getPossibleErrors() { 00728 return array_merge( parent::getPossibleErrors(), array( 00729 array( 'show' ), 00730 array( 'code' => 'permissiondenied', 'info' => 'You need the patrol right to request the patrolled flag' ), 00731 array( 'code' => 'user-excludeuser', 'info' => 'user and excludeuser cannot be used together' ), 00732 ) ); 00733 } 00734 00735 public function getExamples() { 00736 return array( 00737 'api.php?action=query&list=recentchanges' 00738 ); 00739 } 00740 00741 public function getHelpUrls() { 00742 return 'https://www.mediawiki.org/wiki/API:Recentchanges'; 00743 } 00744 00745 public function getVersion() { 00746 return __CLASS__ . ': $Id$'; 00747 } 00748 }