MediaWiki  1.29.1
ApiQueryRecentChanges.php
Go to the documentation of this file.
1 <?php
34 
35  public function __construct( ApiQuery $query, $moduleName ) {
36  parent::__construct( $query, $moduleName, 'rc' );
37  }
38 
39  private $fld_comment = false, $fld_parsedcomment = false, $fld_user = false, $fld_userid = false,
40  $fld_flags = false, $fld_timestamp = false, $fld_title = false, $fld_ids = false,
41  $fld_sizes = false, $fld_redirect = false, $fld_patrolled = false, $fld_loginfo = false,
42  $fld_tags = false, $fld_sha1 = false, $token = [];
43 
44  private $tokenFunctions;
45 
53  protected function getTokenFunctions() {
54  // Don't call the hooks twice
55  if ( isset( $this->tokenFunctions ) ) {
56  return $this->tokenFunctions;
57  }
58 
59  // If we're in a mode that breaks the same-origin policy, no tokens can
60  // be obtained
61  if ( $this->lacksSameOriginSecurity() ) {
62  return [];
63  }
64 
65  $this->tokenFunctions = [
66  'patrol' => [ 'ApiQueryRecentChanges', 'getPatrolToken' ]
67  ];
68  Hooks::run( 'APIQueryRecentChangesTokens', [ &$this->tokenFunctions ] );
69 
70  return $this->tokenFunctions;
71  }
72 
80  public static function getPatrolToken( $pageid, $title, $rc = null ) {
82 
83  $validTokenUser = false;
84 
85  if ( $rc ) {
86  if ( ( $wgUser->useRCPatrol() && $rc->getAttribute( 'rc_type' ) == RC_EDIT ) ||
87  ( $wgUser->useNPPatrol() && $rc->getAttribute( 'rc_type' ) == RC_NEW )
88  ) {
89  $validTokenUser = true;
90  }
91  } elseif ( $wgUser->useRCPatrol() || $wgUser->useNPPatrol() ) {
92  $validTokenUser = true;
93  }
94 
95  if ( $validTokenUser ) {
96  // The patrol token is always the same, let's exploit that
97  static $cachedPatrolToken = null;
98 
99  if ( is_null( $cachedPatrolToken ) ) {
100  $cachedPatrolToken = $wgUser->getEditToken( 'patrol' );
101  }
102 
103  return $cachedPatrolToken;
104  }
105 
106  return false;
107  }
108 
113  public function initProperties( $prop ) {
114  $this->fld_comment = isset( $prop['comment'] );
115  $this->fld_parsedcomment = isset( $prop['parsedcomment'] );
116  $this->fld_user = isset( $prop['user'] );
117  $this->fld_userid = isset( $prop['userid'] );
118  $this->fld_flags = isset( $prop['flags'] );
119  $this->fld_timestamp = isset( $prop['timestamp'] );
120  $this->fld_title = isset( $prop['title'] );
121  $this->fld_ids = isset( $prop['ids'] );
122  $this->fld_sizes = isset( $prop['sizes'] );
123  $this->fld_redirect = isset( $prop['redirect'] );
124  $this->fld_patrolled = isset( $prop['patrolled'] );
125  $this->fld_loginfo = isset( $prop['loginfo'] );
126  $this->fld_tags = isset( $prop['tags'] );
127  $this->fld_sha1 = isset( $prop['sha1'] );
128  }
129 
130  public function execute() {
131  $this->run();
132  }
133 
134  public function executeGenerator( $resultPageSet ) {
135  $this->run( $resultPageSet );
136  }
137 
143  public function run( $resultPageSet = null ) {
144  $user = $this->getUser();
145  /* Get the parameters of the request. */
146  $params = $this->extractRequestParams();
147 
148  /* Build our basic query. Namely, something along the lines of:
149  * SELECT * FROM recentchanges WHERE rc_timestamp > $start
150  * AND rc_timestamp < $end AND rc_namespace = $namespace
151  */
152  $this->addTables( 'recentchanges' );
153  $this->addTimestampWhereRange( 'rc_timestamp', $params['dir'], $params['start'], $params['end'] );
154 
155  if ( !is_null( $params['continue'] ) ) {
156  $cont = explode( '|', $params['continue'] );
157  $this->dieContinueUsageIf( count( $cont ) != 2 );
158  $db = $this->getDB();
159  $timestamp = $db->addQuotes( $db->timestamp( $cont[0] ) );
160  $id = intval( $cont[1] );
161  $this->dieContinueUsageIf( $id != $cont[1] );
162  $op = $params['dir'] === 'older' ? '<' : '>';
163  $this->addWhere(
164  "rc_timestamp $op $timestamp OR " .
165  "(rc_timestamp = $timestamp AND " .
166  "rc_id $op= $id)"
167  );
168  }
169 
170  $order = $params['dir'] === 'older' ? 'DESC' : 'ASC';
171  $this->addOption( 'ORDER BY', [
172  "rc_timestamp $order",
173  "rc_id $order",
174  ] );
175 
176  $this->addWhereFld( 'rc_namespace', $params['namespace'] );
177 
178  if ( !is_null( $params['type'] ) ) {
179  try {
180  $this->addWhereFld( 'rc_type', RecentChange::parseToRCType( $params['type'] ) );
181  } catch ( Exception $e ) {
182  ApiBase::dieDebug( __METHOD__, $e->getMessage() );
183  }
184  }
185 
186  if ( !is_null( $params['show'] ) ) {
187  $show = array_flip( $params['show'] );
188 
189  /* Check for conflicting parameters. */
190  if ( ( isset( $show['minor'] ) && isset( $show['!minor'] ) )
191  || ( isset( $show['bot'] ) && isset( $show['!bot'] ) )
192  || ( isset( $show['anon'] ) && isset( $show['!anon'] ) )
193  || ( isset( $show['redirect'] ) && isset( $show['!redirect'] ) )
194  || ( isset( $show['patrolled'] ) && isset( $show['!patrolled'] ) )
195  || ( isset( $show['patrolled'] ) && isset( $show['unpatrolled'] ) )
196  || ( isset( $show['!patrolled'] ) && isset( $show['unpatrolled'] ) )
197  ) {
198  $this->dieWithError( 'apierror-show' );
199  }
200 
201  // Check permissions
202  if ( isset( $show['patrolled'] )
203  || isset( $show['!patrolled'] )
204  || isset( $show['unpatrolled'] )
205  ) {
206  if ( !$user->useRCPatrol() && !$user->useNPPatrol() ) {
207  $this->dieWithError( 'apierror-permissiondenied-patrolflag', 'permissiondenied' );
208  }
209  }
210 
211  /* Add additional conditions to query depending upon parameters. */
212  $this->addWhereIf( 'rc_minor = 0', isset( $show['!minor'] ) );
213  $this->addWhereIf( 'rc_minor != 0', isset( $show['minor'] ) );
214  $this->addWhereIf( 'rc_bot = 0', isset( $show['!bot'] ) );
215  $this->addWhereIf( 'rc_bot != 0', isset( $show['bot'] ) );
216  $this->addWhereIf( 'rc_user = 0', isset( $show['anon'] ) );
217  $this->addWhereIf( 'rc_user != 0', isset( $show['!anon'] ) );
218  $this->addWhereIf( 'rc_patrolled = 0', isset( $show['!patrolled'] ) );
219  $this->addWhereIf( 'rc_patrolled != 0', isset( $show['patrolled'] ) );
220  $this->addWhereIf( 'page_is_redirect = 1', isset( $show['redirect'] ) );
221 
222  if ( isset( $show['unpatrolled'] ) ) {
223  // See ChangesList::isUnpatrolled
224  if ( $user->useRCPatrol() ) {
225  $this->addWhere( 'rc_patrolled = 0' );
226  } elseif ( $user->useNPPatrol() ) {
227  $this->addWhere( 'rc_patrolled = 0' );
228  $this->addWhereFld( 'rc_type', RC_NEW );
229  }
230  }
231 
232  // Don't throw log entries out the window here
233  $this->addWhereIf(
234  'page_is_redirect = 0 OR page_is_redirect IS NULL',
235  isset( $show['!redirect'] )
236  );
237  }
238 
239  $this->requireMaxOneParameter( $params, 'user', 'excludeuser' );
240 
241  if ( !is_null( $params['user'] ) ) {
242  $this->addWhereFld( 'rc_user_text', $params['user'] );
243  }
244 
245  if ( !is_null( $params['excludeuser'] ) ) {
246  // We don't use the rc_user_text index here because
247  // * it would require us to sort by rc_user_text before rc_timestamp
248  // * the != condition doesn't throw out too many rows anyway
249  $this->addWhere( 'rc_user_text != ' . $this->getDB()->addQuotes( $params['excludeuser'] ) );
250  }
251 
252  /* Add the fields we're concerned with to our query. */
253  $this->addFields( [
254  'rc_id',
255  'rc_timestamp',
256  'rc_namespace',
257  'rc_title',
258  'rc_cur_id',
259  'rc_type',
260  'rc_deleted'
261  ] );
262 
263  $showRedirects = false;
264  /* Determine what properties we need to display. */
265  if ( !is_null( $params['prop'] ) ) {
266  $prop = array_flip( $params['prop'] );
267 
268  /* Set up internal members based upon params. */
269  $this->initProperties( $prop );
270 
271  if ( $this->fld_patrolled && !$user->useRCPatrol() && !$user->useNPPatrol() ) {
272  $this->dieWithError( 'apierror-permissiondenied-patrolflag', 'permissiondenied' );
273  }
274 
275  /* Add fields to our query if they are specified as a needed parameter. */
276  $this->addFieldsIf( [ 'rc_this_oldid', 'rc_last_oldid' ], $this->fld_ids );
277  $this->addFieldsIf( 'rc_comment', $this->fld_comment || $this->fld_parsedcomment );
278  $this->addFieldsIf( 'rc_user', $this->fld_user || $this->fld_userid );
279  $this->addFieldsIf( 'rc_user_text', $this->fld_user );
280  $this->addFieldsIf( [ 'rc_minor', 'rc_type', 'rc_bot' ], $this->fld_flags );
281  $this->addFieldsIf( [ 'rc_old_len', 'rc_new_len' ], $this->fld_sizes );
282  $this->addFieldsIf( [ 'rc_patrolled', 'rc_log_type' ], $this->fld_patrolled );
283  $this->addFieldsIf(
284  [ 'rc_logid', 'rc_log_type', 'rc_log_action', 'rc_params' ],
285  $this->fld_loginfo
286  );
287  $showRedirects = $this->fld_redirect || isset( $show['redirect'] )
288  || isset( $show['!redirect'] );
289  }
290  $this->addFieldsIf( [ 'rc_this_oldid' ],
291  $resultPageSet && $params['generaterevisions'] );
292 
293  if ( $this->fld_tags ) {
294  $this->addTables( 'tag_summary' );
295  $this->addJoinConds( [ 'tag_summary' => [ 'LEFT JOIN', [ 'rc_id=ts_rc_id' ] ] ] );
296  $this->addFields( 'ts_tags' );
297  }
298 
299  if ( $this->fld_sha1 ) {
300  $this->addTables( 'revision' );
301  $this->addJoinConds( [ 'revision' => [ 'LEFT JOIN',
302  [ 'rc_this_oldid=rev_id' ] ] ] );
303  $this->addFields( [ 'rev_sha1', 'rev_deleted' ] );
304  }
305 
306  if ( $params['toponly'] || $showRedirects ) {
307  $this->addTables( 'page' );
308  $this->addJoinConds( [ 'page' => [ 'LEFT JOIN',
309  [ 'rc_namespace=page_namespace', 'rc_title=page_title' ] ] ] );
310  $this->addFields( 'page_is_redirect' );
311 
312  if ( $params['toponly'] ) {
313  $this->addWhere( 'rc_this_oldid = page_latest' );
314  }
315  }
316 
317  if ( !is_null( $params['tag'] ) ) {
318  $this->addTables( 'change_tag' );
319  $this->addJoinConds( [ 'change_tag' => [ 'INNER JOIN', [ 'rc_id=ct_rc_id' ] ] ] );
320  $this->addWhereFld( 'ct_tag', $params['tag'] );
321  }
322 
323  // Paranoia: avoid brute force searches (T19342)
324  if ( !is_null( $params['user'] ) || !is_null( $params['excludeuser'] ) ) {
325  if ( !$user->isAllowed( 'deletedhistory' ) ) {
326  $bitmask = Revision::DELETED_USER;
327  } elseif ( !$user->isAllowedAny( 'suppressrevision', 'viewsuppressed' ) ) {
329  } else {
330  $bitmask = 0;
331  }
332  if ( $bitmask ) {
333  $this->addWhere( $this->getDB()->bitAnd( 'rc_deleted', $bitmask ) . " != $bitmask" );
334  }
335  }
336  if ( $this->getRequest()->getCheck( 'namespace' ) ) {
337  // LogPage::DELETED_ACTION hides the affected page, too.
338  if ( !$user->isAllowed( 'deletedhistory' ) ) {
339  $bitmask = LogPage::DELETED_ACTION;
340  } elseif ( !$user->isAllowedAny( 'suppressrevision', 'viewsuppressed' ) ) {
342  } else {
343  $bitmask = 0;
344  }
345  if ( $bitmask ) {
346  $this->addWhere( $this->getDB()->makeList( [
347  'rc_type != ' . RC_LOG,
348  $this->getDB()->bitAnd( 'rc_deleted', $bitmask ) . " != $bitmask",
349  ], LIST_OR ) );
350  }
351  }
352 
353  $this->token = $params['token'];
354  $this->addOption( 'LIMIT', $params['limit'] + 1 );
355 
356  $hookData = [];
357  $count = 0;
358  /* Perform the actual query. */
359  $res = $this->select( __METHOD__, [], $hookData );
360 
361  $revids = [];
362  $titles = [];
363 
364  $result = $this->getResult();
365 
366  /* Iterate through the rows, adding data extracted from them to our query result. */
367  foreach ( $res as $row ) {
368  if ( $count === 0 && $resultPageSet !== null ) {
369  // Set the non-continue since the list of recentchanges is
370  // prone to having entries added at the start frequently.
371  $this->getContinuationManager()->addGeneratorNonContinueParam(
372  $this, 'continue', "$row->rc_timestamp|$row->rc_id"
373  );
374  }
375  if ( ++$count > $params['limit'] ) {
376  // We've reached the one extra which shows that there are
377  // additional pages to be had. Stop here...
378  $this->setContinueEnumParameter( 'continue', "$row->rc_timestamp|$row->rc_id" );
379  break;
380  }
381 
382  if ( is_null( $resultPageSet ) ) {
383  /* Extract the data from a single row. */
384  $vals = $this->extractRowInfo( $row );
385 
386  /* Add that row's data to our final output. */
387  $fit = $this->processRow( $row, $vals, $hookData ) &&
388  $result->addValue( [ 'query', $this->getModuleName() ], null, $vals );
389  if ( !$fit ) {
390  $this->setContinueEnumParameter( 'continue', "$row->rc_timestamp|$row->rc_id" );
391  break;
392  }
393  } elseif ( $params['generaterevisions'] ) {
394  $revid = (int)$row->rc_this_oldid;
395  if ( $revid > 0 ) {
396  $revids[] = $revid;
397  }
398  } else {
399  $titles[] = Title::makeTitle( $row->rc_namespace, $row->rc_title );
400  }
401  }
402 
403  if ( is_null( $resultPageSet ) ) {
404  /* Format the result */
405  $result->addIndexedTagName( [ 'query', $this->getModuleName() ], 'rc' );
406  } elseif ( $params['generaterevisions'] ) {
407  $resultPageSet->populateFromRevisionIDs( $revids );
408  } else {
409  $resultPageSet->populateFromTitles( $titles );
410  }
411  }
412 
420  public function extractRowInfo( $row ) {
421  /* Determine the title of the page that has been changed. */
422  $title = Title::makeTitle( $row->rc_namespace, $row->rc_title );
423  $user = $this->getUser();
424 
425  /* Our output data. */
426  $vals = [];
427 
428  $type = intval( $row->rc_type );
429  $vals['type'] = RecentChange::parseFromRCType( $type );
430 
431  $anyHidden = false;
432 
433  /* Create a new entry in the result for the title. */
434  if ( $this->fld_title || $this->fld_ids ) {
435  if ( $type === RC_LOG && ( $row->rc_deleted & LogPage::DELETED_ACTION ) ) {
436  $vals['actionhidden'] = true;
437  $anyHidden = true;
438  }
439  if ( $type !== RC_LOG ||
441  ) {
442  if ( $this->fld_title ) {
444  }
445  if ( $this->fld_ids ) {
446  $vals['pageid'] = intval( $row->rc_cur_id );
447  $vals['revid'] = intval( $row->rc_this_oldid );
448  $vals['old_revid'] = intval( $row->rc_last_oldid );
449  }
450  }
451  }
452 
453  if ( $this->fld_ids ) {
454  $vals['rcid'] = intval( $row->rc_id );
455  }
456 
457  /* Add user data and 'anon' flag, if user is anonymous. */
458  if ( $this->fld_user || $this->fld_userid ) {
459  if ( $row->rc_deleted & Revision::DELETED_USER ) {
460  $vals['userhidden'] = true;
461  $anyHidden = true;
462  }
463  if ( Revision::userCanBitfield( $row->rc_deleted, Revision::DELETED_USER, $user ) ) {
464  if ( $this->fld_user ) {
465  $vals['user'] = $row->rc_user_text;
466  }
467 
468  if ( $this->fld_userid ) {
469  $vals['userid'] = (int)$row->rc_user;
470  }
471 
472  if ( !$row->rc_user ) {
473  $vals['anon'] = true;
474  }
475  }
476  }
477 
478  /* Add flags, such as new, minor, bot. */
479  if ( $this->fld_flags ) {
480  $vals['bot'] = (bool)$row->rc_bot;
481  $vals['new'] = $row->rc_type == RC_NEW;
482  $vals['minor'] = (bool)$row->rc_minor;
483  }
484 
485  /* Add sizes of each revision. (Only available on 1.10+) */
486  if ( $this->fld_sizes ) {
487  $vals['oldlen'] = intval( $row->rc_old_len );
488  $vals['newlen'] = intval( $row->rc_new_len );
489  }
490 
491  /* Add the timestamp. */
492  if ( $this->fld_timestamp ) {
493  $vals['timestamp'] = wfTimestamp( TS_ISO_8601, $row->rc_timestamp );
494  }
495 
496  /* Add edit summary / log summary. */
497  if ( $this->fld_comment || $this->fld_parsedcomment ) {
498  if ( $row->rc_deleted & Revision::DELETED_COMMENT ) {
499  $vals['commenthidden'] = true;
500  $anyHidden = true;
501  }
502  if ( Revision::userCanBitfield( $row->rc_deleted, Revision::DELETED_COMMENT, $user ) ) {
503  if ( $this->fld_comment && isset( $row->rc_comment ) ) {
504  $vals['comment'] = $row->rc_comment;
505  }
506 
507  if ( $this->fld_parsedcomment && isset( $row->rc_comment ) ) {
508  $vals['parsedcomment'] = Linker::formatComment( $row->rc_comment, $title );
509  }
510  }
511  }
512 
513  if ( $this->fld_redirect ) {
514  $vals['redirect'] = (bool)$row->page_is_redirect;
515  }
516 
517  /* Add the patrolled flag */
518  if ( $this->fld_patrolled ) {
519  $vals['patrolled'] = $row->rc_patrolled == 1;
520  $vals['unpatrolled'] = ChangesList::isUnpatrolled( $row, $user );
521  }
522 
523  if ( $this->fld_loginfo && $row->rc_type == RC_LOG ) {
524  if ( $row->rc_deleted & LogPage::DELETED_ACTION ) {
525  $vals['actionhidden'] = true;
526  $anyHidden = true;
527  }
528  if ( LogEventsList::userCanBitfield( $row->rc_deleted, LogPage::DELETED_ACTION, $user ) ) {
529  $vals['logid'] = intval( $row->rc_logid );
530  $vals['logtype'] = $row->rc_log_type;
531  $vals['logaction'] = $row->rc_log_action;
532  $vals['logparams'] = LogFormatter::newFromRow( $row )->formatParametersForApi();
533  }
534  }
535 
536  if ( $this->fld_tags ) {
537  if ( $row->ts_tags ) {
538  $tags = explode( ',', $row->ts_tags );
539  ApiResult::setIndexedTagName( $tags, 'tag' );
540  $vals['tags'] = $tags;
541  } else {
542  $vals['tags'] = [];
543  }
544  }
545 
546  if ( $this->fld_sha1 && $row->rev_sha1 !== null ) {
547  if ( $row->rev_deleted & Revision::DELETED_TEXT ) {
548  $vals['sha1hidden'] = true;
549  $anyHidden = true;
550  }
551  if ( Revision::userCanBitfield( $row->rev_deleted, Revision::DELETED_TEXT, $user ) ) {
552  if ( $row->rev_sha1 !== '' ) {
553  $vals['sha1'] = Wikimedia\base_convert( $row->rev_sha1, 36, 16, 40 );
554  } else {
555  $vals['sha1'] = '';
556  }
557  }
558  }
559 
560  if ( !is_null( $this->token ) ) {
562  foreach ( $this->token as $t ) {
563  $val = call_user_func( $tokenFunctions[$t], $row->rc_cur_id,
564  $title, RecentChange::newFromRow( $row ) );
565  if ( $val === false ) {
566  $this->addWarning( [ 'apiwarn-tokennotallowed', $t ] );
567  } else {
568  $vals[$t . 'token'] = $val;
569  }
570  }
571  }
572 
573  if ( $anyHidden && ( $row->rc_deleted & Revision::DELETED_RESTRICTED ) ) {
574  $vals['suppressed'] = true;
575  }
576 
577  return $vals;
578  }
579 
580  public function getCacheMode( $params ) {
581  if ( isset( $params['show'] ) ) {
582  foreach ( $params['show'] as $show ) {
583  if ( $show === 'patrolled' || $show === '!patrolled' ) {
584  return 'private';
585  }
586  }
587  }
588  if ( isset( $params['token'] ) ) {
589  return 'private';
590  }
591  if ( $this->userCanSeeRevDel() ) {
592  return 'private';
593  }
594  if ( !is_null( $params['prop'] ) && in_array( 'parsedcomment', $params['prop'] ) ) {
595  // formatComment() calls wfMessage() among other things
596  return 'anon-public-user-private';
597  }
598 
599  return 'public';
600  }
601 
602  public function getAllowedParams() {
603  return [
604  'start' => [
605  ApiBase::PARAM_TYPE => 'timestamp'
606  ],
607  'end' => [
608  ApiBase::PARAM_TYPE => 'timestamp'
609  ],
610  'dir' => [
611  ApiBase::PARAM_DFLT => 'older',
613  'newer',
614  'older'
615  ],
616  ApiBase::PARAM_HELP_MSG => 'api-help-param-direction',
617  ],
618  'namespace' => [
619  ApiBase::PARAM_ISMULTI => true,
620  ApiBase::PARAM_TYPE => 'namespace',
622  ],
623  'user' => [
624  ApiBase::PARAM_TYPE => 'user'
625  ],
626  'excludeuser' => [
627  ApiBase::PARAM_TYPE => 'user'
628  ],
629  'tag' => null,
630  'prop' => [
631  ApiBase::PARAM_ISMULTI => true,
632  ApiBase::PARAM_DFLT => 'title|timestamp|ids',
634  'user',
635  'userid',
636  'comment',
637  'parsedcomment',
638  'flags',
639  'timestamp',
640  'title',
641  'ids',
642  'sizes',
643  'redirect',
644  'patrolled',
645  'loginfo',
646  'tags',
647  'sha1',
648  ],
650  ],
651  'token' => [
653  ApiBase::PARAM_TYPE => array_keys( $this->getTokenFunctions() ),
655  ],
656  'show' => [
657  ApiBase::PARAM_ISMULTI => true,
659  'minor',
660  '!minor',
661  'bot',
662  '!bot',
663  'anon',
664  '!anon',
665  'redirect',
666  '!redirect',
667  'patrolled',
668  '!patrolled',
669  'unpatrolled'
670  ]
671  ],
672  'limit' => [
673  ApiBase::PARAM_DFLT => 10,
674  ApiBase::PARAM_TYPE => 'limit',
675  ApiBase::PARAM_MIN => 1,
678  ],
679  'type' => [
680  ApiBase::PARAM_DFLT => 'edit|new|log|categorize',
681  ApiBase::PARAM_ISMULTI => true,
683  ],
684  'toponly' => false,
685  'continue' => [
686  ApiBase::PARAM_HELP_MSG => 'api-help-param-continue',
687  ],
688  'generaterevisions' => false,
689  ];
690  }
691 
692  protected function getExamplesMessages() {
693  return [
694  'action=query&list=recentchanges'
695  => 'apihelp-query+recentchanges-example-simple',
696  'action=query&generator=recentchanges&grcshow=!patrolled&prop=info'
697  => 'apihelp-query+recentchanges-example-generator',
698  ];
699  }
700 
701  public function getHelpUrls() {
702  return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Recentchanges';
703  }
704 }
ApiQueryRecentChanges\getPatrolToken
static getPatrolToken( $pageid, $title, $rc=null)
Definition: ApiQueryRecentChanges.php:80
ApiQueryRecentChanges\run
run( $resultPageSet=null)
Generates and outputs the result of this query based upon the provided parameters.
Definition: ApiQueryRecentChanges.php:143
Revision\DELETED_USER
const DELETED_USER
Definition: Revision.php:92
ApiQueryRecentChanges\$fld_comment
$fld_comment
Definition: ApiQueryRecentChanges.php:39
Revision\DELETED_RESTRICTED
const DELETED_RESTRICTED
Definition: Revision.php:93
if
if($IP===false)
Definition: cleanupArchiveUserText.php:4
$wgUser
$wgUser
Definition: Setup.php:781
ApiQueryBase\processRow
processRow( $row, array &$data, array &$hookData)
Call the ApiQueryBaseProcessRow hook.
Definition: ApiQueryBase.php:409
ApiQueryBase\addFields
addFields( $value)
Add a set of fields to select to the internal array.
Definition: ApiQueryBase.php:198
ApiQueryRecentChanges\$fld_ids
$fld_ids
Definition: ApiQueryRecentChanges.php:40
ApiQuery
This is the main query class.
Definition: ApiQuery.php:40
ApiBase\addWarning
addWarning( $msg, $code=null, $data=null)
Add a warning for this module.
Definition: ApiBase.php:1720
ApiQueryRecentChanges
A query action to enumerate the recent changes that were done to the wiki.
Definition: ApiQueryRecentChanges.php:33
ApiQueryRecentChanges\extractRowInfo
extractRowInfo( $row)
Extracts from a single sql row the data needed to describe one recent change.
Definition: ApiQueryRecentChanges.php:420
Revision\DELETED_COMMENT
const DELETED_COMMENT
Definition: Revision.php:91
Revision\userCanBitfield
static userCanBitfield( $bitfield, $field, User $user=null, Title $title=null)
Determine if the current user is allowed to view a particular field of this revision,...
Definition: Revision.php:1779
captcha-old.count
count
Definition: captcha-old.py:225
ApiBase\dieWithError
dieWithError( $msg, $code=null, $data=null, $httpCode=null)
Abort execution with an error.
Definition: ApiBase.php:1796
ApiQueryBase\addTimestampWhereRange
addTimestampWhereRange( $field, $dir, $start, $end, $sort=true)
Add a WHERE clause corresponding to a range, similar to addWhereRange, but converts $start and $end t...
Definition: ApiQueryBase.php:321
ApiBase\PARAM_HELP_MSG
const PARAM_HELP_MSG
(string|array|Message) Specify an alternative i18n documentation message for this parameter.
Definition: ApiBase.php:128
$result
The index of the header message $result[1]=The index of the body text message $result[2 through n]=Parameters passed to body text message. Please note the header message cannot receive/use parameters. 'ImportHandleLogItemXMLTag':When parsing a XML tag in a log item. Return false to stop further processing of the tag $reader:XMLReader object $logInfo:Array of information 'ImportHandlePageXMLTag':When parsing a XML tag in a page. Return false to stop further processing of the tag $reader:XMLReader object & $pageInfo:Array of information 'ImportHandleRevisionXMLTag':When parsing a XML tag in a page revision. Return false to stop further processing of the tag $reader:XMLReader object $pageInfo:Array of page information $revisionInfo:Array of revision information 'ImportHandleToplevelXMLTag':When parsing a top level XML tag. Return false to stop further processing of the tag $reader:XMLReader object 'ImportHandleUploadXMLTag':When parsing a XML tag in a file upload. Return false to stop further processing of the tag $reader:XMLReader object $revisionInfo:Array of information 'ImportLogInterwikiLink':Hook to change the interwiki link used in log entries and edit summaries for transwiki imports. & $fullInterwikiPrefix:Interwiki prefix, may contain colons. & $pageTitle:String that contains page title. 'ImportSources':Called when reading from the $wgImportSources configuration variable. Can be used to lazy-load the import sources list. & $importSources:The value of $wgImportSources. Modify as necessary. See the comment in DefaultSettings.php for the detail of how to structure this array. 'InfoAction':When building information to display on the action=info page. $context:IContextSource object & $pageInfo:Array of information 'InitializeArticleMaybeRedirect':MediaWiki check to see if title is a redirect. & $title:Title object for the current page & $request:WebRequest & $ignoreRedirect:boolean to skip redirect check & $target:Title/string of redirect target & $article:Article object 'InternalParseBeforeLinks':during Parser 's internalParse method before links but after nowiki/noinclude/includeonly/onlyinclude and other processings. & $parser:Parser object & $text:string containing partially parsed text & $stripState:Parser 's internal StripState object 'InternalParseBeforeSanitize':during Parser 's internalParse method just before the parser removes unwanted/dangerous HTML tags and after nowiki/noinclude/includeonly/onlyinclude and other processings. Ideal for syntax-extensions after template/parser function execution which respect nowiki and HTML-comments. & $parser:Parser object & $text:string containing partially parsed text & $stripState:Parser 's internal StripState object 'InterwikiLoadPrefix':When resolving if a given prefix is an interwiki or not. Return true without providing an interwiki to continue interwiki search. $prefix:interwiki prefix we are looking for. & $iwData:output array describing the interwiki with keys iw_url, iw_local, iw_trans and optionally iw_api and iw_wikiid. 'InvalidateEmailComplete':Called after a user 's email has been invalidated successfully. $user:user(object) whose email is being invalidated 'IRCLineURL':When constructing the URL to use in an IRC notification. Callee may modify $url and $query, URL will be constructed as $url . $query & $url:URL to index.php & $query:Query string $rc:RecentChange object that triggered url generation 'IsFileCacheable':Override the result of Article::isFileCacheable()(if true) & $article:article(object) being checked 'IsTrustedProxy':Override the result of IP::isTrustedProxy() & $ip:IP being check & $result:Change this value to override the result of IP::isTrustedProxy() 'IsUploadAllowedFromUrl':Override the result of UploadFromUrl::isAllowedUrl() $url:URL used to upload from & $allowed:Boolean indicating if uploading is allowed for given URL 'isValidEmailAddr':Override the result of Sanitizer::validateEmail(), for instance to return false if the domain name doesn 't match your organization. $addr:The e-mail address entered by the user & $result:Set this and return false to override the internal checks 'isValidPassword':Override the result of User::isValidPassword() $password:The password entered by the user & $result:Set this and return false to override the internal checks $user:User the password is being validated for 'Language::getMessagesFileName':$code:The language code or the language we 're looking for a messages file for & $file:The messages file path, you can override this to change the location. 'LanguageGetMagic':DEPRECATED! Use $magicWords in a file listed in $wgExtensionMessagesFiles instead. Use this to define synonyms of magic words depending of the language & $magicExtensions:associative array of magic words synonyms $lang:language code(string) 'LanguageGetNamespaces':Provide custom ordering for namespaces or remove namespaces. Do not use this hook to add namespaces. Use CanonicalNamespaces for that. & $namespaces:Array of namespaces indexed by their numbers 'LanguageGetSpecialPageAliases':DEPRECATED! Use $specialPageAliases in a file listed in $wgExtensionMessagesFiles instead. Use to define aliases of special pages names depending of the language & $specialPageAliases:associative array of magic words synonyms $lang:language code(string) 'LanguageGetTranslatedLanguageNames':Provide translated language names. & $names:array of language code=> language name $code:language of the preferred translations 'LanguageLinks':Manipulate a page 's language links. This is called in various places to allow extensions to define the effective language links for a page. $title:The page 's Title. & $links:Array with elements of the form "language:title" in the order that they will be output. & $linkFlags:Associative array mapping prefixed links to arrays of flags. Currently unused, but planned to provide support for marking individual language links in the UI, e.g. for featured articles. 'LanguageSelector':Hook to change the language selector available on a page. $out:The output page. $cssClassName:CSS class name of the language selector. 'LinkBegin':DEPRECATED! Use HtmlPageLinkRendererBegin instead. Used when generating internal and interwiki links in Linker::link(), before processing starts. Return false to skip default processing and return $ret. See documentation for Linker::link() for details on the expected meanings of parameters. $skin:the Skin object $target:the Title that the link is pointing to & $html:the contents that the< a > tag should have(raw HTML) $result
Definition: hooks.txt:1954
wfTimestamp
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
Definition: GlobalFunctions.php:1994
ApiQueryRecentChanges\getTokenFunctions
getTokenFunctions()
Get an array mapping token names to their handler functions.
Definition: ApiQueryRecentChanges.php:53
ApiBase\PARAM_TYPE
const PARAM_TYPE
(string|string[]) Either an array of allowed value strings, or a string type as described below.
Definition: ApiBase.php:91
ApiBase\getResult
getResult()
Get the result object.
Definition: ApiBase.php:610
RC_LOG
const RC_LOG
Definition: Defines.php:142
$user
please add to it if you re going to add events to the MediaWiki code where normally authentication against an external auth plugin would be creating a account $user
Definition: hooks.txt:246
ApiQueryRecentChanges\$fld_sizes
$fld_sizes
Definition: ApiQueryRecentChanges.php:41
ApiQueryRecentChanges\execute
execute()
Evaluates the parameters, performs the requested query, and sets up the result.
Definition: ApiQueryRecentChanges.php:130
RecentChange\getChangeTypes
static getChangeTypes()
Get an array of all change types.
Definition: RecentChange.php:162
$params
$params
Definition: styleTest.css.php:40
ApiQueryRecentChanges\$fld_userid
$fld_userid
Definition: ApiQueryRecentChanges.php:39
RC_EDIT
const RC_EDIT
Definition: Defines.php:140
$res
$res
Definition: database.txt:21
ContextSource\getRequest
getRequest()
Get the WebRequest object.
Definition: ContextSource.php:78
ApiQueryBase\addOption
addOption( $name, $value=null)
Add an option such as LIMIT or USE INDEX.
Definition: ApiQueryBase.php:333
$type
do that in ParserLimitReportFormat instead use this to modify the parameters of the image and a DIV can begin in one section and end in another Make sure your code can handle that case gracefully See the EditSectionClearerLink extension for an example zero but section is usually empty its values are the globals values before the output is cached my talk my contributions etc etc otherwise the built in rate limiting checks are if enabled allows for interception of redirect as a string mapping parameter names to values & $type
Definition: hooks.txt:2536
RecentChange\parseToRCType
static parseToRCType( $type)
Parsing text to RC_* constants.
Definition: RecentChange.php:129
ContextSource\getUser
getUser()
Get the User object.
Definition: ContextSource.php:133
ApiBase\lacksSameOriginSecurity
lacksSameOriginSecurity()
Returns true if the current request breaks the same-origin policy.
Definition: ApiBase.php:538
ApiQueryBase\addFieldsIf
addFieldsIf( $value, $condition)
Same as addFields(), but add the fields only if a condition is met.
Definition: ApiQueryBase.php:212
php
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition: injection.txt:35
ApiQueryRecentChanges\$fld_redirect
$fld_redirect
Definition: ApiQueryRecentChanges.php:41
ApiQueryGeneratorBase\setContinueEnumParameter
setContinueEnumParameter( $paramName, $paramValue)
Overridden to set the generator param if in generator mode.
Definition: ApiQueryGeneratorBase.php:88
ApiBase\PARAM_DEPRECATED
const PARAM_DEPRECATED
(boolean) Is the parameter deprecated (will show a warning)?
Definition: ApiBase.php:109
$query
null for the wiki Added should default to null in handler for backwards compatibility add a value to it if you want to add a cookie that have to vary cache options can modify $query
Definition: hooks.txt:1572
NS_SPECIAL
const NS_SPECIAL
Definition: Defines.php:51
ApiQueryRecentChanges\getAllowedParams
getAllowedParams()
Returns an array of allowed parameters (parameter name) => (default value) or (parameter name) => (ar...
Definition: ApiQueryRecentChanges.php:602
ApiBase\PARAM_MIN
const PARAM_MIN
(integer) Lowest value allowed for the parameter, for PARAM_TYPE 'integer' and 'limit'.
Definition: ApiBase.php:103
ApiQueryRecentChanges\$fld_flags
$fld_flags
Definition: ApiQueryRecentChanges.php:40
LIST_OR
const LIST_OR
Definition: Defines.php:44
$title
namespace and then decline to actually register it file or subcat img or subcat $title
Definition: hooks.txt:934
$titles
linkcache txt The LinkCache class maintains a list of article titles and the information about whether or not the article exists in the database This is used to mark up links when displaying a page If the same link appears more than once on any page then it only has to be looked up once In most cases link lookups are done in batches with the LinkBatch class or the equivalent in so the link cache is mostly useful for short snippets of parsed and for links in the navigation areas of the skin The link cache was formerly used to track links used in a document for the purposes of updating the link tables This application is now deprecated To create a you can use the following $titles
Definition: linkcache.txt:17
LogFormatter\newFromRow
static newFromRow( $row)
Handy shortcut for constructing a formatter directly from database row.
Definition: LogFormatter.php:74
ApiQueryRecentChanges\executeGenerator
executeGenerator( $resultPageSet)
Execute this module as a generator.
Definition: ApiQueryRecentChanges.php:134
ApiBase\LIMIT_BIG1
const LIMIT_BIG1
Fast query, standard limit.
Definition: ApiBase.php:203
ApiQueryRecentChanges\$fld_title
$fld_title
Definition: ApiQueryRecentChanges.php:40
ApiQueryRecentChanges\$fld_parsedcomment
$fld_parsedcomment
Definition: ApiQueryRecentChanges.php:39
ApiQueryBase\getDB
getDB()
Get the Query database connection (read-only)
Definition: ApiQueryBase.php:111
ApiBase\PARAM_MAX
const PARAM_MAX
(integer) Max value allowed for the parameter, for PARAM_TYPE 'integer' and 'limit'.
Definition: ApiBase.php:94
RecentChange\newFromRow
static newFromRow( $row)
Definition: RecentChange.php:115
ApiQueryBase\addTables
addTables( $tables, $alias=null)
Add a set of tables to the internal array.
Definition: ApiQueryBase.php:164
ApiQueryBase\select
select( $method, $extraQuery=[], array &$hookData=null)
Execute a SELECT query based on the values in the internal arrays.
Definition: ApiQueryBase.php:358
ApiQueryRecentChanges\$fld_user
$fld_user
Definition: ApiQueryRecentChanges.php:39
Title\makeTitle
static makeTitle( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:514
global
when a variable name is used in a it is silently declared as a new masking the global
Definition: design.txt:93
ApiBase\PARAM_EXTRA_NAMESPACES
const PARAM_EXTRA_NAMESPACES
(int[]) When PARAM_TYPE is 'namespace', include these as additional possible values.
Definition: ApiBase.php:189
LogPage\DELETED_ACTION
const DELETED_ACTION
Definition: LogPage.php:32
ApiQueryRecentChanges\__construct
__construct(ApiQuery $query, $moduleName)
Definition: ApiQueryRecentChanges.php:35
ApiBase\getContinuationManager
getContinuationManager()
Get the continuation manager.
Definition: ApiBase.php:650
ApiBase\extractRequestParams
extractRequestParams( $parseLimit=true)
Using getAllowedParams(), this function makes an array of the values provided by the user,...
Definition: ApiBase.php:718
ApiResult\setIndexedTagName
static setIndexedTagName(array &$arr, $tag)
Set the tag name for numeric-keyed values in XML format.
Definition: ApiResult.php:616
$e
div flags Integer display flags(NO_ACTION_LINK, NO_EXTRA_USER_LINKS) 'LogException' returning false will NOT prevent logging $e
Definition: hooks.txt:2122
NS_MEDIA
const NS_MEDIA
Definition: Defines.php:50
ApiBase\dieContinueUsageIf
dieContinueUsageIf( $condition)
Die with the 'badcontinue' error.
Definition: ApiBase.php:1950
ApiQueryRecentChanges\initProperties
initProperties( $prop)
Sets internal state to include the desired properties in the output.
Definition: ApiQueryRecentChanges.php:113
ApiQueryBase\addJoinConds
addJoinConds( $join_conds)
Add a set of JOIN conditions to the internal array.
Definition: ApiQueryBase.php:187
ApiQueryBase\addWhereFld
addWhereFld( $field, $value)
Equivalent to addWhere(array($field => $value))
Definition: ApiQueryBase.php:266
RC_NEW
const RC_NEW
Definition: Defines.php:141
ApiBase\requireMaxOneParameter
requireMaxOneParameter( $params, $required)
Die if more than one of a certain set of parameters is set and not false.
Definition: ApiBase.php:792
Linker\formatComment
static formatComment( $comment, $title=null, $local=false, $wikiId=null)
This function is called by all recent changes variants, by the page history, and by the user contribu...
Definition: Linker.php:1094
ApiQueryGeneratorBase
Definition: ApiQueryGeneratorBase.php:30
ApiQueryRecentChanges\$fld_tags
$fld_tags
Definition: ApiQueryRecentChanges.php:42
ApiQueryRecentChanges\$fld_patrolled
$fld_patrolled
Definition: ApiQueryRecentChanges.php:41
ApiQueryRecentChanges\getHelpUrls
getHelpUrls()
Return links to more detailed help pages about the module.
Definition: ApiQueryRecentChanges.php:701
ApiQueryRecentChanges\getExamplesMessages
getExamplesMessages()
Returns usage examples for this module.
Definition: ApiQueryRecentChanges.php:692
ApiBase\LIMIT_BIG2
const LIMIT_BIG2
Fast query, apihighlimits limit.
Definition: ApiBase.php:205
ApiQueryRecentChanges\$fld_loginfo
$fld_loginfo
Definition: ApiQueryRecentChanges.php:41
LogEventsList\userCanBitfield
static userCanBitfield( $bitfield, $field, User $user=null)
Determine if the current user is allowed to view a particular field of this log row,...
Definition: LogEventsList.php:512
RecentChange\parseFromRCType
static parseFromRCType( $rcType)
Parsing RC_* constants to human-readable test.
Definition: RecentChange.php:151
ApiQueryRecentChanges\$fld_timestamp
$fld_timestamp
Definition: ApiQueryRecentChanges.php:40
ApiBase\PARAM_DFLT
const PARAM_DFLT
(null|boolean|integer|string) Default value of the parameter.
Definition: ApiBase.php:52
as
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
Definition: distributors.txt:9
ApiBase\getModuleName
getModuleName()
Get the name of the module being executed by this instance.
Definition: ApiBase.php:490
ApiBase\PARAM_ISMULTI
const PARAM_ISMULTI
(boolean) Accept multiple pipe-separated values for this parameter (e.g.
Definition: ApiBase.php:55
ApiBase\PARAM_MAX2
const PARAM_MAX2
(integer) Max value allowed for the parameter for users with the apihighlimits right,...
Definition: ApiBase.php:100
true
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return true
Definition: hooks.txt:1956
LogPage\DELETED_RESTRICTED
const DELETED_RESTRICTED
Definition: LogPage.php:35
ApiQueryBase\addWhere
addWhere( $value)
Add a set of WHERE clauses to the internal array.
Definition: ApiQueryBase.php:233
ChangesList\isUnpatrolled
static isUnpatrolled( $rc, User $user)
Definition: ChangesList.php:702
$t
$t
Definition: testCompression.php:67
ApiQueryRecentChanges\$token
$token
Definition: ApiQueryRecentChanges.php:42
ApiBase\PARAM_HELP_MSG_PER_VALUE
const PARAM_HELP_MSG_PER_VALUE
((string|array|Message)[]) When PARAM_TYPE is an array, this is an array mapping those values to $msg...
Definition: ApiBase.php:160
Hooks\run
static run( $event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.
Definition: Hooks.php:131
ApiQueryBase\userCanSeeRevDel
userCanSeeRevDel()
Check whether the current user has permission to view revision-deleted fields.
Definition: ApiQueryBase.php:606
ApiBase\dieDebug
static dieDebug( $method, $message)
Internal code errors should be reported with this method.
Definition: ApiBase.php:1962
ApiQueryRecentChanges\getCacheMode
getCacheMode( $params)
Get the cache mode for the data generated by this module.
Definition: ApiQueryRecentChanges.php:580
Revision\DELETED_TEXT
const DELETED_TEXT
Definition: Revision.php:90
ApiQueryBase\addWhereIf
addWhereIf( $value, $condition)
Same as addWhere(), but add the WHERE clauses only if a condition is met.
Definition: ApiQueryBase.php:251
ApiQueryBase\addTitleInfo
static addTitleInfo(&$arr, $title, $prefix='')
Add information (title and namespace) about a Title object to a result array.
Definition: ApiQueryBase.php:486
ApiQueryRecentChanges\$fld_sha1
$fld_sha1
Definition: ApiQueryRecentChanges.php:42
ApiQueryRecentChanges\$tokenFunctions
$tokenFunctions
Definition: ApiQueryRecentChanges.php:44