MediaWiki  1.30.0
ApiQueryLogEvents.php
Go to the documentation of this file.
1 <?php
33 
34  private $commentStore;
35 
36  public function __construct( ApiQuery $query, $moduleName ) {
37  parent::__construct( $query, $moduleName, 'le' );
38  }
39 
40  private $fld_ids = false, $fld_title = false, $fld_type = false,
41  $fld_user = false, $fld_userid = false,
42  $fld_timestamp = false, $fld_comment = false, $fld_parsedcomment = false,
43  $fld_details = false, $fld_tags = false;
44 
45  public function execute() {
46  $params = $this->extractRequestParams();
47  $db = $this->getDB();
48  $this->commentStore = new CommentStore( 'log_comment' );
49  $this->requireMaxOneParameter( $params, 'title', 'prefix', 'namespace' );
50 
51  $prop = array_flip( $params['prop'] );
52 
53  $this->fld_ids = isset( $prop['ids'] );
54  $this->fld_title = isset( $prop['title'] );
55  $this->fld_type = isset( $prop['type'] );
56  $this->fld_user = isset( $prop['user'] );
57  $this->fld_userid = isset( $prop['userid'] );
58  $this->fld_timestamp = isset( $prop['timestamp'] );
59  $this->fld_comment = isset( $prop['comment'] );
60  $this->fld_parsedcomment = isset( $prop['parsedcomment'] );
61  $this->fld_details = isset( $prop['details'] );
62  $this->fld_tags = isset( $prop['tags'] );
63 
64  $hideLogs = LogEventsList::getExcludeClause( $db, 'user', $this->getUser() );
65  if ( $hideLogs !== false ) {
66  $this->addWhere( $hideLogs );
67  }
68 
69  // Order is significant here
70  $this->addTables( [ 'logging', 'user', 'page' ] );
71  $this->addJoinConds( [
72  'user' => [ 'LEFT JOIN',
73  'user_id=log_user' ],
74  'page' => [ 'LEFT JOIN',
75  [ 'log_namespace=page_namespace',
76  'log_title=page_title' ] ] ] );
77 
78  $this->addFields( [
79  'log_id',
80  'log_type',
81  'log_action',
82  'log_timestamp',
83  'log_deleted',
84  ] );
85 
86  $this->addFieldsIf( 'page_id', $this->fld_ids );
87  // log_page is the page_id saved at log time, whereas page_id is from a
88  // join at query time. This leads to different results in various
89  // scenarios, e.g. deletion, recreation.
90  $this->addFieldsIf( 'log_page', $this->fld_ids );
91  $this->addFieldsIf( [ 'log_user', 'log_user_text', 'user_name' ], $this->fld_user );
92  $this->addFieldsIf( 'log_user', $this->fld_userid );
93  $this->addFieldsIf(
94  [ 'log_namespace', 'log_title' ],
95  $this->fld_title || $this->fld_parsedcomment
96  );
97  $this->addFieldsIf( 'log_params', $this->fld_details );
98 
99  if ( $this->fld_comment || $this->fld_parsedcomment ) {
100  $commentQuery = $this->commentStore->getJoin();
101  $this->addTables( $commentQuery['tables'] );
102  $this->addFields( $commentQuery['fields'] );
103  $this->addJoinConds( $commentQuery['joins'] );
104  }
105 
106  if ( $this->fld_tags ) {
107  $this->addTables( 'tag_summary' );
108  $this->addJoinConds( [ 'tag_summary' => [ 'LEFT JOIN', 'log_id=ts_log_id' ] ] );
109  $this->addFields( 'ts_tags' );
110  }
111 
112  if ( !is_null( $params['tag'] ) ) {
113  $this->addTables( 'change_tag' );
114  $this->addJoinConds( [ 'change_tag' => [ 'INNER JOIN',
115  [ 'log_id=ct_log_id' ] ] ] );
116  $this->addWhereFld( 'ct_tag', $params['tag'] );
117  }
118 
119  if ( !is_null( $params['action'] ) ) {
120  // Do validation of action param, list of allowed actions can contains wildcards
121  // Allow the param, when the actions is in the list or a wildcard version is listed.
122  $logAction = $params['action'];
123  if ( strpos( $logAction, '/' ) === false ) {
124  // all items in the list have a slash
125  $valid = false;
126  } else {
127  $logActions = array_flip( $this->getAllowedLogActions() );
128  list( $type, $action ) = explode( '/', $logAction, 2 );
129  $valid = isset( $logActions[$logAction] ) || isset( $logActions[$type . '/*'] );
130  }
131 
132  if ( !$valid ) {
133  $encParamName = $this->encodeParamName( 'action' );
134  $this->dieWithError(
135  [ 'apierror-unrecognizedvalue', $encParamName, wfEscapeWikiText( $logAction ) ],
136  "unknown_$encParamName"
137  );
138  }
139 
140  $this->addWhereFld( 'log_type', $type );
141  $this->addWhereFld( 'log_action', $action );
142  } elseif ( !is_null( $params['type'] ) ) {
143  $this->addWhereFld( 'log_type', $params['type'] );
144  }
145 
146  $this->addTimestampWhereRange(
147  'log_timestamp',
148  $params['dir'],
149  $params['start'],
150  $params['end']
151  );
152  // Include in ORDER BY for uniqueness
153  $this->addWhereRange( 'log_id', $params['dir'], null, null );
154 
155  if ( !is_null( $params['continue'] ) ) {
156  $cont = explode( '|', $params['continue'] );
157  $this->dieContinueUsageIf( count( $cont ) != 2 );
158  $op = ( $params['dir'] === 'newer' ? '>' : '<' );
159  $continueTimestamp = $db->addQuotes( $db->timestamp( $cont[0] ) );
160  $continueId = (int)$cont[1];
161  $this->dieContinueUsageIf( $continueId != $cont[1] );
162  $this->addWhere( "log_timestamp $op $continueTimestamp OR " .
163  "(log_timestamp = $continueTimestamp AND " .
164  "log_id $op= $continueId)"
165  );
166  }
167 
168  $limit = $params['limit'];
169  $this->addOption( 'LIMIT', $limit + 1 );
170 
171  $user = $params['user'];
172  if ( !is_null( $user ) ) {
173  $userid = User::idFromName( $user );
174  if ( $userid ) {
175  $this->addWhereFld( 'log_user', $userid );
176  } else {
177  $this->addWhereFld( 'log_user_text', $user );
178  }
179  }
180 
181  $title = $params['title'];
182  if ( !is_null( $title ) ) {
183  $titleObj = Title::newFromText( $title );
184  if ( is_null( $titleObj ) ) {
185  $this->dieWithError( [ 'apierror-invalidtitle', wfEscapeWikiText( $title ) ] );
186  }
187  $this->addWhereFld( 'log_namespace', $titleObj->getNamespace() );
188  $this->addWhereFld( 'log_title', $titleObj->getDBkey() );
189  }
190 
191  if ( $params['namespace'] !== null ) {
192  $this->addWhereFld( 'log_namespace', $params['namespace'] );
193  }
194 
195  $prefix = $params['prefix'];
196 
197  if ( !is_null( $prefix ) ) {
198  if ( $this->getConfig()->get( 'MiserMode' ) ) {
199  $this->dieWithError( 'apierror-prefixsearchdisabled' );
200  }
201 
202  $title = Title::newFromText( $prefix );
203  if ( is_null( $title ) ) {
204  $this->dieWithError( [ 'apierror-invalidtitle', wfEscapeWikiText( $prefix ) ] );
205  }
206  $this->addWhereFld( 'log_namespace', $title->getNamespace() );
207  $this->addWhere( 'log_title ' . $db->buildLike( $title->getDBkey(), $db->anyString() ) );
208  }
209 
210  // Paranoia: avoid brute force searches (T19342)
211  if ( $params['namespace'] !== null || !is_null( $title ) || !is_null( $user ) ) {
212  if ( !$this->getUser()->isAllowed( 'deletedhistory' ) ) {
213  $titleBits = LogPage::DELETED_ACTION;
214  $userBits = LogPage::DELETED_USER;
215  } elseif ( !$this->getUser()->isAllowedAny( 'suppressrevision', 'viewsuppressed' ) ) {
218  } else {
219  $titleBits = 0;
220  $userBits = 0;
221  }
222  if ( ( $params['namespace'] !== null || !is_null( $title ) ) && $titleBits ) {
223  $this->addWhere( $db->bitAnd( 'log_deleted', $titleBits ) . " != $titleBits" );
224  }
225  if ( !is_null( $user ) && $userBits ) {
226  $this->addWhere( $db->bitAnd( 'log_deleted', $userBits ) . " != $userBits" );
227  }
228  }
229 
230  $count = 0;
231  $res = $this->select( __METHOD__ );
232  $result = $this->getResult();
233  foreach ( $res as $row ) {
234  if ( ++$count > $limit ) {
235  // We've reached the one extra which shows that there are
236  // additional pages to be had. Stop here...
237  $this->setContinueEnumParameter( 'continue', "$row->log_timestamp|$row->log_id" );
238  break;
239  }
240 
241  $vals = $this->extractRowInfo( $row );
242  $fit = $result->addValue( [ 'query', $this->getModuleName() ], null, $vals );
243  if ( !$fit ) {
244  $this->setContinueEnumParameter( 'continue', "$row->log_timestamp|$row->log_id" );
245  break;
246  }
247  }
248  $result->addIndexedTagName( [ 'query', $this->getModuleName() ], 'item' );
249  }
250 
262  public static function addLogParams( $result, &$vals, $params, $type,
263  $action, $ts, $legacy = false
264  ) {
265  wfDeprecated( __METHOD__, '1.25' );
266 
267  $entry = new ManualLogEntry( $type, $action );
268  $entry->setParameters( $params );
269  $entry->setTimestamp( $ts );
270  $entry->setLegacy( $legacy );
271  $formatter = LogFormatter::newFromEntry( $entry );
272  $vals['params'] = $formatter->formatParametersForApi();
273 
274  return $vals;
275  }
276 
277  private function extractRowInfo( $row ) {
278  $logEntry = DatabaseLogEntry::newFromRow( $row );
279  $vals = [
280  ApiResult::META_TYPE => 'assoc',
281  ];
282  $anyHidden = false;
283  $user = $this->getUser();
284 
285  if ( $this->fld_ids ) {
286  $vals['logid'] = intval( $row->log_id );
287  }
288 
289  if ( $this->fld_title || $this->fld_parsedcomment ) {
290  $title = Title::makeTitle( $row->log_namespace, $row->log_title );
291  }
292 
293  if ( $this->fld_title || $this->fld_ids || $this->fld_details && $row->log_params !== '' ) {
295  $vals['actionhidden'] = true;
296  $anyHidden = true;
297  }
299  if ( $this->fld_title ) {
301  }
302  if ( $this->fld_ids ) {
303  $vals['pageid'] = intval( $row->page_id );
304  $vals['logpage'] = intval( $row->log_page );
305  }
306  if ( $this->fld_details ) {
307  $vals['params'] = LogFormatter::newFromEntry( $logEntry )->formatParametersForApi();
308  }
309  }
310  }
311 
312  if ( $this->fld_type ) {
313  $vals['type'] = $row->log_type;
314  $vals['action'] = $row->log_action;
315  }
316 
317  if ( $this->fld_user || $this->fld_userid ) {
319  $vals['userhidden'] = true;
320  $anyHidden = true;
321  }
323  if ( $this->fld_user ) {
324  $vals['user'] = $row->user_name === null ? $row->log_user_text : $row->user_name;
325  }
326  if ( $this->fld_userid ) {
327  $vals['userid'] = intval( $row->log_user );
328  }
329 
330  if ( !$row->log_user ) {
331  $vals['anon'] = true;
332  }
333  }
334  }
335  if ( $this->fld_timestamp ) {
336  $vals['timestamp'] = wfTimestamp( TS_ISO_8601, $row->log_timestamp );
337  }
338 
339  if ( $this->fld_comment || $this->fld_parsedcomment ) {
341  $vals['commenthidden'] = true;
342  $anyHidden = true;
343  }
345  $comment = $this->commentStore->getComment( $row )->text;
346  if ( $this->fld_comment ) {
347  $vals['comment'] = $comment;
348  }
349 
350  if ( $this->fld_parsedcomment ) {
351  $vals['parsedcomment'] = Linker::formatComment( $comment, $title );
352  }
353  }
354  }
355 
356  if ( $this->fld_tags ) {
357  if ( $row->ts_tags ) {
358  $tags = explode( ',', $row->ts_tags );
359  ApiResult::setIndexedTagName( $tags, 'tag' );
360  $vals['tags'] = $tags;
361  } else {
362  $vals['tags'] = [];
363  }
364  }
365 
366  if ( $anyHidden && LogEventsList::isDeleted( $row, LogPage::DELETED_RESTRICTED ) ) {
367  $vals['suppressed'] = true;
368  }
369 
370  return $vals;
371  }
372 
376  private function getAllowedLogActions() {
377  $config = $this->getConfig();
378  return array_keys( array_merge(
379  $config->get( 'LogActions' ),
380  $config->get( 'LogActionsHandlers' )
381  ) );
382  }
383 
384  public function getCacheMode( $params ) {
385  if ( $this->userCanSeeRevDel() ) {
386  return 'private';
387  }
388  if ( !is_null( $params['prop'] ) && in_array( 'parsedcomment', $params['prop'] ) ) {
389  // formatComment() calls wfMessage() among other things
390  return 'anon-public-user-private';
391  } elseif ( LogEventsList::getExcludeClause( $this->getDB(), 'user', $this->getUser() )
392  === LogEventsList::getExcludeClause( $this->getDB(), 'public' )
393  ) { // Output can only contain public data.
394  return 'public';
395  } else {
396  return 'anon-public-user-private';
397  }
398  }
399 
400  public function getAllowedParams( $flags = 0 ) {
401  $config = $this->getConfig();
402  $ret = [
403  'prop' => [
404  ApiBase::PARAM_ISMULTI => true,
405  ApiBase::PARAM_DFLT => 'ids|title|type|user|timestamp|comment|details',
407  'ids',
408  'title',
409  'type',
410  'user',
411  'userid',
412  'timestamp',
413  'comment',
414  'parsedcomment',
415  'details',
416  'tags'
417  ],
419  ],
420  'type' => [
421  ApiBase::PARAM_TYPE => $config->get( 'LogTypes' )
422  ],
423  'action' => [
424  // validation on request is done in execute()
426  ? $this->getAllowedLogActions()
427  : null
428  ],
429  'start' => [
430  ApiBase::PARAM_TYPE => 'timestamp'
431  ],
432  'end' => [
433  ApiBase::PARAM_TYPE => 'timestamp'
434  ],
435  'dir' => [
436  ApiBase::PARAM_DFLT => 'older',
438  'newer',
439  'older'
440  ],
441  ApiBase::PARAM_HELP_MSG => 'api-help-param-direction',
442  ],
443  'user' => [
444  ApiBase::PARAM_TYPE => 'user',
445  ],
446  'title' => null,
447  'namespace' => [
448  ApiBase::PARAM_TYPE => 'namespace',
450  ],
451  'prefix' => [],
452  'tag' => null,
453  'limit' => [
454  ApiBase::PARAM_DFLT => 10,
455  ApiBase::PARAM_TYPE => 'limit',
456  ApiBase::PARAM_MIN => 1,
459  ],
460  'continue' => [
461  ApiBase::PARAM_HELP_MSG => 'api-help-param-continue',
462  ],
463  ];
464 
465  if ( $config->get( 'MiserMode' ) ) {
466  $ret['prefix'][ApiBase::PARAM_HELP_MSG] = 'api-help-param-disabled-in-miser-mode';
467  }
468 
469  return $ret;
470  }
471 
472  protected function getExamplesMessages() {
473  return [
474  'action=query&list=logevents'
475  => 'apihelp-query+logevents-example-simple',
476  ];
477  }
478 
479  public function getHelpUrls() {
480  return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Logevents';
481  }
482 }
ContextSource\getConfig
getConfig()
Get the Config object.
Definition: ContextSource.php:68
$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:244
Title\newFromText
static newFromText( $text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
Definition: Title.php:268
ApiQueryBase\addFields
addFields( $value)
Add a set of fields to select to the internal array.
Definition: ApiQueryBase.php:196
ApiQuery
This is the main query class.
Definition: ApiQuery.php:40
ApiQueryLogEvents\addLogParams
static addLogParams( $result, &$vals, $params, $type, $action, $ts, $legacy=false)
Definition: ApiQueryLogEvents.php:262
ApiQueryLogEvents\getExamplesMessages
getExamplesMessages()
Returns usage examples for this module.
Definition: ApiQueryLogEvents.php:472
captcha-old.count
count
Definition: captcha-old.py:249
ApiResult\META_TYPE
const META_TYPE
Key for the 'type' metadata item.
Definition: ApiResult.php:108
ApiBase\dieWithError
dieWithError( $msg, $code=null, $data=null, $httpCode=null)
Abort execution with an error.
Definition: ApiBase.php:1855
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:319
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:1963
wfTimestamp
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
Definition: GlobalFunctions.php:2040
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
ApiQueryLogEvents\$fld_comment
$fld_comment
Definition: ApiQueryLogEvents.php:42
ApiBase\getResult
getResult()
Get the result object.
Definition: ApiBase.php:632
CommentStore
CommentStore handles storage of comments (edit summaries, log reasons, etc) in the database.
Definition: CommentStore.php:30
$params
$params
Definition: styleTest.css.php:40
ApiQueryLogEvents\$fld_userid
$fld_userid
Definition: ApiQueryLogEvents.php:41
$res
$res
Definition: database.txt:21
ApiQueryBase\addOption
addOption( $name, $value=null)
Add an option such as LIMIT or USE INDEX.
Definition: ApiQueryBase.php:331
ContextSource\getUser
getUser()
Get the User object.
Definition: ContextSource.php:133
ApiQueryLogEvents\$fld_timestamp
$fld_timestamp
Definition: ApiQueryLogEvents.php:42
ApiQueryLogEvents\__construct
__construct(ApiQuery $query, $moduleName)
Definition: ApiQueryLogEvents.php:36
ApiQueryLogEvents
Query action to List the log events, with optional filtering by various parameters.
Definition: ApiQueryLogEvents.php:32
ApiQueryBase\addFieldsIf
addFieldsIf( $value, $condition)
Same as addFields(), but add the fields only if a condition is met.
Definition: ApiQueryBase.php:210
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
ApiQueryLogEvents\$commentStore
$commentStore
Definition: ApiQueryLogEvents.php:34
$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:1581
NS_SPECIAL
const NS_SPECIAL
Definition: Defines.php:54
ApiBase\PARAM_MIN
const PARAM_MIN
(integer) Lowest value allowed for the parameter, for PARAM_TYPE 'integer' and 'limit'.
Definition: ApiBase.php:103
ApiQueryLogEvents\$fld_details
$fld_details
Definition: ApiQueryLogEvents.php:43
$title
namespace and then decline to actually register it file or subcat img or subcat $title
Definition: hooks.txt:932
DatabaseLogEntry\newFromRow
static newFromRow( $row)
Constructs new LogEntry from database result row.
Definition: LogEntry.php:205
wfDeprecated
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Throws a warning that $function is deprecated.
Definition: GlobalFunctions.php:1176
LogPage\DELETED_COMMENT
const DELETED_COMMENT
Definition: LogPage.php:33
ApiQueryLogEvents\getAllowedParams
getAllowedParams( $flags=0)
Definition: ApiQueryLogEvents.php:400
LogPage\DELETED_USER
const DELETED_USER
Definition: LogPage.php:34
ApiQueryBase
This is a base class for all Query modules.
Definition: ApiQueryBase.php:37
ApiBase\LIMIT_BIG1
const LIMIT_BIG1
Fast query, standard limit.
Definition: ApiBase.php:225
ApiQueryBase\getDB
getDB()
Get the Query database connection (read-only)
Definition: ApiQueryBase.php:109
ApiBase\PARAM_MAX
const PARAM_MAX
(integer) Max value allowed for the parameter, for PARAM_TYPE 'integer' and 'limit'.
Definition: ApiBase.php:94
ApiQueryBase\addTables
addTables( $tables, $alias=null)
Add a set of tables to the internal array.
Definition: ApiQueryBase.php:162
ApiQueryBase\select
select( $method, $extraQuery=[], array &$hookData=null)
Execute a SELECT query based on the values in the internal arrays.
Definition: ApiQueryBase.php:356
Title\makeTitle
static makeTitle( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:529
ApiQueryLogEvents\$fld_type
$fld_type
Definition: ApiQueryLogEvents.php:40
ApiBase\PARAM_EXTRA_NAMESPACES
const PARAM_EXTRA_NAMESPACES
(int[]) When PARAM_TYPE is 'namespace', include these as additional possible values.
Definition: ApiBase.php:189
ApiQueryLogEvents\getHelpUrls
getHelpUrls()
Return links to more detailed help pages about the module.
Definition: ApiQueryLogEvents.php:479
list
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global list
Definition: deferred.txt:11
LogPage\DELETED_ACTION
const DELETED_ACTION
Definition: LogPage.php:32
ApiQueryBase\addWhereRange
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.
Definition: ApiQueryBase.php:284
ApiBase\extractRequestParams
extractRequestParams( $parseLimit=true)
Using getAllowedParams(), this function makes an array of the values provided by the user,...
Definition: ApiBase.php:740
ApiResult\setIndexedTagName
static setIndexedTagName(array &$arr, $tag)
Set the tag name for numeric-keyed values in XML format.
Definition: ApiResult.php:616
ApiQueryLogEvents\$fld_title
$fld_title
Definition: ApiQueryLogEvents.php:40
NS_MEDIA
const NS_MEDIA
Definition: Defines.php:53
ApiBase\dieContinueUsageIf
dieContinueUsageIf( $condition)
Die with the 'badcontinue' error.
Definition: ApiBase.php:2026
ApiBase\encodeParamName
encodeParamName( $paramName)
This method mangles parameter name based on the prefix supplied to the constructor.
Definition: ApiBase.php:721
ApiBase\GET_VALUES_FOR_HELP
const GET_VALUES_FOR_HELP
getAllowedParams() flag: When set, the result could take longer to generate, but should be more thoro...
Definition: ApiBase.php:238
ApiQueryLogEvents\$fld_parsedcomment
$fld_parsedcomment
Definition: ApiQueryLogEvents.php:42
LogEventsList\getExcludeClause
static getExcludeClause( $db, $audience='public', User $user=null)
SQL clause to skip forbidden log types for this user.
Definition: LogEventsList.php:750
ApiQueryBase\addJoinConds
addJoinConds( $join_conds)
Add a set of JOIN conditions to the internal array.
Definition: ApiQueryBase.php:185
wfEscapeWikiText
wfEscapeWikiText( $text)
Escapes the given text so that it may be output using addWikiText() without any linking,...
Definition: GlobalFunctions.php:1703
$ret
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 & $ret
Definition: hooks.txt:1965
ApiQueryBase\addWhereFld
addWhereFld( $field, $value)
Equivalent to addWhere(array($field => $value))
Definition: ApiQueryBase.php:264
ApiBase\requireMaxOneParameter
requireMaxOneParameter( $params, $required)
Die if more than one of a certain set of parameters is set and not false.
Definition: ApiBase.php:814
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:1099
ApiQueryLogEvents\extractRowInfo
extractRowInfo( $row)
Definition: ApiQueryLogEvents.php:277
ApiBase\LIMIT_BIG2
const LIMIT_BIG2
Fast query, apihighlimits limit.
Definition: ApiBase.php:227
User\idFromName
static idFromName( $name, $flags=self::READ_NORMAL)
Get database id given a user name.
Definition: User.php:765
ApiQueryLogEvents\$fld_user
$fld_user
Definition: ApiQueryLogEvents.php:41
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
LogEventsList\userCan
static userCan( $row, $field, User $user=null)
Determine if the current user is allowed to view a particular field of this log row,...
Definition: LogEventsList.php:529
LogEventsList\isDeleted
static isDeleted( $row, $field)
Definition: LogEventsList.php:565
ApiBase\getModuleName
getModuleName()
Get the name of the module being executed by this instance.
Definition: ApiBase.php:512
ApiBase\PARAM_ISMULTI
const PARAM_ISMULTI
(boolean) Accept multiple pipe-separated values for this parameter (e.g.
Definition: ApiBase.php:55
ApiQueryLogEvents\getCacheMode
getCacheMode( $params)
Get the cache mode for the data generated by this module.
Definition: ApiQueryLogEvents.php:384
ApiBase\PARAM_MAX2
const PARAM_MAX2
(integer) Max value allowed for the parameter for users with the apihighlimits right,...
Definition: ApiBase.php:100
ManualLogEntry
Class for creating log entries manually, to inject them into the database.
Definition: LogEntry.php:400
ApiQueryLogEvents\execute
execute()
Evaluates the parameters, performs the requested query, and sets up the result.
Definition: ApiQueryLogEvents.php:45
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:231
ApiQueryBase\setContinueEnumParameter
setContinueEnumParameter( $paramName, $paramValue)
Set a query-continue value.
Definition: ApiQueryBase.php:535
ApiQueryLogEvents\$fld_tags
$fld_tags
Definition: ApiQueryLogEvents.php:43
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
ApiQueryBase\userCanSeeRevDel
userCanSeeRevDel()
Check whether the current user has permission to view revision-deleted fields.
Definition: ApiQueryBase.php:606
ApiQueryLogEvents\$fld_ids
$fld_ids
Definition: ApiQueryLogEvents.php:40
$flags
it s the revision text itself In either if gzip is the revision text is gzipped $flags
Definition: hooks.txt:2801
ApiQueryLogEvents\getAllowedLogActions
getAllowedLogActions()
Definition: ApiQueryLogEvents.php:376
ApiQueryBase\addTitleInfo
static addTitleInfo(&$arr, $title, $prefix='')
Add information (title and namespace) about a Title object to a result array.
Definition: ApiQueryBase.php:486
LogFormatter\newFromEntry
static newFromEntry(LogEntry $entry)
Constructs a new formatter suitable for given entry.
Definition: LogFormatter.php:50
$type
$type
Definition: testCompression.php:48