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