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