MediaWiki REL1_29
ApiQueryUserContributions.php
Go to the documentation of this file.
1<?php
33
34 public function __construct( ApiQuery $query, $moduleName ) {
35 parent::__construct( $query, $moduleName, 'uc' );
36 }
37
40 private $fld_ids = false, $fld_title = false, $fld_timestamp = false,
41 $fld_comment = false, $fld_parsedcomment = false, $fld_flags = false,
42 $fld_patrolled = false, $fld_tags = false, $fld_size = false, $fld_sizediff = false;
43
44 public function execute() {
45 // Parse some parameters
46 $this->params = $this->extractRequestParams();
47
48 $prop = array_flip( $this->params['prop'] );
49 $this->fld_ids = isset( $prop['ids'] );
50 $this->fld_title = isset( $prop['title'] );
51 $this->fld_comment = isset( $prop['comment'] );
52 $this->fld_parsedcomment = isset( $prop['parsedcomment'] );
53 $this->fld_size = isset( $prop['size'] );
54 $this->fld_sizediff = isset( $prop['sizediff'] );
55 $this->fld_flags = isset( $prop['flags'] );
56 $this->fld_timestamp = isset( $prop['timestamp'] );
57 $this->fld_patrolled = isset( $prop['patrolled'] );
58 $this->fld_tags = isset( $prop['tags'] );
59
60 // Most of this code will use the 'contributions' group DB, which can map to replica DBs
61 // with extra user based indexes or partioning by user. The additional metadata
62 // queries should use a regular replica DB since the lookup pattern is not all by user.
63 $dbSecondary = $this->getDB(); // any random replica DB
64
65 // TODO: if the query is going only against the revision table, should this be done?
66 $this->selectNamedDB( 'contributions', DB_REPLICA, 'contributions' );
67
68 $this->requireOnlyOneParameter( $this->params, 'userprefix', 'userids', 'user' );
69
70 $this->idMode = false;
71 if ( isset( $this->params['userprefix'] ) ) {
72 $this->prefixMode = true;
73 $this->multiUserMode = true;
74 $this->userprefix = $this->params['userprefix'];
75 } elseif ( isset( $this->params['userids'] ) ) {
76 $this->userids = [];
77
78 if ( !count( $this->params['userids'] ) ) {
79 $encParamName = $this->encodeParamName( 'userids' );
80 $this->dieWithError( [ 'apierror-paramempty', $encParamName ], "paramempty_$encParamName" );
81 }
82
83 foreach ( $this->params['userids'] as $uid ) {
84 if ( $uid <= 0 ) {
85 $this->dieWithError( [ 'apierror-invaliduserid', $uid ], 'invaliduserid' );
86 }
87
88 $this->userids[] = $uid;
89 }
90
91 $this->prefixMode = false;
92 $this->multiUserMode = ( count( $this->params['userids'] ) > 1 );
93 $this->idMode = true;
94 } else {
95 $anyIPs = false;
96 $this->userids = [];
97 $this->usernames = [];
98 if ( !count( $this->params['user'] ) ) {
99 $encParamName = $this->encodeParamName( 'user' );
100 $this->dieWithError(
101 [ 'apierror-paramempty', $encParamName ], "paramempty_$encParamName"
102 );
103 }
104 foreach ( $this->params['user'] as $u ) {
105 if ( $u === '' ) {
106 $encParamName = $this->encodeParamName( 'user' );
107 $this->dieWithError(
108 [ 'apierror-paramempty', $encParamName ], "paramempty_$encParamName"
109 );
110 }
111
112 if ( User::isIP( $u ) ) {
113 $anyIPs = true;
114 $this->usernames[] = $u;
115 } else {
116 $name = User::getCanonicalName( $u, 'valid' );
117 if ( $name === false ) {
118 $encParamName = $this->encodeParamName( 'user' );
119 $this->dieWithError(
120 [ 'apierror-baduser', $encParamName, wfEscapeWikiText( $u ) ], "baduser_$encParamName"
121 );
122 }
123 $this->usernames[] = $name;
124 }
125 }
126 $this->prefixMode = false;
127 $this->multiUserMode = ( count( $this->params['user'] ) > 1 );
128
129 if ( !$anyIPs ) {
130 $dbr = $this->getDB();
131 $res = $dbr->select( 'user', 'user_id', [ 'user_name' => $this->usernames ], __METHOD__ );
132 foreach ( $res as $row ) {
133 $this->userids[] = $row->user_id;
134 }
135 $this->idMode = count( $this->userids ) === count( $this->usernames );
136 }
137 }
138
139 $this->prepareQuery();
140
141 $hookData = [];
142 // Do the actual query.
143 $res = $this->select( __METHOD__, [], $hookData );
144
145 if ( $this->fld_sizediff ) {
146 $revIds = [];
147 foreach ( $res as $row ) {
148 if ( $row->rev_parent_id ) {
149 $revIds[] = $row->rev_parent_id;
150 }
151 }
152 $this->parentLens = Revision::getParentLengths( $dbSecondary, $revIds );
153 $res->rewind(); // reset
154 }
155
156 // Initialise some variables
157 $count = 0;
158 $limit = $this->params['limit'];
159
160 // Fetch each row
161 foreach ( $res as $row ) {
162 if ( ++$count > $limit ) {
163 // We've reached the one extra which shows that there are
164 // additional pages to be had. Stop here...
165 $this->setContinueEnumParameter( 'continue', $this->continueStr( $row ) );
166 break;
167 }
168
169 $vals = $this->extractRowInfo( $row );
170 $fit = $this->processRow( $row, $vals, $hookData ) &&
171 $this->getResult()->addValue( [ 'query', $this->getModuleName() ], null, $vals );
172 if ( !$fit ) {
173 $this->setContinueEnumParameter( 'continue', $this->continueStr( $row ) );
174 break;
175 }
176 }
177
178 $this->getResult()->addIndexedTagName(
179 [ 'query', $this->getModuleName() ],
180 'item'
181 );
182 }
183
187 private function prepareQuery() {
188 // We're after the revision table, and the corresponding page
189 // row for anything we retrieve. We may also need the
190 // recentchanges row and/or tag summary row.
191 $user = $this->getUser();
192 $tables = [ 'page', 'revision' ]; // Order may change
193 $this->addWhere( 'page_id=rev_page' );
194
195 // Handle continue parameter
196 if ( !is_null( $this->params['continue'] ) ) {
197 $continue = explode( '|', $this->params['continue'] );
198 $db = $this->getDB();
199 if ( $this->multiUserMode ) {
200 $this->dieContinueUsageIf( count( $continue ) != 4 );
201 $modeFlag = array_shift( $continue );
202 $this->dieContinueUsageIf( !in_array( $modeFlag, [ 'id', 'name' ] ) );
203 if ( $this->idMode && $modeFlag === 'name' ) {
204 // The users were created since this query started, but we
205 // can't go back and change modes now. So just keep on with
206 // name mode.
207 $this->idMode = false;
208 }
209 $this->dieContinueUsageIf( ( $modeFlag === 'id' ) !== $this->idMode );
210 $userField = $this->idMode ? 'rev_user' : 'rev_user_text';
211 $encUser = $db->addQuotes( array_shift( $continue ) );
212 } else {
213 $this->dieContinueUsageIf( count( $continue ) != 2 );
214 }
215 $encTS = $db->addQuotes( $db->timestamp( $continue[0] ) );
216 $encId = (int)$continue[1];
217 $this->dieContinueUsageIf( $encId != $continue[1] );
218 $op = ( $this->params['dir'] == 'older' ? '<' : '>' );
219 if ( $this->multiUserMode ) {
220 $this->addWhere(
221 "$userField $op $encUser OR " .
222 "($userField = $encUser AND " .
223 "(rev_timestamp $op $encTS OR " .
224 "(rev_timestamp = $encTS AND " .
225 "rev_id $op= $encId)))"
226 );
227 } else {
228 $this->addWhere(
229 "rev_timestamp $op $encTS OR " .
230 "(rev_timestamp = $encTS AND " .
231 "rev_id $op= $encId)"
232 );
233 }
234 }
235
236 // Don't include any revisions where we're not supposed to be able to
237 // see the username.
238 if ( !$user->isAllowed( 'deletedhistory' ) ) {
239 $bitmask = Revision::DELETED_USER;
240 } elseif ( !$user->isAllowedAny( 'suppressrevision', 'viewsuppressed' ) ) {
242 } else {
243 $bitmask = 0;
244 }
245 if ( $bitmask ) {
246 $this->addWhere( $this->getDB()->bitAnd( 'rev_deleted', $bitmask ) . " != $bitmask" );
247 }
248
249 // We only want pages by the specified users.
250 if ( $this->prefixMode ) {
251 $this->addWhere( 'rev_user_text' .
252 $this->getDB()->buildLike( $this->userprefix, $this->getDB()->anyString() ) );
253 } elseif ( $this->idMode ) {
254 $this->addWhereFld( 'rev_user', $this->userids );
255 } else {
256 $this->addWhereFld( 'rev_user_text', $this->usernames );
257 }
258 // ... and in the specified timeframe.
259 // Ensure the same sort order for rev_user/rev_user_text and rev_timestamp
260 // so our query is indexed
261 if ( $this->multiUserMode ) {
262 $this->addWhereRange( $this->idMode ? 'rev_user' : 'rev_user_text',
263 $this->params['dir'], null, null );
264 }
265 $this->addTimestampWhereRange( 'rev_timestamp',
266 $this->params['dir'], $this->params['start'], $this->params['end'] );
267 // Include in ORDER BY for uniqueness
268 $this->addWhereRange( 'rev_id', $this->params['dir'], null, null );
269
270 $this->addWhereFld( 'page_namespace', $this->params['namespace'] );
271
272 $show = $this->params['show'];
273 if ( $this->params['toponly'] ) { // deprecated/old param
274 $show[] = 'top';
275 }
276 if ( !is_null( $show ) ) {
277 $show = array_flip( $show );
278
279 if ( ( isset( $show['minor'] ) && isset( $show['!minor'] ) )
280 || ( isset( $show['patrolled'] ) && isset( $show['!patrolled'] ) )
281 || ( isset( $show['top'] ) && isset( $show['!top'] ) )
282 || ( isset( $show['new'] ) && isset( $show['!new'] ) )
283 ) {
284 $this->dieWithError( 'apierror-show' );
285 }
286
287 $this->addWhereIf( 'rev_minor_edit = 0', isset( $show['!minor'] ) );
288 $this->addWhereIf( 'rev_minor_edit != 0', isset( $show['minor'] ) );
289 $this->addWhereIf( 'rc_patrolled = 0', isset( $show['!patrolled'] ) );
290 $this->addWhereIf( 'rc_patrolled != 0', isset( $show['patrolled'] ) );
291 $this->addWhereIf( 'rev_id != page_latest', isset( $show['!top'] ) );
292 $this->addWhereIf( 'rev_id = page_latest', isset( $show['top'] ) );
293 $this->addWhereIf( 'rev_parent_id != 0', isset( $show['!new'] ) );
294 $this->addWhereIf( 'rev_parent_id = 0', isset( $show['new'] ) );
295 }
296 $this->addOption( 'LIMIT', $this->params['limit'] + 1 );
297
298 // Mandatory fields: timestamp allows request continuation
299 // ns+title checks if the user has access rights for this page
300 // user_text is necessary if multiple users were specified
301 $this->addFields( [
302 'rev_id',
303 'rev_timestamp',
304 'page_namespace',
305 'page_title',
306 'rev_user',
307 'rev_user_text',
308 'rev_deleted'
309 ] );
310
311 if ( isset( $show['patrolled'] ) || isset( $show['!patrolled'] ) ||
312 $this->fld_patrolled
313 ) {
314 if ( !$user->useRCPatrol() && !$user->useNPPatrol() ) {
315 $this->dieWithError( 'apierror-permissiondenied-patrolflag', 'permissiondenied' );
316 }
317
318 // Use a redundant join condition on both
319 // timestamp and ID so we can use the timestamp
320 // index
321 $index['recentchanges'] = 'rc_user_text';
322 if ( isset( $show['patrolled'] ) || isset( $show['!patrolled'] ) ) {
323 // Put the tables in the right order for
324 // STRAIGHT_JOIN
325 $tables = [ 'revision', 'recentchanges', 'page' ];
326 $this->addOption( 'STRAIGHT_JOIN' );
327 $this->addWhere( 'rc_user_text=rev_user_text' );
328 $this->addWhere( 'rc_timestamp=rev_timestamp' );
329 $this->addWhere( 'rc_this_oldid=rev_id' );
330 } else {
331 $tables[] = 'recentchanges';
332 $this->addJoinConds( [ 'recentchanges' => [
333 'LEFT JOIN', [
334 'rc_user_text=rev_user_text',
335 'rc_timestamp=rev_timestamp',
336 'rc_this_oldid=rev_id' ] ] ] );
337 }
338 }
339
340 $this->addTables( $tables );
341 $this->addFieldsIf( 'rev_page', $this->fld_ids );
342 $this->addFieldsIf( 'page_latest', $this->fld_flags );
343 // $this->addFieldsIf( 'rev_text_id', $this->fld_ids ); // Should this field be exposed?
344 $this->addFieldsIf( 'rev_comment', $this->fld_comment || $this->fld_parsedcomment );
345 $this->addFieldsIf( 'rev_len', $this->fld_size || $this->fld_sizediff );
346 $this->addFieldsIf( 'rev_minor_edit', $this->fld_flags );
347 $this->addFieldsIf( 'rev_parent_id', $this->fld_flags || $this->fld_sizediff || $this->fld_ids );
348 $this->addFieldsIf( 'rc_patrolled', $this->fld_patrolled );
349
350 if ( $this->fld_tags ) {
351 $this->addTables( 'tag_summary' );
352 $this->addJoinConds(
353 [ 'tag_summary' => [ 'LEFT JOIN', [ 'rev_id=ts_rev_id' ] ] ]
354 );
355 $this->addFields( 'ts_tags' );
356 }
357
358 if ( isset( $this->params['tag'] ) ) {
359 $this->addTables( 'change_tag' );
360 $this->addJoinConds(
361 [ 'change_tag' => [ 'INNER JOIN', [ 'rev_id=ct_rev_id' ] ] ]
362 );
363 $this->addWhereFld( 'ct_tag', $this->params['tag'] );
364 }
365
366 if ( isset( $index ) ) {
367 $this->addOption( 'USE INDEX', $index );
368 }
369 }
370
377 private function extractRowInfo( $row ) {
378 $vals = [];
379 $anyHidden = false;
380
381 if ( $row->rev_deleted & Revision::DELETED_TEXT ) {
382 $vals['texthidden'] = true;
383 $anyHidden = true;
384 }
385
386 // Any rows where we can't view the user were filtered out in the query.
387 $vals['userid'] = (int)$row->rev_user;
388 $vals['user'] = $row->rev_user_text;
389 if ( $row->rev_deleted & Revision::DELETED_USER ) {
390 $vals['userhidden'] = true;
391 $anyHidden = true;
392 }
393 if ( $this->fld_ids ) {
394 $vals['pageid'] = intval( $row->rev_page );
395 $vals['revid'] = intval( $row->rev_id );
396 // $vals['textid'] = intval( $row->rev_text_id ); // todo: Should this field be exposed?
397
398 if ( !is_null( $row->rev_parent_id ) ) {
399 $vals['parentid'] = intval( $row->rev_parent_id );
400 }
401 }
402
403 $title = Title::makeTitle( $row->page_namespace, $row->page_title );
404
405 if ( $this->fld_title ) {
407 }
408
409 if ( $this->fld_timestamp ) {
410 $vals['timestamp'] = wfTimestamp( TS_ISO_8601, $row->rev_timestamp );
411 }
412
413 if ( $this->fld_flags ) {
414 $vals['new'] = $row->rev_parent_id == 0 && !is_null( $row->rev_parent_id );
415 $vals['minor'] = (bool)$row->rev_minor_edit;
416 $vals['top'] = $row->page_latest == $row->rev_id;
417 }
418
419 if ( ( $this->fld_comment || $this->fld_parsedcomment ) && isset( $row->rev_comment ) ) {
420 if ( $row->rev_deleted & Revision::DELETED_COMMENT ) {
421 $vals['commenthidden'] = true;
422 $anyHidden = true;
423 }
424
425 $userCanView = Revision::userCanBitfield(
426 $row->rev_deleted,
427 Revision::DELETED_COMMENT, $this->getUser()
428 );
429
430 if ( $userCanView ) {
431 if ( $this->fld_comment ) {
432 $vals['comment'] = $row->rev_comment;
433 }
434
435 if ( $this->fld_parsedcomment ) {
436 $vals['parsedcomment'] = Linker::formatComment( $row->rev_comment, $title );
437 }
438 }
439 }
440
441 if ( $this->fld_patrolled ) {
442 $vals['patrolled'] = (bool)$row->rc_patrolled;
443 }
444
445 if ( $this->fld_size && !is_null( $row->rev_len ) ) {
446 $vals['size'] = intval( $row->rev_len );
447 }
448
449 if ( $this->fld_sizediff
450 && !is_null( $row->rev_len )
451 && !is_null( $row->rev_parent_id )
452 ) {
453 $parentLen = isset( $this->parentLens[$row->rev_parent_id] )
454 ? $this->parentLens[$row->rev_parent_id]
455 : 0;
456 $vals['sizediff'] = intval( $row->rev_len - $parentLen );
457 }
458
459 if ( $this->fld_tags ) {
460 if ( $row->ts_tags ) {
461 $tags = explode( ',', $row->ts_tags );
462 ApiResult::setIndexedTagName( $tags, 'tag' );
463 $vals['tags'] = $tags;
464 } else {
465 $vals['tags'] = [];
466 }
467 }
468
469 if ( $anyHidden && $row->rev_deleted & Revision::DELETED_RESTRICTED ) {
470 $vals['suppressed'] = true;
471 }
472
473 return $vals;
474 }
475
476 private function continueStr( $row ) {
477 if ( $this->multiUserMode ) {
478 if ( $this->idMode ) {
479 return "id|$row->rev_user|$row->rev_timestamp|$row->rev_id";
480 } else {
481 return "name|$row->rev_user_text|$row->rev_timestamp|$row->rev_id";
482 }
483 } else {
484 return "$row->rev_timestamp|$row->rev_id";
485 }
486 }
487
488 public function getCacheMode( $params ) {
489 // This module provides access to deleted revisions and patrol flags if
490 // the requester is logged in
491 return 'anon-public-user-private';
492 }
493
494 public function getAllowedParams() {
495 return [
496 'limit' => [
498 ApiBase::PARAM_TYPE => 'limit',
502 ],
503 'start' => [
504 ApiBase::PARAM_TYPE => 'timestamp'
505 ],
506 'end' => [
507 ApiBase::PARAM_TYPE => 'timestamp'
508 ],
509 'continue' => [
510 ApiBase::PARAM_HELP_MSG => 'api-help-param-continue',
511 ],
512 'user' => [
513 ApiBase::PARAM_TYPE => 'user',
515 ],
516 'userids' => [
517 ApiBase::PARAM_TYPE => 'integer',
519 ],
520 'userprefix' => null,
521 'dir' => [
522 ApiBase::PARAM_DFLT => 'older',
524 'newer',
525 'older'
526 ],
527 ApiBase::PARAM_HELP_MSG => 'api-help-param-direction',
528 ],
529 'namespace' => [
531 ApiBase::PARAM_TYPE => 'namespace'
532 ],
533 'prop' => [
535 ApiBase::PARAM_DFLT => 'ids|title|timestamp|comment|size|flags',
537 'ids',
538 'title',
539 'timestamp',
540 'comment',
541 'parsedcomment',
542 'size',
543 'sizediff',
544 'flags',
545 'patrolled',
546 'tags'
547 ],
549 ],
550 'show' => [
553 'minor',
554 '!minor',
555 'patrolled',
556 '!patrolled',
557 'top',
558 '!top',
559 'new',
560 '!new',
561 ],
563 'apihelp-query+usercontribs-param-show',
564 $this->getConfig()->get( 'RCMaxAge' )
565 ],
566 ],
567 'tag' => null,
568 'toponly' => [
569 ApiBase::PARAM_DFLT => false,
571 ],
572 ];
573 }
574
575 protected function getExamplesMessages() {
576 return [
577 'action=query&list=usercontribs&ucuser=Example'
578 => 'apihelp-query+usercontribs-example-user',
579 'action=query&list=usercontribs&ucuserprefix=192.0.2.'
580 => 'apihelp-query+usercontribs-example-ipprefix',
581 ];
582 }
583
584 public function getHelpUrls() {
585 return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Usercontribs';
586 }
587}
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
wfEscapeWikiText( $text)
Escapes the given text so that it may be output using addWikiText() without any linking,...
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
encodeParamName( $paramName)
This method mangles parameter name based on the prefix supplied to the constructor.
Definition ApiBase.php:699
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
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
const PARAM_HELP_MSG
(string|array|Message) Specify an alternative i18n documentation message for this parameter.
Definition ApiBase.php:128
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
requireOnlyOneParameter( $params, $required)
Die if none or more than one of a certain set of parameters is set and not false.
Definition ApiBase.php:754
const PARAM_ISMULTI
(boolean) Accept multiple pipe-separated values for this parameter (e.g.
Definition ApiBase.php:55
This is a base class for all Query modules.
selectNamedDB( $name, $db, $groups)
Selects the query database connection with the given name.
static addTitleInfo(&$arr, $title, $prefix='')
Add information (title and namespace) about a Title object to a result array.
setContinueEnumParameter( $paramName, $paramValue)
Set a query-continue value.
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.
addWhereRange( $field, $dir, $start, $end, $sort=true)
Add a WHERE clause corresponding to a range, and an ORDER BY clause to sort in the right direction.
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.
This query action adds a list of a specified user's contributions to the output.
prepareQuery()
Prepares the query and returns the limit of rows requested.
getHelpUrls()
Return links to more detailed help pages about the module.
getAllowedParams()
Returns an array of allowed parameters (parameter name) => (default value) or (parameter name) => (ar...
execute()
Evaluates the parameters, performs the requested query, and sets up the result.
__construct(ApiQuery $query, $moduleName)
extractRowInfo( $row)
Extract fields from the database row and append them to a result array.
getExamplesMessages()
Returns usage examples for this module.
getCacheMode( $params)
Get the cache mode for the data generated by this module.
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.
getUser()
Get the User object.
getConfig()
Get the Config 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
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,...
static getParentLengths( $db, array $revIds)
Do a batched query to get the parent revision lengths.
Definition Revision.php:546
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
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
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
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist Do not use this to implement individual filters if they are compatible with the ChangesListFilter and ChangesListFilterGroup structure use sub classes of those in conjunction with the ChangesListSpecialPageStructuredFilters hook This hook can be used to implement filters that do not implement that or custom behavior that is not an individual filter e g Watchlist and Watchlist you will want to construct new ChangesListBooleanFilter or ChangesListStringOptionsFilter objects When constructing you specify which group they belong to You can reuse existing or create your you must register them with $special registerFilterGroup removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set and then return false from the hook function Ensure you consume the ChangeTagAfterDelete hook to carry out custom deletion actions as context called by AbstractContent::getParserOutput May be used to override the normal model specific rendering of page content as context as context the output can only depend on parameters provided to this hook not on global state indicating whether full HTML should be generated If generation of HTML may be but other information should still be present in the ParserOutput object to manipulate or replace but no entry for that model exists in $wgContentHandlers please use GetContentModels hook to make them known to core if desired whether it is OK to use $contentModel on $title Handler functions that modify $ok should generally return false to prevent further hooks from further modifying $ok inclusive $limit
Definition hooks.txt:1143
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
Allows to change the fields on the form that will be generated $name
Definition hooks.txt:304
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
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
const DB_REPLICA
Definition defines.php:25