MediaWiki REL1_29
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
45
53 protected function getTokenFunctions() {
54 // Don't call the hooks twice
55 if ( isset( $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
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 }
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,
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' => [
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' => [
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' => [
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' => [
674 ApiBase::PARAM_TYPE => 'limit',
678 ],
679 'type' => [
680 ApiBase::PARAM_DFLT => 'edit|new|log|categorize',
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}
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
$wgUser
Definition Setup.php:781
const PARAM_MAX2
(integer) Max value allowed for the parameter for users with the apihighlimits right,...
Definition ApiBase.php:100
const PARAM_DEPRECATED
(boolean) Is the parameter deprecated (will show a warning)?
Definition ApiBase.php:109
const PARAM_MAX
(integer) Max value allowed for the parameter, for PARAM_TYPE 'integer' and 'limit'.
Definition ApiBase.php:94
dieWithError( $msg, $code=null, $data=null, $httpCode=null)
Abort execution with an error.
Definition ApiBase.php:1796
dieContinueUsageIf( $condition)
Die with the 'badcontinue' error.
Definition ApiBase.php:1950
static dieDebug( $method, $message)
Internal code errors should be reported with this method.
Definition ApiBase.php:1962
const PARAM_TYPE
(string|string[]) Either an array of allowed value strings, or a string type as described below.
Definition ApiBase.php:91
const PARAM_DFLT
(null|boolean|integer|string) Default value of the parameter.
Definition ApiBase.php:52
extractRequestParams( $parseLimit=true)
Using getAllowedParams(), this function makes an array of the values provided by the user,...
Definition ApiBase.php:718
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
const PARAM_MIN
(integer) Lowest value allowed for the parameter, for PARAM_TYPE 'integer' and 'limit'.
Definition ApiBase.php:103
const LIMIT_BIG1
Fast query, standard limit.
Definition ApiBase.php:203
getResult()
Get the result object.
Definition ApiBase.php:610
requireMaxOneParameter( $params, $required)
Die if more than one of a certain set of parameters is set and not false.
Definition ApiBase.php:792
const PARAM_EXTRA_NAMESPACES
(int[]) When PARAM_TYPE is 'namespace', include these as additional possible values.
Definition ApiBase.php:189
const PARAM_HELP_MSG
(string|array|Message) Specify an alternative i18n documentation message for this parameter.
Definition ApiBase.php:128
addWarning( $msg, $code=null, $data=null)
Add a warning for this module.
Definition ApiBase.php:1720
const LIMIT_BIG2
Fast query, apihighlimits limit.
Definition ApiBase.php:205
getModuleName()
Get the name of the module being executed by this instance.
Definition ApiBase.php:490
getContinuationManager()
Get the continuation manager.
Definition ApiBase.php:650
const PARAM_ISMULTI
(boolean) Accept multiple pipe-separated values for this parameter (e.g.
Definition ApiBase.php:55
lacksSameOriginSecurity()
Returns true if the current request breaks the same-origin policy.
Definition ApiBase.php:538
static addTitleInfo(&$arr, $title, $prefix='')
Add information (title and namespace) about a Title object to a result array.
processRow( $row, array &$data, array &$hookData)
Call the ApiQueryBaseProcessRow hook.
addWhereIf( $value, $condition)
Same as addWhere(), but add the WHERE clauses only if a condition is met.
addFields( $value)
Add a set of fields to select to the internal array.
addOption( $name, $value=null)
Add an option such as LIMIT or USE INDEX.
addTables( $tables, $alias=null)
Add a set of tables to the internal array.
addTimestampWhereRange( $field, $dir, $start, $end, $sort=true)
Add a WHERE clause corresponding to a range, similar to addWhereRange, but converts $start and $end t...
getDB()
Get the Query database connection (read-only)
addFieldsIf( $value, $condition)
Same as addFields(), but add the fields only if a condition is met.
addJoinConds( $join_conds)
Add a set of JOIN conditions to the internal array.
addWhereFld( $field, $value)
Equivalent to addWhere(array($field => $value))
addWhere( $value)
Add a set of WHERE clauses to the internal array.
userCanSeeRevDel()
Check whether the current user has permission to view revision-deleted fields.
setContinueEnumParameter( $paramName, $paramValue)
Overridden to set the generator param if in generator mode.
A query action to enumerate the recent changes that were done to the wiki.
__construct(ApiQuery $query, $moduleName)
static getPatrolToken( $pageid, $title, $rc=null)
getAllowedParams()
Returns an array of allowed parameters (parameter name) => (default value) or (parameter name) => (ar...
initProperties( $prop)
Sets internal state to include the desired properties in the output.
getExamplesMessages()
Returns usage examples for this module.
execute()
Evaluates the parameters, performs the requested query, and sets up the result.
executeGenerator( $resultPageSet)
Execute this module as a generator.
run( $resultPageSet=null)
Generates and outputs the result of this query based upon the provided parameters.
getHelpUrls()
Return links to more detailed help pages about the module.
getCacheMode( $params)
Get the cache mode for the data generated by this module.
extractRowInfo( $row)
Extracts from a single sql row the data needed to describe one recent change.
getTokenFunctions()
Get an array mapping token names to their handler functions.
This is the main query class.
Definition ApiQuery.php:40
static setIndexedTagName(array &$arr, $tag)
Set the tag name for numeric-keyed values in XML format.
static isUnpatrolled( $rc, User $user)
getUser()
Get the User object.
getRequest()
Get the WebRequest object.
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
static userCanBitfield( $bitfield, $field, User $user=null)
Determine if the current user is allowed to view a particular field of this log row,...
static newFromRow( $row)
Handy shortcut for constructing a formatter directly from database row.
const DELETED_RESTRICTED
Definition LogPage.php:35
const DELETED_ACTION
Definition LogPage.php:32
static parseToRCType( $type)
Parsing text to RC_* constants.
static newFromRow( $row)
static getChangeTypes()
Get an array of all change types.
static parseFromRCType( $rcType)
Parsing RC_* constants to human-readable test.
const DELETED_USER
Definition Revision.php:92
const DELETED_TEXT
Definition Revision.php:90
const DELETED_RESTRICTED
Definition Revision.php:93
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,...
const DELETED_COMMENT
Definition Revision.php:91
We use the convention $dbr for read and $dbw for write to help you keep track of whether the database object is a the world will explode Or to be a subsequent write query which succeeded on the master may fail when replicated to the slave due to a unique key collision Replication on the slave will stop and it may take hours to repair the database and get it back online Setting read_only in my cnf on the slave will avoid this but given the dire we prefer to have as many checks as possible We provide a but the wrapper functions like select() and insert() are usually more convenient. They take care of things like table prefixes and escaping for you. If you really need to make your own SQL
$res
Definition database.txt:21
when a variable name is used in a it is silently declared as a new local masking the global
Definition design.txt:95
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
const RC_NEW
Definition Defines.php:141
const NS_SPECIAL
Definition Defines.php:51
const LIST_OR
Definition Defines.php:44
const RC_LOG
Definition Defines.php:142
const NS_MEDIA
Definition Defines.php:50
const RC_EDIT
Definition Defines.php:140
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 local account $user
Definition hooks.txt:249
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
namespace and then decline to actually register it file or subcat img or subcat $title
Definition hooks.txt:964
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:1967
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:2604
null for the local 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:1601
returning false will NOT prevent logging $e
Definition hooks.txt:2127
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:37
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
$params