MediaWiki  master
ArticleViewTest.php
Go to the documentation of this file.
1 <?php
7 
12 
13  protected function setUp() {
14  parent::setUp();
15 
16  $this->setUserLang( 'qqx' );
17  }
18 
19  private function getHtml( OutputPage $output ) {
20  return preg_replace( '/<!--.*?-->/s', '', $output->getHTML() );
21  }
22 
32  private function getPage( $title, array $revisionContents = [], array &$revisions = [] ) {
33  if ( is_string( $title ) ) {
35  }
36 
37  $page = WikiPage::factory( $title );
38 
39  $user = $this->getTestUser()->getUser();
40 
41  foreach ( $revisionContents as $key => $cont ) {
42  if ( is_string( $cont ) ) {
43  $cont = new WikitextContent( $cont );
44  }
45 
46  $u = $page->newPageUpdater( $user );
47  $u->setContent( SlotRecord::MAIN, $cont );
48  $rev = $u->saveRevision( CommentStoreComment::newUnsavedComment( 'Rev ' . $key ) );
49 
50  $revisions[ $key ] = $rev;
51  }
52 
53  return $page;
54  }
55 
60  public function testGetOldId() {
61  $revisions = [];
62  $page = $this->getPage( __METHOD__, [ 1 => 'Test A', 2 => 'Test B' ], $revisions );
63 
64  $idA = $revisions[1]->getId();
65  $idB = $revisions[2]->getId();
66 
67  // oldid in constructor
68  $article = new Article( $page->getTitle(), $idA );
69  $this->assertSame( $idA, $article->getOldID() );
70  $article->getRevisionFetched();
71  $this->assertSame( $idA, $article->getRevIdFetched() );
72 
73  // oldid 0 in constructor
74  $article = new Article( $page->getTitle(), 0 );
75  $this->assertSame( 0, $article->getOldID() );
76  $article->getRevisionFetched();
77  $this->assertSame( $idB, $article->getRevIdFetched() );
78 
79  // oldid in request
80  $article = new Article( $page->getTitle() );
81  $context = new RequestContext();
82  $context->setRequest( new FauxRequest( [ 'oldid' => $idA ] ) );
83  $article->setContext( $context );
84  $this->assertSame( $idA, $article->getOldID() );
85  $article->getRevisionFetched();
86  $this->assertSame( $idA, $article->getRevIdFetched() );
87 
88  // no oldid
89  $article = new Article( $page->getTitle() );
90  $context = new RequestContext();
91  $context->setRequest( new FauxRequest( [] ) );
92  $article->setContext( $context );
93  $this->assertSame( 0, $article->getOldID() );
94  $article->getRevisionFetched();
95  $this->assertSame( $idB, $article->getRevIdFetched() );
96  }
97 
98  public function testView() {
99  $page = $this->getPage( __METHOD__, [ 1 => 'Test A', 2 => 'Test B' ] );
100 
101  $article = new Article( $page->getTitle(), 0 );
102  $article->getContext()->getOutput()->setTitle( $page->getTitle() );
103  $article->view();
104 
105  $output = $article->getContext()->getOutput();
106  $this->assertContains( 'Test B', $this->getHtml( $output ) );
107  $this->assertNotContains( 'id="mw-revision-info"', $this->getHtml( $output ) );
108  $this->assertNotContains( 'id="mw-revision-nav"', $this->getHtml( $output ) );
109  }
110 
111  public function testViewCached() {
112  $page = $this->getPage( __METHOD__, [ 1 => 'Test A', 2 => 'Test B' ] );
113 
114  $po = new ParserOutput( 'Cached Text' );
115 
116  $article = new Article( $page->getTitle(), 0 );
117  $article->getContext()->getOutput()->setTitle( $page->getTitle() );
118 
119  $cache = MediaWikiServices::getInstance()->getParserCache();
120  $cache->save( $po, $page, $article->getParserOptions() );
121 
122  $article->view();
123 
124  $output = $article->getContext()->getOutput();
125  $this->assertContains( 'Cached Text', $this->getHtml( $output ) );
126  $this->assertNotContains( 'Test A', $this->getHtml( $output ) );
127  $this->assertNotContains( 'Test B', $this->getHtml( $output ) );
128  }
129 
133  public function testViewRedirect() {
134  $target = Title::makeTitle( $this->getDefaultWikitextNS(), 'Test_Target' );
135  $redirectText = '#REDIRECT [[' . $target->getPrefixedText() . ']]';
136 
137  $page = $this->getPage( __METHOD__, [ $redirectText ] );
138 
139  $article = new Article( $page->getTitle(), 0 );
140  $article->getContext()->getOutput()->setTitle( $page->getTitle() );
141  $article->view();
142 
143  $this->assertNotNull(
144  $article->getRedirectTarget()->getPrefixedDBkey()
145  );
146  $this->assertSame(
147  $target->getPrefixedDBkey(),
148  $article->getRedirectTarget()->getPrefixedDBkey()
149  );
150 
151  $output = $article->getContext()->getOutput();
152  $this->assertContains( 'class="redirectText"', $this->getHtml( $output ) );
153  $this->assertContains(
154  '>' . htmlspecialchars( $target->getPrefixedText() ) . '<',
155  $this->getHtml( $output )
156  );
157  }
158 
159  public function testViewNonText() {
160  $dummy = $this->getPage( __METHOD__, [ 'Dummy' ] );
161  $dummyRev = $dummy->getRevision()->getRevisionRecord();
162  $title = $dummy->getTitle();
163 
165  $mockHandler = $this->getMockBuilder( ContentHandler::class )
166  ->setMethods(
167  [
168  'isParserCacheSupported',
169  'serializeContent',
170  'unserializeContent',
171  'makeEmptyContent',
172  ]
173  )
174  ->setConstructorArgs( [ 'NotText', [ 'application/frobnitz' ] ] )
175  ->getMock();
176 
177  $mockHandler->method( 'isParserCacheSupported' )
178  ->willReturn( false );
179 
180  $this->setTemporaryHook(
181  'ContentHandlerForModelID',
182  function ( $id, &$handler ) use ( $mockHandler ) {
183  $handler = $mockHandler;
184  }
185  );
186 
188  $content = $this->getMock( Content::class );
189  $content->method( 'getParserOutput' )
190  ->willReturn( new ParserOutput( 'Structured Output' ) );
191  $content->method( 'getModel' )
192  ->willReturn( 'NotText' );
193  $content->expects( $this->never() )->method( 'getNativeData' );
194  $content->method( 'copy' )
195  ->willReturn( $content );
196 
198  $rev->setId( $dummyRev->getId() );
199  $rev->setPageId( $title->getArticleID() );
200  $rev->setUser( $dummyRev->getUser() );
201  $rev->setComment( $dummyRev->getComment() );
202  $rev->setTimestamp( $dummyRev->getTimestamp() );
203 
204  $rev->setContent( SlotRecord::MAIN, $content );
205 
206  $rev = new Revision( $rev );
207 
209  $page = $this->getMockBuilder( WikiPage::class )
210  ->setMethods( [ 'getRevision', 'getLatest' ] )
211  ->setConstructorArgs( [ $title ] )
212  ->getMock();
213 
214  $page->method( 'getRevision' )
215  ->willReturn( $rev );
216  $page->method( 'getLatest' )
217  ->willReturn( $rev->getId() );
218 
220  $article->getContext()->getOutput()->setTitle( $page->getTitle() );
221  $article->view();
222 
223  $output = $article->getContext()->getOutput();
224  $this->assertContains( 'Structured Output', $this->getHtml( $output ) );
225  $this->assertNotContains( 'Dummy', $this->getHtml( $output ) );
226  }
227 
228  public function testViewOfOldRevision() {
229  $revisions = [];
230  $page = $this->getPage( __METHOD__, [ 1 => 'Test A', 2 => 'Test B' ], $revisions );
231  $idA = $revisions[1]->getId();
232 
233  $article = new Article( $page->getTitle(), $idA );
234  $article->getContext()->getOutput()->setTitle( $page->getTitle() );
235  $article->view();
236 
237  $output = $article->getContext()->getOutput();
238  $this->assertContains( 'Test A', $this->getHtml( $output ) );
239  $this->assertContains( 'id="mw-revision-info"', $output->getSubtitle() );
240  $this->assertContains( 'id="mw-revision-nav"', $output->getSubtitle() );
241 
242  $this->assertNotContains( 'id="revision-info-current"', $output->getSubtitle() );
243  $this->assertNotContains( 'Test B', $this->getHtml( $output ) );
244  }
245 
246  public function testViewOfCurrentRevision() {
247  $revisions = [];
248  $page = $this->getPage( __METHOD__, [ 1 => 'Test A', 2 => 'Test B' ], $revisions );
249  $idB = $revisions[2]->getId();
250 
251  $article = new Article( $page->getTitle(), $idB );
252  $article->getContext()->getOutput()->setTitle( $page->getTitle() );
253  $article->view();
254 
255  $output = $article->getContext()->getOutput();
256  $this->assertContains( 'Test B', $this->getHtml( $output ) );
257  $this->assertContains( 'id="mw-revision-info-current"', $output->getSubtitle() );
258  $this->assertContains( 'id="mw-revision-nav"', $output->getSubtitle() );
259  }
260 
261  public function testViewOfMissingRevision() {
262  $revisions = [];
263  $page = $this->getPage( __METHOD__, [ 1 => 'Test A' ], $revisions );
264  $badId = $revisions[1]->getId() + 100;
265 
266  $article = new Article( $page->getTitle(), $badId );
267  $article->getContext()->getOutput()->setTitle( $page->getTitle() );
268  $article->view();
269 
270  $output = $article->getContext()->getOutput();
271  $this->assertContains( 'missing-revision: ' . $badId, $this->getHtml( $output ) );
272 
273  $this->assertNotContains( 'Test A', $this->getHtml( $output ) );
274  }
275 
276  public function testViewOfDeletedRevision() {
277  $revisions = [];
278  $page = $this->getPage( __METHOD__, [ 1 => 'Test A', 2 => 'Test B' ], $revisions );
279  $idA = $revisions[1]->getId();
280 
281  $revDelList = new RevDelRevisionList(
282  RequestContext::getMain(), $page->getTitle(), [ $idA ]
283  );
284  $revDelList->setVisibility( [
285  'value' => [ RevisionRecord::DELETED_TEXT => 1 ],
286  'comment' => "Testing",
287  ] );
288 
289  $article = new Article( $page->getTitle(), $idA );
290  $article->getContext()->getOutput()->setTitle( $page->getTitle() );
291  $article->view();
292 
293  $output = $article->getContext()->getOutput();
294  $this->assertContains( '(rev-deleted-text-permission)', $this->getHtml( $output ) );
295 
296  $this->assertNotContains( 'Test A', $this->getHtml( $output ) );
297  $this->assertNotContains( 'Test B', $this->getHtml( $output ) );
298  }
299 
301  $revisions = [];
302  $page = $this->getPage( __METHOD__, [ 1 => 'Test A', 2 => 'Test B' ], $revisions );
303  $idA = $revisions[1]->getId();
304 
305  $revDelList = new RevDelRevisionList(
306  RequestContext::getMain(), $page->getTitle(), [ $idA ]
307  );
308  $revDelList->setVisibility( [
309  'value' => [ RevisionRecord::DELETED_TEXT => 1 ],
310  'comment' => "Testing",
311  ] );
312 
313  $article = new Article( $page->getTitle(), $idA );
315  $article->setContext( $context );
316  $context->getOutput()->setTitle( $page->getTitle() );
317  $context->getRequest()->setVal( 'unhide', 1 );
318  $context->setUser( $this->getTestUser( [ 'sysop' ] )->getUser() );
319  $article->view();
320 
321  $output = $article->getContext()->getOutput();
322  $this->assertContains( '(rev-deleted-text-view)', $this->getHtml( $output ) );
323 
324  $this->assertContains( 'Test A', $this->getHtml( $output ) );
325  $this->assertNotContains( 'Test B', $this->getHtml( $output ) );
326  }
327 
328  public function testViewMissingPage() {
329  $page = $this->getPage( __METHOD__ );
330 
331  $article = new Article( $page->getTitle() );
332  $article->getContext()->getOutput()->setTitle( $page->getTitle() );
333  $article->view();
334 
335  $output = $article->getContext()->getOutput();
336  $this->assertContains( '(noarticletextanon)', $this->getHtml( $output ) );
337  }
338 
339  public function testViewDeletedPage() {
340  $page = $this->getPage( __METHOD__, [ 1 => 'Test A', 2 => 'Test B' ] );
341  $page->doDeleteArticle( 'Test' );
342 
343  $article = new Article( $page->getTitle() );
344  $article->getContext()->getOutput()->setTitle( $page->getTitle() );
345  $article->view();
346 
347  $output = $article->getContext()->getOutput();
348  $this->assertContains( 'moveddeleted', $this->getHtml( $output ) );
349  $this->assertContains( 'logentry-delete-delete', $this->getHtml( $output ) );
350  $this->assertContains( '(noarticletextanon)', $this->getHtml( $output ) );
351 
352  $this->assertNotContains( 'Test A', $this->getHtml( $output ) );
353  $this->assertNotContains( 'Test B', $this->getHtml( $output ) );
354  }
355 
356  public function testViewMessagePage() {
357  $title = Title::makeTitle( NS_MEDIAWIKI, 'Mainpage' );
358  $page = $this->getPage( $title );
359 
360  $article = new Article( $page->getTitle() );
361  $article->getContext()->getOutput()->setTitle( $page->getTitle() );
362  $article->view();
363 
364  $output = $article->getContext()->getOutput();
365  $this->assertContains(
366  wfMessage( 'mainpage' )->inContentLanguage()->parse(),
367  $this->getHtml( $output )
368  );
369  $this->assertNotContains( '(noarticletextanon)', $this->getHtml( $output ) );
370  }
371 
372  public function testViewMissingUserPage() {
373  $user = $this->getTestUser()->getUser();
374  $user->addToDatabase();
375 
376  $title = Title::makeTitle( NS_USER, $user->getName() );
377 
378  $page = $this->getPage( $title );
379 
380  $article = new Article( $page->getTitle() );
381  $article->getContext()->getOutput()->setTitle( $page->getTitle() );
382  $article->view();
383 
384  $output = $article->getContext()->getOutput();
385  $this->assertContains( '(noarticletextanon)', $this->getHtml( $output ) );
386  $this->assertNotContains( '(userpage-userdoesnotexist-view)', $this->getHtml( $output ) );
387  }
388 
390  $user = User::newFromName( 'Testing ' . __METHOD__ );
391 
392  $title = Title::makeTitle( NS_USER, $user->getName() );
393 
394  $page = $this->getPage( $title );
395 
396  $article = new Article( $page->getTitle() );
397  $article->getContext()->getOutput()->setTitle( $page->getTitle() );
398  $article->view();
399 
400  $output = $article->getContext()->getOutput();
401  $this->assertContains( '(noarticletextanon)', $this->getHtml( $output ) );
402  $this->assertContains( '(userpage-userdoesnotexist-view:', $this->getHtml( $output ) );
403  }
404 
405  public function testArticleViewHeaderHook() {
406  $page = $this->getPage( __METHOD__, [ 1 => 'Test A' ] );
407 
408  $article = new Article( $page->getTitle(), 0 );
409  $article->getContext()->getOutput()->setTitle( $page->getTitle() );
410 
411  $this->setTemporaryHook(
412  'ArticleViewHeader',
413  function ( Article $articlePage, &$outputDone, &$useParserCache ) use ( $article ) {
414  $this->assertSame( $article, $articlePage, '$articlePage' );
415 
416  $outputDone = new ParserOutput( 'Hook Text' );
417  $outputDone->setTitleText( 'Hook Title' );
418 
419  $articlePage->getContext()->getOutput()->addParserOutput( $outputDone );
420  }
421  );
422 
423  $article->view();
424 
425  $output = $article->getContext()->getOutput();
426  $this->assertNotContains( 'Test A', $this->getHtml( $output ) );
427  $this->assertContains( 'Hook Text', $this->getHtml( $output ) );
428  $this->assertSame( 'Hook Title', $output->getPageTitle() );
429  }
430 
432  $page = $this->getPage( __METHOD__, [ 1 => 'Test A' ] );
433 
434  $article = new Article( $page->getTitle(), 0 );
435  $article->getContext()->getOutput()->setTitle( $page->getTitle() );
436 
437  // use ArticleViewHeader hook to bypass the parser cache
438  $this->setTemporaryHook(
439  'ArticleViewHeader',
440  function ( Article $articlePage, &$outputDone, &$useParserCache ) use ( $article ) {
441  $useParserCache = false;
442  }
443  );
444 
445  $this->setTemporaryHook(
446  'ArticleContentViewCustom',
447  function ( Content $content, Title $title, OutputPage $output ) use ( $page ) {
448  $this->assertSame( $page->getTitle(), $title, '$title' );
449  $this->assertSame( 'Test A', $content->getText(), '$content' );
450 
451  $output->addHTML( 'Hook Text' );
452  return false;
453  }
454  );
455 
456  $this->hideDeprecated(
457  'ArticleContentViewCustom hook (used in hook-ArticleContentViewCustom-closure)'
458  );
459 
460  $article->view();
461 
462  $output = $article->getContext()->getOutput();
463  $this->assertNotContains( 'Test A', $this->getHtml( $output ) );
464  $this->assertContains( 'Hook Text', $this->getHtml( $output ) );
465  }
466 
468  $page = $this->getPage( __METHOD__, [ 1 => 'Test A' ] );
469 
470  $article = new Article( $page->getTitle(), 0 );
471  $article->getContext()->getOutput()->setTitle( $page->getTitle() );
472 
473  // use ArticleViewHeader hook to bypass the parser cache
474  $this->setTemporaryHook(
475  'ArticleViewHeader',
476  function ( Article $articlePage, &$outputDone, &$useParserCache ) use ( $article ) {
477  $useParserCache = false;
478  }
479  );
480 
481  $this->setTemporaryHook(
482  'ArticleRevisionViewCustom',
483  function ( RevisionRecord $rev, Title $title, $oldid, OutputPage $output ) use ( $page ) {
484  $content = $rev->getContent( SlotRecord::MAIN );
485  $this->assertSame( $page->getTitle(), $title, '$title' );
486  $this->assertSame( 'Test A', $content->getText(), '$content' );
487 
488  $output->addHTML( 'Hook Text' );
489  return false;
490  }
491  );
492 
493  $article->view();
494 
495  $output = $article->getContext()->getOutput();
496  $this->assertNotContains( 'Test A', $this->getHtml( $output ) );
497  $this->assertContains( 'Hook Text', $this->getHtml( $output ) );
498  }
499 
501  $page = $this->getPage( __METHOD__, [ 1 => 'Test A' ] );
502 
503  $article = new Article( $page->getTitle(), 0 );
504  $article->getContext()->getOutput()->setTitle( $page->getTitle() );
505 
506  // use ArticleViewHeader hook to bypass the parser cache
507  $this->setTemporaryHook(
508  'ArticleViewHeader',
509  function ( Article $articlePage, &$outputDone, &$useParserCache ) use ( $article ) {
510  $useParserCache = false;
511  }
512  );
513 
514  $this->setTemporaryHook(
515  'ArticleAfterFetchContentObject',
516  function ( Article &$articlePage, Content &$content ) use ( $page, $article ) {
517  $this->assertSame( $article, $articlePage, '$articlePage' );
518  $this->assertSame( 'Test A', $content->getText(), '$content' );
519 
520  $content = new WikitextContent( 'Hook Text' );
521  }
522  );
523 
524  $this->hideDeprecated(
525  'ArticleAfterFetchContentObject hook'
526  . ' (used in hook-ArticleAfterFetchContentObject-closure)'
527  );
528 
529  $article->view();
530 
531  $output = $article->getContext()->getOutput();
532  $this->assertNotContains( 'Test A', $this->getHtml( $output ) );
533  $this->assertContains( 'Hook Text', $this->getHtml( $output ) );
534  }
535 
536  public function testShowMissingArticleHook() {
537  $page = $this->getPage( __METHOD__ );
538 
539  $article = new Article( $page->getTitle() );
540  $article->getContext()->getOutput()->setTitle( $page->getTitle() );
541 
542  $this->setTemporaryHook(
543  'ShowMissingArticle',
544  function ( Article $articlePage ) use ( $article ) {
545  $this->assertSame( $article, $articlePage, '$articlePage' );
546 
547  $articlePage->getContext()->getOutput()->addHTML( 'Hook Text' );
548  }
549  );
550 
551  $article->view();
552 
553  $output = $article->getContext()->getOutput();
554  $this->assertContains( '(noarticletextanon)', $this->getHtml( $output ) );
555  $this->assertContains( 'Hook Text', $this->getHtml( $output ) );
556  }
557 
558 }
The wiki should then use memcached to cache various data To use multiple just add more items to the array To increase the weight of a make its entry a array("192.168.0.1:11211", 2))
static factory(Title $title)
Create a WikiPage object of the appropriate class for the given title.
Definition: WikiPage.php:138
setContext(IContextSource $context)
setTemporaryHook( $hookName, $handler)
Create a temporary hook handler which will be reset by tearDown.
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
An IContextSource implementation which will inherit context from another source but allow individual ...
Class for viewing MediaWiki article and history.
Definition: Article.php:37
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 MediaWikiServices
Definition: injection.txt:23
\Article::view()
setContext( $context)
Sets the context this Article is executed in.
Definition: Article.php:2223
static newUnsavedComment( $comment, array $data=null)
Create a new, unsaved CommentStoreComment.
static configuration should be added through ResourceLoaderGetConfigVars instead can be used to get the real title e g db for database replication lag or jobqueue for job queue size converted to pseudo seconds It is possible to add more fields and they will be returned to the user in the API response after the basic globals have been set but before ordinary actions take place $output
Definition: hooks.txt:2217
Mutable RevisionRecord implementation, for building new revision entries programmatically.
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that When $user is not it can be in the form of< username >< more info > e g for bot passwords intended to be added to log contexts Fields it might only if the login was with a bot password 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 modifiable modifiable after all normalizations have been except for the $wgMaxImageArea check set to true or false to override the $wgMaxImageArea check result gives extension the possibility to transform it themselves $handler
Definition: hooks.txt:780
getContext()
Gets the context this Article is executed in.
Definition: Article.php:2233
getDefaultWikitextNS()
Returns the ID of a namespace that defaults to Wikitext.
setVisibility(array $params)
Set the visibility for the revisions in this list.
Definition: RevDelList.php:108
getHTML()
Get the body HTML.
List for revision table items.
either a unescaped string or a HtmlArmor object after in associative array form externallinks including delete and has completed for all link tables whether this was an auto creation use $formDescriptor instead default is conds Array Extra conditions for the No matching items in log is displayed if loglist is empty msgKey Array If you want a nice box with a set this to the key of the message First element is the message additional optional elements are parameters for the key that are processed with wfMessage() -> params() ->parseAsBlock() - offset Set to overwrite offset parameter in $wgRequest set to '' to unset offset - wrap String Wrap the message in html(usually something like "&lt
static getMain()
Get the RequestContext object associated with the main request.
getRevisionFetched()
Get the fetched Revision object depending on request parameters or null on failure.
Definition: Article.php:558
getContent( $role, $audience=self::FOR_PUBLIC, User $user=null)
Returns the Content of the given slot of this revision.
getContext()
Get the base IContextSource object.
$cache
Definition: mcc.php:33
namespace and then decline to actually register it file or subcat img or subcat $title
Definition: hooks.txt:925
presenting them properly to the user as errors is done by the caller return true use this to change the list i e etc $rev
Definition: hooks.txt:1766
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 NS_MEDIAWIKI
Definition: Defines.php:72
hideDeprecated( $function)
Don&#39;t throw a warning if $function is deprecated and called later.
testViewRedirect()
Article::getRedirectTarget()
static makeTitle( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:589
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
you have access to all of the normal MediaWiki so you can get a DB use the etc For full docs on the Maintenance class
Definition: maintenance.txt:52
do that in ParserLimitReportFormat instead use this to modify the parameters of the image all existing parser cache entries will be invalid To avoid you ll need to handle that somehow(e.g. with the RejectParserCacheValue hook) because MediaWiki won 't do it for you. & $defaults also a ContextSource after deleting those rows but within the same transaction you ll probably need to make sure the header is varied on and they can depend only on the ResourceLoaderContext $context
Definition: hooks.txt:2633
testGetOldId()
Article::getOldId() Article::getRevIdFetched()
Page revision base class.
addHTML( $text)
Append $text to the body HTML.
return true to allow those checks to and false if checking is done remove or add to the links of a group of changes in EnhancedChangesList Hook subscribers can return false to omit this line from recentchanges use this to change the tables headers change it to an object instance and return false override the list derivative used the name of the old file & $article
Definition: hooks.txt:1473
getHtml(OutputPage $output)
testArticleAfterFetchContentObjectHook()
static newFromName( $name, $validate='valid')
Static factory method for creation from username.
Definition: User.php:587
getPage( $title, array $revisionContents=[], array &$revisions=[])
static newFromWikiPage(WikiPage $page, IContextSource $context)
Create an Article object of the appropriate class for the given page.
Definition: Article.php:191
$content
Definition: pageupdater.txt:72
static getTestUser( $groups=[])
Convenience method for getting an immutable test user.
return true to allow those checks to and false if checking is done & $user
Definition: hooks.txt:1473