MediaWiki  1.27.2
SpecialExport.php
Go to the documentation of this file.
1 <?php
31 class SpecialExport extends SpecialPage {
33 
34  public function __construct() {
35  parent::__construct( 'Export' );
36  }
37 
38  public function execute( $par ) {
39  $this->setHeaders();
40  $this->outputHeader();
41  $config = $this->getConfig();
42 
43  // Set some variables
44  $this->curonly = true;
45  $this->doExport = false;
46  $request = $this->getRequest();
47  $this->templates = $request->getCheck( 'templates' );
48  $this->pageLinkDepth = $this->validateLinkDepth(
49  $request->getIntOrNull( 'pagelink-depth' )
50  );
51  $nsindex = '';
52  $exportall = false;
53 
54  if ( $request->getCheck( 'addcat' ) ) {
55  $page = $request->getText( 'pages' );
56  $catname = $request->getText( 'catname' );
57 
58  if ( $catname !== '' && $catname !== null && $catname !== false ) {
59  $t = Title::makeTitleSafe( NS_MAIN, $catname );
60  if ( $t ) {
66  $catpages = $this->getPagesFromCategory( $t );
67  if ( $catpages ) {
68  if ( $page !== '' ) {
69  $page .= "\n";
70  }
71  $page .= implode( "\n", $catpages );
72  }
73  }
74  }
75  } elseif ( $request->getCheck( 'addns' ) && $config->get( 'ExportFromNamespaces' ) ) {
76  $page = $request->getText( 'pages' );
77  $nsindex = $request->getText( 'nsindex', '' );
78 
79  if ( strval( $nsindex ) !== '' ) {
83  $nspages = $this->getPagesFromNamespace( $nsindex );
84  if ( $nspages ) {
85  $page .= "\n" . implode( "\n", $nspages );
86  }
87  }
88  } elseif ( $request->getCheck( 'exportall' ) && $config->get( 'ExportAllowAll' ) ) {
89  $this->doExport = true;
90  $exportall = true;
91 
92  /* Although $page and $history are not used later on, we
93  nevertheless set them to avoid that PHP notices about using
94  undefined variables foul up our XML output (see call to
95  doExport(...) further down) */
96  $page = '';
97  $history = '';
98  } elseif ( $request->wasPosted() && $par == '' ) {
99  $page = $request->getText( 'pages' );
100  $this->curonly = $request->getCheck( 'curonly' );
101  $rawOffset = $request->getVal( 'offset' );
102 
103  if ( $rawOffset ) {
104  $offset = wfTimestamp( TS_MW, $rawOffset );
105  } else {
106  $offset = null;
107  }
108 
109  $maxHistory = $config->get( 'ExportMaxHistory' );
110  $limit = $request->getInt( 'limit' );
111  $dir = $request->getVal( 'dir' );
112  $history = [
113  'dir' => 'asc',
114  'offset' => false,
115  'limit' => $maxHistory,
116  ];
117  $historyCheck = $request->getCheck( 'history' );
118 
119  if ( $this->curonly ) {
120  $history = WikiExporter::CURRENT;
121  } elseif ( !$historyCheck ) {
122  if ( $limit > 0 && ( $maxHistory == 0 || $limit < $maxHistory ) ) {
123  $history['limit'] = $limit;
124  }
125 
126  if ( !is_null( $offset ) ) {
127  $history['offset'] = $offset;
128  }
129 
130  if ( strtolower( $dir ) == 'desc' ) {
131  $history['dir'] = 'desc';
132  }
133  }
134 
135  if ( $page != '' ) {
136  $this->doExport = true;
137  }
138  } else {
139  // Default to current-only for GET requests.
140  $page = $request->getText( 'pages', $par );
141  $historyCheck = $request->getCheck( 'history' );
142 
143  if ( $historyCheck ) {
144  $history = WikiExporter::FULL;
145  } else {
146  $history = WikiExporter::CURRENT;
147  }
148 
149  if ( $page != '' ) {
150  $this->doExport = true;
151  }
152  }
153 
154  if ( !$config->get( 'ExportAllowHistory' ) ) {
155  // Override
156  $history = WikiExporter::CURRENT;
157  }
158 
159  $list_authors = $request->getCheck( 'listauthors' );
160  if ( !$this->curonly || !$config->get( 'ExportAllowListContributors' ) ) {
161  $list_authors = false;
162  }
163 
164  if ( $this->doExport ) {
165  $this->getOutput()->disable();
166 
167  // Cancel output buffering and gzipping if set
168  // This should provide safer streaming for pages with history
170  $request->response()->header( "Content-type: application/xml; charset=utf-8" );
171  $request->response()->header( "X-Robots-Tag: noindex,nofollow" );
172 
173  if ( $request->getCheck( 'wpDownload' ) ) {
174  // Provide a sane filename suggestion
175  $filename = urlencode( $config->get( 'Sitename' ) . '-' . wfTimestampNow() . '.xml' );
176  $request->response()->header( "Content-disposition: attachment;filename={$filename}" );
177  }
178 
179  $this->doExport( $page, $history, $list_authors, $exportall );
180 
181  return;
182  }
183 
184  $out = $this->getOutput();
185  $out->addWikiMsg( 'exporttext' );
186 
187  if ( $page == '' ) {
188  $categoryName = $request->getText( 'catname' );
189  } else {
190  $categoryName = '';
191  }
192 
193  $formDescriptor = [
194  'catname' => [
195  'type' => 'textwithbutton',
196  'name' => 'catname',
197  'horizontal-label' => true,
198  'label-message' => 'export-addcattext',
199  'default' => $categoryName,
200  'size' => 40,
201  'buttontype' => 'submit',
202  'buttonname' => 'addcat',
203  'buttondefault' => $this->msg( 'export-addcat' )->text(),
204  ],
205  ];
206  if ( $config->get( 'ExportFromNamespaces' ) ) {
207  $formDescriptor += [
208  'nsindex' => [
209  'type' => 'namespaceselectwithbutton',
210  'default' => $nsindex,
211  'label-message' => 'export-addnstext',
212  'horizontal-label' => true,
213  'name' => 'nsindex',
214  'id' => 'namespace',
215  'cssclass' => 'namespaceselector',
216  'buttontype' => 'submit',
217  'buttonname' => 'addns',
218  'buttondefault' => $this->msg( 'export-addns' )->text(),
219  ],
220  ];
221  }
222 
223  if ( $config->get( 'ExportAllowAll' ) ) {
224  $formDescriptor += [
225  'exportall' => [
226  'type' => 'check',
227  'label-message' => 'exportall',
228  'name' => 'exportall',
229  'id' => 'exportall',
230  'default' => $request->wasPosted() ? $request->getCheck( 'exportall' ) : false,
231  ],
232  ];
233  }
234 
235  $formDescriptor += [
236  'textarea' => [
237  'class' => 'HTMLTextAreaField',
238  'name' => 'pages',
239  'label-message' => 'export-manual',
240  'nodata' => true,
241  'rows' => 10,
242  'default' => $page,
243  ],
244  ];
245 
246  if ( $config->get( 'ExportAllowHistory' ) ) {
247  $formDescriptor += [
248  'curonly' => [
249  'type' => 'check',
250  'label-message' => 'exportcuronly',
251  'name' => 'curonly',
252  'id' => 'curonly',
253  'default' => $request->wasPosted() ? $request->getCheck( 'curonly' ) : true,
254  ],
255  ];
256  } else {
257  $out->addWikiMsg( 'exportnohistory' );
258  }
259 
260  $formDescriptor += [
261  'templates' => [
262  'type' => 'check',
263  'label-message' => 'export-templates',
264  'name' => 'templates',
265  'id' => 'wpExportTemplates',
266  'default' => $request->wasPosted() ? $request->getCheck( 'templates' ) : false,
267  ],
268  ];
269 
270  if ( $config->get( 'ExportMaxLinkDepth' ) || $this->userCanOverrideExportDepth() ) {
271  $formDescriptor += [
272  'pagelink-depth' => [
273  'type' => 'text',
274  'name' => 'pagelink-depth',
275  'id' => 'pagelink-depth',
276  'label-message' => 'export-pagelinks',
277  'default' => '0',
278  'size' => 20,
279  ],
280  ];
281  }
282 
283  $formDescriptor += [
284  'wpDownload' => [
285  'type' => 'check',
286  'name' =>'wpDownload',
287  'id' => 'wpDownload',
288  'default' => $request->wasPosted() ? $request->getCheck( 'wpDownload' ) : true,
289  'label-message' => 'export-download',
290  ],
291  ];
292 
293  if ( $config->get( 'ExportAllowListContributors' ) ) {
294  $formDescriptor += [
295  'listauthors' => [
296  'type' => 'check',
297  'label-message' => 'exportlistauthors',
298  'default' => $request->wasPosted() ? $request->getCheck( 'listauthors' ) : false,
299  'name' => 'listauthors',
300  'id' => 'listauthors',
301  ],
302  ];
303  }
304 
305  $htmlForm = HTMLForm::factory( 'ooui', $formDescriptor, $this->getContext() );
306  $htmlForm->setSubmitTextMsg( 'export-submit' );
307  $htmlForm->prepareForm()->displayForm( false );
308  $this->addHelpLink( 'Help:Export' );
309  }
310 
314  private function userCanOverrideExportDepth() {
315  return $this->getUser()->isAllowed( 'override-export-depth' );
316  }
317 
327  private function doExport( $page, $history, $list_authors, $exportall ) {
328 
329  // If we are grabbing everything, enable full history and ignore the rest
330  if ( $exportall ) {
331  $history = WikiExporter::FULL;
332  } else {
333  $pageSet = []; // Inverted index of all pages to look up
334 
335  // Split up and normalize input
336  foreach ( explode( "\n", $page ) as $pageName ) {
337  $pageName = trim( $pageName );
338  $title = Title::newFromText( $pageName );
339  if ( $title && !$title->isExternal() && $title->getText() !== '' ) {
340  // Only record each page once!
341  $pageSet[$title->getPrefixedText()] = true;
342  }
343  }
344 
345  // Set of original pages to pass on to further manipulation...
346  $inputPages = array_keys( $pageSet );
347 
348  // Look up any linked pages if asked...
349  if ( $this->templates ) {
350  $pageSet = $this->getTemplates( $inputPages, $pageSet );
351  }
352  $linkDepth = $this->pageLinkDepth;
353  if ( $linkDepth ) {
354  $pageSet = $this->getPageLinks( $inputPages, $pageSet, $linkDepth );
355  }
356 
357  $pages = array_keys( $pageSet );
358 
359  // Normalize titles to the same format and remove dupes, see bug 17374
360  foreach ( $pages as $k => $v ) {
361  $pages[$k] = str_replace( " ", "_", $v );
362  }
363 
364  $pages = array_unique( $pages );
365  }
366 
367  /* Ok, let's get to it... */
368  if ( $history == WikiExporter::CURRENT ) {
369  $lb = false;
370  $db = wfGetDB( DB_SLAVE );
372  } else {
373  // Use an unbuffered query; histories may be very long!
374  $lb = wfGetLBFactory()->newMainLB();
375  $db = $lb->getConnection( DB_SLAVE );
377 
378  // This might take a while... :D
379  MediaWiki\suppressWarnings();
380  set_time_limit( 0 );
381  MediaWiki\restoreWarnings();
382  }
383 
384  $exporter = new WikiExporter( $db, $history, $buffer );
385  $exporter->list_authors = $list_authors;
386  $exporter->openStream();
387 
388  if ( $exportall ) {
389  $exporter->allPages();
390  } else {
391  foreach ( $pages as $page ) {
392  # Bug 8824: Only export pages the user can read
393  $title = Title::newFromText( $page );
394  if ( is_null( $title ) ) {
395  // @todo Perhaps output an <error> tag or something.
396  continue;
397  }
398 
399  if ( !$title->userCan( 'read', $this->getUser() ) ) {
400  // @todo Perhaps output an <error> tag or something.
401  continue;
402  }
403 
404  $exporter->pageByTitle( $title );
405  }
406  }
407 
408  $exporter->closeStream();
409 
410  if ( $lb ) {
411  $lb->closeAll();
412  }
413  }
414 
419  private function getPagesFromCategory( $title ) {
421 
422  $maxPages = $this->getConfig()->get( 'ExportPagelistLimit' );
423 
424  $name = $title->getDBkey();
425 
426  $dbr = wfGetDB( DB_SLAVE );
427  $res = $dbr->select(
428  [ 'page', 'categorylinks' ],
429  [ 'page_namespace', 'page_title' ],
430  [ 'cl_from=page_id', 'cl_to' => $name ],
431  __METHOD__,
432  [ 'LIMIT' => $maxPages ]
433  );
434 
435  $pages = [];
436 
437  foreach ( $res as $row ) {
438  $n = $row->page_title;
439  if ( $row->page_namespace ) {
440  $ns = $wgContLang->getNsText( $row->page_namespace );
441  $n = $ns . ':' . $n;
442  }
443 
444  $pages[] = $n;
445  }
446 
447  return $pages;
448  }
449 
454  private function getPagesFromNamespace( $nsindex ) {
456 
457  $maxPages = $this->getConfig()->get( 'ExportPagelistLimit' );
458 
459  $dbr = wfGetDB( DB_SLAVE );
460  $res = $dbr->select(
461  'page',
462  [ 'page_namespace', 'page_title' ],
463  [ 'page_namespace' => $nsindex ],
464  __METHOD__,
465  [ 'LIMIT' => $maxPages ]
466  );
467 
468  $pages = [];
469 
470  foreach ( $res as $row ) {
471  $n = $row->page_title;
472 
473  if ( $row->page_namespace ) {
474  $ns = $wgContLang->getNsText( $row->page_namespace );
475  $n = $ns . ':' . $n;
476  }
477 
478  $pages[] = $n;
479  }
480 
481  return $pages;
482  }
483 
490  private function getTemplates( $inputPages, $pageSet ) {
491  return $this->getLinks( $inputPages, $pageSet,
492  'templatelinks',
493  [ 'namespace' => 'tl_namespace', 'title' => 'tl_title' ],
494  [ 'page_id=tl_from' ]
495  );
496  }
497 
503  private function validateLinkDepth( $depth ) {
504  if ( $depth < 0 ) {
505  return 0;
506  }
507 
508  if ( !$this->userCanOverrideExportDepth() ) {
509  $maxLinkDepth = $this->getConfig()->get( 'ExportMaxLinkDepth' );
510  if ( $depth > $maxLinkDepth ) {
511  return $maxLinkDepth;
512  }
513  }
514 
515  /*
516  * There's a HARD CODED limit of 5 levels of recursion here to prevent a
517  * crazy-big export from being done by someone setting the depth
518  * number too high. In other words, last resort safety net.
519  */
520 
521  return intval( min( $depth, 5 ) );
522  }
523 
531  private function getPageLinks( $inputPages, $pageSet, $depth ) {
532  // @codingStandardsIgnoreStart Squiz.WhiteSpace.SemicolonSpacing.Incorrect
533  for ( ; $depth > 0; --$depth ) {
534  // @codingStandardsIgnoreEnd
535  $pageSet = $this->getLinks(
536  $inputPages, $pageSet, 'pagelinks',
537  [ 'namespace' => 'pl_namespace', 'title' => 'pl_title' ],
538  [ 'page_id=pl_from' ]
539  );
540  $inputPages = array_keys( $pageSet );
541  }
542 
543  return $pageSet;
544  }
545 
555  private function getLinks( $inputPages, $pageSet, $table, $fields, $join ) {
556  $dbr = wfGetDB( DB_SLAVE );
557 
558  foreach ( $inputPages as $page ) {
559  $title = Title::newFromText( $page );
560 
561  if ( $title ) {
562  $pageSet[$title->getPrefixedText()] = true;
565  $result = $dbr->select(
566  [ 'page', $table ],
567  $fields,
568  array_merge(
569  $join,
570  [
571  'page_namespace' => $title->getNamespace(),
572  'page_title' => $title->getDBkey()
573  ]
574  ),
575  __METHOD__
576  );
577 
578  foreach ( $result as $row ) {
579  $template = Title::makeTitle( $row->namespace, $row->title );
580  $pageSet[$template->getPrefixedText()] = true;
581  }
582  }
583  }
584 
585  return $pageSet;
586  }
587 
588  protected function getGroupName() {
589  return 'pagetools';
590  }
591 }
wfGetDB($db, $groups=[], $wiki=false)
Get a Database object.
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that probably a stub it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping see BaseTemplate::getToolbox and BaseTemplate::makeListItem for details on the format of individual items inside of this array or by returning and letting standard HTTP rendering take place modifiable or by returning false and taking over the output $out
Definition: hooks.txt:762
getTemplates($inputPages, $pageSet)
Expand a list of pages to include templates used in those pages.
getContext()
Gets the context this SpecialPage is executed in.
if(count($args)==0) $dir
const NS_MAIN
Definition: Defines.php:69
A special page that allows users to export pages in a XML file.
static factory($displayFormat)
Construct a HTMLForm object for given display type.
Definition: HTMLForm.php:264
validateLinkDepth($depth)
Validate link depth setting, if available.
msg()
Wrapper around wfMessage that sets the current context.
getOutput()
Get the OutputPage being used for this instance.
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
when a variable name is used in a it is silently declared as a new local masking the global
Definition: design.txt:93
getLinks($inputPages, $pageSet, $table, $fields, $join)
Expand a list of pages to include items used in those pages.
addHelpLink($to, $overrideBaseUrl=false)
Adds help link with an icon via page indicators.
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:Associative array mapping language codes to prefixed links of the form"language:title".&$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':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:1796
outputHeader($summaryMessageKey= '')
Outputs a summary message on top of special pages Per default the message key is the canonical name o...
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that probably a stub it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping $template
Definition: hooks.txt:762
wfTimestamp($outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
Parent class for all special pages.
Definition: SpecialPage.php:36
wfResetOutputBuffers($resetGzipEncoding=true)
Clear away any user-level output buffers, discarding contents.
$res
Definition: database.txt:21
wfTimestampNow()
Convenience function; returns MediaWiki timestamp for the present time.
setHeaders()
Sets headers - this should be called from the execute() method of all derived classes! ...
static makeTitleSafe($ns, $title, $fragment= '', $interwiki= '')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:548
const DB_SLAVE
Definition: Defines.php:46
$buffer
namespace and then decline to actually register it file or subcat img or subcat $title
Definition: hooks.txt:912
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
const TS_MW
MediaWiki concatenated string timestamp (YYYYMMDDHHMMSS)
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
wfGetLBFactory()
Get the load balancer factory object.
error also a ContextSource you ll probably need to make sure the header is varied on $request
Definition: hooks.txt:2418
getPageLinks($inputPages, $pageSet, $depth)
Expand a list of pages to include pages linked to from that page.
getPagesFromCategory($title)
getUser()
Shortcut to get the User executing this instance.
getConfig()
Shortcut to get main config object.
getPagesFromNamespace($nsindex)
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:1004
this class mediates it Skin Encapsulates a look and feel for the wiki All of the functions that render HTML and make choices about how to render it are here and are called from various other places when and is meant to be subclassed with other skins that may override some of its functions The User object contains a reference to a and so rather than having a global skin object we just rely on the global User and get the skin with $wgUser and also has some character encoding functions and other locale stuff The current user interface language is instantiated as and the local content language as $wgContLang
Definition: design.txt:56
doExport($page, $history, $list_authors, $exportall)
Do the actual page exporting.
getRequest()
Get the WebRequest being used for this instance.
static & makeTitle($ns, $title, $fragment= '', $interwiki= '')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:524
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 $page
Definition: hooks.txt:2338
Allows to change the fields on the form that will be generated $name
Definition: hooks.txt:310