MediaWiki REL1_27
ImageListPager.php
Go to the documentation of this file.
1<?php
26
27 protected $mFieldNames = null;
28
29 // Subclasses should override buildQueryConds instead of using $mQueryConds variable.
30 protected $mQueryConds = [];
31
32 protected $mUserName = null;
33
39 protected $mUser = null;
40
41 protected $mSearch = '';
42
43 protected $mIncluding = false;
44
45 protected $mShowAll = false;
46
47 protected $mTableName = 'image';
48
49 function __construct( IContextSource $context, $userName = null, $search = '',
50 $including = false, $showAll = false
51 ) {
52 $this->setContext( $context );
53 $this->mIncluding = $including;
54 $this->mShowAll = $showAll;
55
56 if ( $userName !== null && $userName !== '' ) {
57 $nt = Title::makeTitleSafe( NS_USER, $userName );
58 if ( is_null( $nt ) ) {
59 $this->outputUserDoesNotExist( $userName );
60 } else {
61 $this->mUserName = $nt->getText();
62 $user = User::newFromName( $this->mUserName, false );
63 if ( $user ) {
64 $this->mUser = $user;
65 }
66 if ( !$user || ( $user->isAnon() && !User::isIP( $user->getName() ) ) ) {
67 $this->outputUserDoesNotExist( $userName );
68 }
69 }
70 }
71
72 if ( $search !== '' && !$this->getConfig()->get( 'MiserMode' ) ) {
73 $this->mSearch = $search;
74 $nt = Title::newFromText( $this->mSearch );
75
76 if ( $nt ) {
78 $this->mQueryConds[] = 'LOWER(img_name)' .
79 $dbr->buildLike( $dbr->anyString(),
80 strtolower( $nt->getDBkey() ), $dbr->anyString() );
81 }
82 }
83
84 if ( !$including ) {
85 if ( $this->getRequest()->getText( 'sort', 'img_date' ) == 'img_date' ) {
86 $this->mDefaultDirection = IndexPager::DIR_DESCENDING;
87 } else {
88 $this->mDefaultDirection = IndexPager::DIR_ASCENDING;
89 }
90 } else {
91 $this->mDefaultDirection = IndexPager::DIR_DESCENDING;
92 }
93
94 parent::__construct( $context );
95 }
96
102 function getRelevantUser() {
103 return $this->mUser;
104 }
105
111 protected function outputUserDoesNotExist( $userName ) {
112 $this->getOutput()->wrapWikiMsg(
113 "<div class=\"mw-userpage-userdoesnotexist error\">\n$1\n</div>",
114 [
115 'listfiles-userdoesnotexist',
116 wfEscapeWikiText( $userName ),
117 ]
118 );
119 }
120
128 protected function buildQueryConds( $table ) {
129 $prefix = $table === 'image' ? 'img' : 'oi';
130 $conds = [];
131
132 if ( !is_null( $this->mUserName ) ) {
133 $conds[$prefix . '_user_text'] = $this->mUserName;
134 }
135
136 if ( $this->mSearch !== '' ) {
137 $nt = Title::newFromText( $this->mSearch );
138 if ( $nt ) {
139 $dbr = wfGetDB( DB_SLAVE );
140 $conds[] = 'LOWER(' . $prefix . '_name)' .
141 $dbr->buildLike( $dbr->anyString(),
142 strtolower( $nt->getDBkey() ), $dbr->anyString() );
143 }
144 }
145
146 if ( $table === 'oldimage' ) {
147 // Don't want to deal with revdel.
148 // Future fixme: Show partial information as appropriate.
149 // Would have to be careful about filtering by username when username is deleted.
150 $conds['oi_deleted'] = 0;
151 }
152
153 // Add mQueryConds in case anyone was subclassing and using the old variable.
154 return $conds + $this->mQueryConds;
155 }
156
160 function getFieldNames() {
161 if ( !$this->mFieldNames ) {
162 $this->mFieldNames = [
163 'img_timestamp' => $this->msg( 'listfiles_date' )->text(),
164 'img_name' => $this->msg( 'listfiles_name' )->text(),
165 'thumb' => $this->msg( 'listfiles_thumb' )->text(),
166 'img_size' => $this->msg( 'listfiles_size' )->text(),
167 ];
168 if ( is_null( $this->mUserName ) ) {
169 // Do not show username if filtering by username
170 $this->mFieldNames['img_user_text'] = $this->msg( 'listfiles_user' )->text();
171 }
172 // img_description down here, in order so that its still after the username field.
173 $this->mFieldNames['img_description'] = $this->msg( 'listfiles_description' )->text();
174
175 if ( !$this->getConfig()->get( 'MiserMode' ) && !$this->mShowAll ) {
176 $this->mFieldNames['count'] = $this->msg( 'listfiles_count' )->text();
177 }
178 if ( $this->mShowAll ) {
179 $this->mFieldNames['top'] = $this->msg( 'listfiles-latestversion' )->text();
180 }
181 }
182
183 return $this->mFieldNames;
184 }
185
186 function isFieldSortable( $field ) {
187 if ( $this->mIncluding ) {
188 return false;
189 }
190 $sortable = [ 'img_timestamp', 'img_name', 'img_size' ];
191 /* For reference, the indicies we can use for sorting are:
192 * On the image table: img_usertext_timestamp, img_size, img_timestamp
193 * On oldimage: oi_usertext_timestamp, oi_name_timestamp
194 *
195 * In particular that means we cannot sort by timestamp when not filtering
196 * by user and including old images in the results. Which is sad.
197 */
198 if ( $this->getConfig()->get( 'MiserMode' ) && !is_null( $this->mUserName ) ) {
199 // If we're sorting by user, the index only supports sorting by time.
200 if ( $field === 'img_timestamp' ) {
201 return true;
202 } else {
203 return false;
204 }
205 } elseif ( $this->getConfig()->get( 'MiserMode' )
206 && $this->mShowAll /* && mUserName === null */
207 ) {
208 // no oi_timestamp index, so only alphabetical sorting in this case.
209 if ( $field === 'img_name' ) {
210 return true;
211 } else {
212 return false;
213 }
214 }
215
216 return in_array( $field, $sortable );
217 }
218
219 function getQueryInfo() {
220 // Hacky Hacky Hacky - I want to get query info
221 // for two different tables, without reimplementing
222 // the pager class.
223 $qi = $this->getQueryInfoReal( $this->mTableName );
224
225 return $qi;
226 }
227
238 protected function getQueryInfoReal( $table ) {
239 $prefix = $table === 'oldimage' ? 'oi' : 'img';
240
241 $tables = [ $table ];
242 $fields = array_keys( $this->getFieldNames() );
243
244 if ( $table === 'oldimage' ) {
245 foreach ( $fields as $id => &$field ) {
246 if ( substr( $field, 0, 4 ) !== 'img_' ) {
247 continue;
248 }
249 $field = $prefix . substr( $field, 3 ) . ' AS ' . $field;
250 }
251 $fields[array_search( 'top', $fields )] = "'no' AS top";
252 } else {
253 if ( $this->mShowAll ) {
254 $fields[array_search( 'top', $fields )] = "'yes' AS top";
255 }
256 }
257 $fields[] = $prefix . '_user AS img_user';
258 $fields[array_search( 'thumb', $fields )] = $prefix . '_name AS thumb';
259
260 $options = $join_conds = [];
261
262 # Depends on $wgMiserMode
263 # Will also not happen if mShowAll is true.
264 if ( isset( $this->mFieldNames['count'] ) ) {
265 $tables[] = 'oldimage';
266
267 # Need to rewrite this one
268 foreach ( $fields as &$field ) {
269 if ( $field == 'count' ) {
270 $field = 'COUNT(oi_archive_name) AS count';
271 }
272 }
273 unset( $field );
274
275 $dbr = wfGetDB( DB_SLAVE );
276 if ( $dbr->implicitGroupby() ) {
277 $options = [ 'GROUP BY' => 'img_name' ];
278 } else {
279 $columnlist = preg_grep( '/^img/', array_keys( $this->getFieldNames() ) );
280 $options = [ 'GROUP BY' => array_merge( [ 'img_user' ], $columnlist ) ];
281 }
282 $join_conds = [ 'oldimage' => [ 'LEFT JOIN', 'oi_name = img_name' ] ];
283 }
284
285 return [
286 'tables' => $tables,
287 'fields' => $fields,
288 'conds' => $this->buildQueryConds( $table ),
289 'options' => $options,
290 'join_conds' => $join_conds
291 ];
292 }
293
306 function reallyDoQuery( $offset, $limit, $asc ) {
307 $prevTableName = $this->mTableName;
308 $this->mTableName = 'image';
309 list( $tables, $fields, $conds, $fname, $options, $join_conds ) =
310 $this->buildQueryInfo( $offset, $limit, $asc );
311 $imageRes = $this->mDb->select( $tables, $fields, $conds, $fname, $options, $join_conds );
312 $this->mTableName = $prevTableName;
313
314 if ( !$this->mShowAll ) {
315 return $imageRes;
316 }
317
318 $this->mTableName = 'oldimage';
319
320 # Hacky...
321 $oldIndex = $this->mIndexField;
322 if ( substr( $this->mIndexField, 0, 4 ) !== 'img_' ) {
323 throw new MWException( "Expected to be sorting on an image table field" );
324 }
325 $this->mIndexField = 'oi_' . substr( $this->mIndexField, 4 );
326
327 list( $tables, $fields, $conds, $fname, $options, $join_conds ) =
328 $this->buildQueryInfo( $offset, $limit, $asc );
329 $oldimageRes = $this->mDb->select( $tables, $fields, $conds, $fname, $options, $join_conds );
330
331 $this->mTableName = $prevTableName;
332 $this->mIndexField = $oldIndex;
333
334 return $this->combineResult( $imageRes, $oldimageRes, $limit, $asc );
335 }
336
348 protected function combineResult( $res1, $res2, $limit, $ascending ) {
349 $res1->rewind();
350 $res2->rewind();
351 $topRes1 = $res1->next();
352 $topRes2 = $res2->next();
353 $resultArray = [];
354 for ( $i = 0; $i < $limit && $topRes1 && $topRes2; $i++ ) {
355 if ( strcmp( $topRes1->{$this->mIndexField}, $topRes2->{$this->mIndexField} ) > 0 ) {
356 if ( !$ascending ) {
357 $resultArray[] = $topRes1;
358 $topRes1 = $res1->next();
359 } else {
360 $resultArray[] = $topRes2;
361 $topRes2 = $res2->next();
362 }
363 } else {
364 if ( !$ascending ) {
365 $resultArray[] = $topRes2;
366 $topRes2 = $res2->next();
367 } else {
368 $resultArray[] = $topRes1;
369 $topRes1 = $res1->next();
370 }
371 }
372 }
373
374 // @codingStandardsIgnoreStart Squiz.WhiteSpace.SemicolonSpacing.Incorrect
375 for ( ; $i < $limit && $topRes1; $i++ ) {
376 // @codingStandardsIgnoreEnd
377 $resultArray[] = $topRes1;
378 $topRes1 = $res1->next();
379 }
380
381 // @codingStandardsIgnoreStart Squiz.WhiteSpace.SemicolonSpacing.Incorrect
382 for ( ; $i < $limit && $topRes2; $i++ ) {
383 // @codingStandardsIgnoreEnd
384 $resultArray[] = $topRes2;
385 $topRes2 = $res2->next();
386 }
387
388 return new FakeResultWrapper( $resultArray );
389 }
390
391 function getDefaultSort() {
392 if ( $this->mShowAll && $this->getConfig()->get( 'MiserMode' ) && is_null( $this->mUserName ) ) {
393 // Unfortunately no index on oi_timestamp.
394 return 'img_name';
395 } else {
396 return 'img_timestamp';
397 }
398 }
399
400 function doBatchLookups() {
401 $userIds = [];
402 $this->mResult->seek( 0 );
403 foreach ( $this->mResult as $row ) {
404 $userIds[] = $row->img_user;
405 }
406 # Do a link batch query for names and userpages
407 UserCache::singleton()->doQuery( $userIds, [ 'userpage' ], __METHOD__ );
408 }
409
424 function formatValue( $field, $value ) {
425 switch ( $field ) {
426 case 'thumb':
427 $opt = [ 'time' => wfTimestamp( TS_MW, $this->mCurrentRow->img_timestamp ) ];
428 $file = RepoGroup::singleton()->getLocalRepo()->findFile( $value, $opt );
429 // If statement for paranoia
430 if ( $file ) {
431 $thumb = $file->transform( [ 'width' => 180, 'height' => 360 ] );
432
433 return $thumb->toHtml( [ 'desc-link' => true ] );
434 } else {
435 return htmlspecialchars( $value );
436 }
437 case 'img_timestamp':
438 // We may want to make this a link to the "old" version when displaying old files
439 return htmlspecialchars( $this->getLanguage()->userTimeAndDate( $value, $this->getUser() ) );
440 case 'img_name':
441 static $imgfile = null;
442 if ( $imgfile === null ) {
443 $imgfile = $this->msg( 'imgfile' )->text();
444 }
445
446 // Weird files can maybe exist? Bug 22227
447 $filePage = Title::makeTitleSafe( NS_FILE, $value );
448 if ( $filePage ) {
450 $filePage,
451 htmlspecialchars( $filePage->getText() )
452 );
453 $download = Xml::element( 'a',
454 [ 'href' => wfLocalFile( $filePage )->getUrl() ],
455 $imgfile
456 );
457 $download = $this->msg( 'parentheses' )->rawParams( $download )->escaped();
458
459 // Add delete links if allowed
460 // From https://github.com/Wikia/app/pull/3859
461 if ( $filePage->userCan( 'delete', $this->getUser() ) ) {
462 $deleteMsg = $this->msg( 'listfiles-delete' )->escaped();
463
464 $delete = Linker::linkKnown(
465 $filePage, $deleteMsg, [], [ 'action' => 'delete' ]
466 );
467 $delete = $this->msg( 'parentheses' )->rawParams( $delete )->escaped();
468
469 return "$link $download $delete";
470 }
471
472 return "$link $download";
473 } else {
474 return htmlspecialchars( $value );
475 }
476 case 'img_user_text':
477 if ( $this->mCurrentRow->img_user ) {
478 $name = User::whoIs( $this->mCurrentRow->img_user );
481 htmlspecialchars( $name )
482 );
483 } else {
484 $link = htmlspecialchars( $value );
485 }
486
487 return $link;
488 case 'img_size':
489 return htmlspecialchars( $this->getLanguage()->formatSize( $value ) );
490 case 'img_description':
492 case 'count':
493 return $this->getLanguage()->formatNum( intval( $value ) + 1 );
494 case 'top':
495 // Messages: listfiles-latestversion-yes, listfiles-latestversion-no
496 return $this->msg( 'listfiles-latestversion-' . $value );
497 default:
498 throw new MWException( "Unknown field '$field'" );
499 }
500 }
501
502 function getForm() {
503 $fields = [];
504 $fields['limit'] = [
505 'type' => 'select',
506 'name' => 'limit',
507 'label-message' => 'table_pager_limit_label',
508 'options' => $this->getLimitSelectList(),
509 'default' => $this->mLimit,
510 ];
511
512 if ( !$this->getConfig()->get( 'MiserMode' ) ) {
513 $fields['ilsearch'] = [
514 'type' => 'text',
515 'name' => 'ilsearch',
516 'id' => 'mw-ilsearch',
517 'label-message' => 'listfiles_search_for',
518 'default' => $this->mSearch,
519 'size' => '40',
520 'maxlength' => '255',
521 ];
522 }
523
524 $this->getOutput()->addModules( 'mediawiki.userSuggest' );
525 $fields['user'] = [
526 'type' => 'text',
527 'name' => 'user',
528 'id' => 'mw-listfiles-user',
529 'label-message' => 'username',
530 'default' => $this->mUserName,
531 'size' => '40',
532 'maxlength' => '255',
533 'cssclass' => 'mw-autocomplete-user', // used by mediawiki.userSuggest
534 ];
535
536 $fields['ilshowall'] = [
537 'type' => 'check',
538 'name' => 'ilshowall',
539 'id' => 'mw-listfiles-show-all',
540 'label-message' => 'listfiles-show-all',
541 'default' => $this->mShowAll,
542 ];
543
544 $query = $this->getRequest()->getQueryValues();
545 unset( $query['title'] );
546 unset( $query['limit'] );
547 unset( $query['ilsearch'] );
548 unset( $query['ilshowall'] );
549 unset( $query['user'] );
550
551 $form = new HTMLForm( $fields, $this->getContext() );
552
553 $form->setMethod( 'get' );
554 $form->setTitle( $this->getTitle() );
555 $form->setId( 'mw-listfiles-form' );
556 $form->setWrapperLegendMsg( 'listfiles' );
557 $form->setSubmitTextMsg( 'table_pager_limit_submit' );
558 $form->addHiddenFields( $query );
559
560 $form->prepareForm();
561 $form->displayForm( '' );
562 }
563
564 protected function getTableClass() {
565 return parent::getTableClass() . ' listfiles';
566 }
567
568 protected function getNavClass() {
569 return parent::getNavClass() . ' listfiles_nav';
570 }
571
572 protected function getSortHeaderClass() {
573 return parent::getSortHeaderClass() . ' listfiles_sort';
574 }
575
576 function getPagingQueries() {
577 $queries = parent::getPagingQueries();
578 if ( !is_null( $this->mUserName ) ) {
579 # Append the username to the query string
580 foreach ( $queries as &$query ) {
581 if ( $query !== false ) {
582 $query['user'] = $this->mUserName;
583 }
584 }
585 }
586
587 return $queries;
588 }
589
590 function getDefaultQuery() {
591 $queries = parent::getDefaultQuery();
592 if ( !isset( $queries['user'] ) && !is_null( $this->mUserName ) ) {
593 $queries['user'] = $this->mUserName;
594 }
595
596 return $queries;
597 }
598
599 function getTitle() {
600 return SpecialPage::getTitleFor( 'Listfiles' );
601 }
602}
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
wfLocalFile( $title)
Get an object referring to a locally registered file.
const TS_MW
MediaWiki concatenated string timestamp (YYYYMMDDHHMMSS)
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,...
$i
Definition Parser.php:1694
if(!defined( 'MEDIAWIKI')) $fname
This file is not a valid entry point, perform no further processing unless MEDIAWIKI is defined.
Definition Setup.php:35
getRequest()
Get the WebRequest object.
getConfig()
Get the Config object.
msg()
Get a Message object with context set Parameters are the same as wfMessage()
getOutput()
Get the OutputPage object.
IContextSource $context
setContext(IContextSource $context)
Set the IContextSource object.
Overloads the relevant methods of the real ResultsWrapper so it doesn't go anywhere near an actual da...
Object handling generic submission, CSRF protection, layout and other logic for UI forms.
Definition HTMLForm.php:123
getDefaultSort()
The database field name used as a default sort order.
formatValue( $field, $value)
outputUserDoesNotExist( $userName)
Add a message to the output stating that the user doesn't exist.
getTitle()
Get the Title object.
buildQueryConds( $table)
Build the where clause of the query.
doBatchLookups()
Called from getBody(), before getStartBody() is called and after doQuery() was called.
combineResult( $res1, $res2, $limit, $ascending)
Combine results from 2 tables.
User null $mUser
The relevant user.
reallyDoQuery( $offset, $limit, $asc)
Override reallyDoQuery to mix together two queries.
getRelevantUser()
Get the user relevant to the ImageList.
getQueryInfo()
This function should be overridden to provide all parameters needed for the main paged query.
getDefaultQuery()
Get an array of query parameters that should be put into self-links.
getPagingQueries()
Get a URL query array for the prev, next, first and last links.
getQueryInfoReal( $table)
Actually get the query info.
__construct(IContextSource $context, $userName=null, $search='', $including=false, $showAll=false)
isFieldSortable( $field)
Return true if the named field should be sortable by the UI, false otherwise.
$mIndexField
The index to actually be used for ordering.
const DIR_ASCENDING
Constants for the $mDefaultDirection field.
buildQueryInfo( $offset, $limit, $descending)
Build variables to use by the database wrapper.
const DIR_DESCENDING
static link( $target, $html=null, $customAttribs=[], $query=[], $options=[])
This function returns an HTML link to the given target.
Definition Linker.php:195
static linkKnown( $target, $html=null, $customAttribs=[], $query=[], $options=[ 'known', 'noclasses'])
Identical to link(), except $options defaults to 'known'.
Definition Linker.php:264
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:1290
MediaWiki exception.
static singleton()
Get a RepoGroup instance.
Definition RepoGroup.php:59
static getTitleFor( $name, $subpage=false, $fragment='')
Get a localised Title object for a specified special page name.
Table-based display with a user-selectable sort order.
static & makeTitle( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Definition Title.php:524
static newFromText( $text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
Definition Title.php:277
static makeTitleSafe( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Definition Title.php:548
static singleton()
Definition UserCache.php:34
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
Definition User.php:47
static element( $element, $attribs=null, $contents='', $allowShortTag=true)
Format an XML element with given attributes and, optionally, text content.
Definition Xml.php:39
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
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 NS_USER
Definition Defines.php:72
const NS_FILE
Definition Defines.php:76
const DB_SLAVE
Definition Defines.php:47
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 e g Watchlist & $tables
Definition hooks.txt:986
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist 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 $options
Definition hooks.txt:1042
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist 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 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:1081
the value to return A Title object or null for latest to be modified or replaced by the hook handler or if authentication is not possible after cache objects are set for highlighting & $link
Definition hooks.txt:2692
Allows to change the fields on the form that will be generated $name
Definition hooks.txt:314
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:1458
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
Interface for objects which can provide a MediaWiki context on request.
$queries