MediaWiki  1.27.2
EditPageTest.php
Go to the documentation of this file.
1 <?php
2 
13 
14  protected function setUp() {
15  global $wgExtraNamespaces, $wgNamespaceContentModels, $wgContentHandlers, $wgContLang;
16 
17  parent::setUp();
18 
19  $this->setMwGlobals( [
20  'wgExtraNamespaces' => $wgExtraNamespaces,
21  'wgNamespaceContentModels' => $wgNamespaceContentModels,
22  'wgContentHandlers' => $wgContentHandlers,
23  'wgContLang' => $wgContLang,
24  ] );
25 
26  $wgExtraNamespaces[12312] = 'Dummy';
27  $wgExtraNamespaces[12313] = 'Dummy_talk';
28 
29  $wgNamespaceContentModels[12312] = "testing";
30  $wgContentHandlers["testing"] = 'DummyContentHandlerForTesting';
31 
32  MWNamespace::getCanonicalNamespaces( true ); # reset namespace cache
33  $wgContLang->resetNamespaces(); # reset namespace cache
34  }
35 
42  $this->assertEquals( $title, $extracted );
43  }
44 
45  public static function provideExtractSectionTitle() {
46  return [
47  [
48  "== Test ==\n\nJust a test section.",
49  "Test"
50  ],
51  [
52  "An initial section, no header.",
53  false
54  ],
55  [
56  "An initial section with a fake heder (bug 32617)\n\n== Test == ??\nwtf",
57  false
58  ],
59  [
60  "== Section ==\nfollowed by a fake == Non-section == ??\nnoooo",
61  "Section"
62  ],
63  [
64  "== Section== \t\r\n followed by whitespace (bug 35051)",
65  'Section',
66  ],
67  ];
68  }
69 
70  protected function forceRevisionDate( WikiPage $page, $timestamp ) {
71  $dbw = wfGetDB( DB_MASTER );
72 
73  $dbw->update( 'revision',
74  [ 'rev_timestamp' => $dbw->timestamp( $timestamp ) ],
75  [ 'rev_id' => $page->getLatest() ] );
76 
77  $page->clear();
78  }
79 
88  protected function assertEditedTextEquals( $expected, $actual, $msg = '' ) {
89  $this->assertEquals( rtrim( $expected ), rtrim( $actual ), $msg );
90  }
91 
117  protected function assertEdit( $title, $baseText, $user = null, array $edit,
118  $expectedCode = null, $expectedText = null, $message = null
119  ) {
120  if ( is_string( $title ) ) {
121  $ns = $this->getDefaultWikitextNS();
122  $title = Title::newFromText( $title, $ns );
123  }
124  $this->assertNotNull( $title );
125 
126  if ( is_string( $user ) ) {
128 
129  if ( $user->getId() === 0 ) {
130  $user->addToDatabase();
131  }
132  }
133 
135 
136  if ( $baseText !== null ) {
138  $page->doEditContent( $content, "base text for test" );
139  $this->forceRevisionDate( $page, '20120101000000' );
140 
141  // sanity check
142  $page->clear();
143  $currentText = ContentHandler::getContentText( $page->getContent() );
144 
145  # EditPage rtrim() the user input, so we alter our expected text
146  # to reflect that.
147  $this->assertEditedTextEquals( $baseText, $currentText );
148  }
149 
150  if ( $user == null ) {
151  $user = $GLOBALS['wgUser'];
152  } else {
153  $this->setMwGlobals( 'wgUser', $user );
154  }
155 
156  if ( !isset( $edit['wpEditToken'] ) ) {
157  $edit['wpEditToken'] = $user->getEditToken();
158  }
159 
160  if ( !isset( $edit['wpEdittime'] ) ) {
161  $edit['wpEdittime'] = $page->exists() ? $page->getTimestamp() : '';
162  }
163 
164  if ( !isset( $edit['wpStarttime'] ) ) {
165  $edit['wpStarttime'] = wfTimestampNow();
166  }
167 
168  $req = new FauxRequest( $edit, true ); // session ??
169 
170  $article = new Article( $title );
171  $article->getContext()->setTitle( $title );
172  $ep = new EditPage( $article );
173  $ep->setContextTitle( $title );
174  $ep->importFormData( $req );
175 
176  $bot = isset( $edit['bot'] ) ? (bool)$edit['bot'] : false;
177 
178  // this is where the edit happens!
179  // Note: don't want to use EditPage::AttemptSave, because it messes with $wgOut
180  // and throws exceptions like PermissionsError
181  $status = $ep->internalAttemptSave( $result, $bot );
182 
183  if ( $expectedCode !== null ) {
184  // check edit code
185  $this->assertEquals( $expectedCode, $status->value,
186  "Expected result code mismatch. $message" );
187  }
188 
190 
191  if ( $expectedText !== null ) {
192  // check resulting page text
193  $content = $page->getContent();
195 
196  # EditPage rtrim() the user input, so we alter our expected text
197  # to reflect that.
198  $this->assertEditedTextEquals( $expectedText, $text,
199  "Expected article text mismatch. $message" );
200  }
201 
202  return $page;
203  }
204 
205  public static function provideCreatePages() {
206  return [
207  [ 'expected article being created',
208  'EditPageTest_testCreatePage',
209  null,
210  'Hello World!',
212  'Hello World!'
213  ],
214  [ 'expected article not being created if empty',
215  'EditPageTest_testCreatePage',
216  null,
217  '',
219  null
220  ],
221  [ 'expected MediaWiki: page being created',
222  'MediaWiki:January',
223  'UTSysop',
224  'Not January',
226  'Not January'
227  ],
228  [ 'expected not-registered MediaWiki: page not being created if empty',
229  'MediaWiki:EditPageTest_testCreatePage',
230  'UTSysop',
231  '',
233  null
234  ],
235  [ 'expected registered MediaWiki: page being created even if empty',
236  'MediaWiki:January',
237  'UTSysop',
238  '',
240  ''
241  ],
242  [ 'expected registered MediaWiki: page whose default content is empty'
243  . ' not being created if empty',
244  'MediaWiki:Ipb-default-expiry',
245  'UTSysop',
246  '',
248  ''
249  ],
250  [ 'expected MediaWiki: page not being created if text equals default message',
251  'MediaWiki:January',
252  'UTSysop',
253  'January',
255  null
256  ],
257  [ 'expected empty article being created',
258  'EditPageTest_testCreatePage',
259  null,
260  '',
262  '',
263  true
264  ],
265  ];
266  }
267 
272  public function testCreatePage(
273  $desc, $pageTitle, $user, $editText, $expectedCode, $expectedText, $ignoreBlank = false
274  ) {
275  $checkId = null;
276 
277  $this->setMwGlobals( 'wgHooks', [
278  'PageContentInsertComplete' => [ function (
280  $summary, $minor, $u1, $u2, &$flags, Revision $revision
281  ) {
282  // types/refs checked
283  } ],
284  'PageContentSaveComplete' => [ function (
286  $summary, $minor, $u1, $u2, &$flags, Revision $revision,
287  Status &$status, $baseRevId
288  ) use ( &$checkId ) {
289  $checkId = $status->value['revision']->getId();
290  // types/refs checked
291  } ],
292  ] );
293 
294  $edit = [ 'wpTextbox1' => $editText ];
295  if ( $ignoreBlank ) {
296  $edit['wpIgnoreBlankArticle'] = 1;
297  }
298 
299  $page = $this->assertEdit( $pageTitle, null, $user, $edit, $expectedCode, $expectedText, $desc );
300 
301  if ( $expectedCode != EditPage::AS_BLANK_ARTICLE ) {
302  $latest = $page->getLatest();
303  $page->doDeleteArticleReal( $pageTitle );
304 
305  $this->assertGreaterThan( 0, $latest, "Page revision ID updated in object" );
306  $this->assertEquals( $latest, $checkId, "Revision in Status for hook" );
307  }
308  }
309 
314  public function testCreatePageTrx(
315  $desc, $pageTitle, $user, $editText, $expectedCode, $expectedText, $ignoreBlank = false
316  ) {
317  $checkIds = [];
318  $this->setMwGlobals( 'wgHooks', [
319  'PageContentInsertComplete' => [ function (
321  $summary, $minor, $u1, $u2, &$flags, Revision $revision
322  ) {
323  // types/refs checked
324  } ],
325  'PageContentSaveComplete' => [ function (
327  $summary, $minor, $u1, $u2, &$flags, Revision $revision,
328  Status &$status, $baseRevId
329  ) use ( &$checkIds ) {
330  $checkIds[] = $status->value['revision']->getId();
331  // types/refs checked
332  } ],
333  ] );
334 
335  wfGetDB( DB_MASTER )->begin( __METHOD__ );
336 
337  $edit = [ 'wpTextbox1' => $editText ];
338  if ( $ignoreBlank ) {
339  $edit['wpIgnoreBlankArticle'] = 1;
340  }
341 
342  $page = $this->assertEdit(
343  $pageTitle, null, $user, $edit, $expectedCode, $expectedText, $desc );
344 
345  $pageTitle2 = (string)$pageTitle . '/x';
346  $page2 = $this->assertEdit(
347  $pageTitle2, null, $user, $edit, $expectedCode, $expectedText, $desc );
348 
349  wfGetDB( DB_MASTER )->commit( __METHOD__ );
350 
351  if ( $expectedCode != EditPage::AS_BLANK_ARTICLE ) {
352  $latest = $page->getLatest();
353  $page->doDeleteArticleReal( $pageTitle );
354 
355  $this->assertGreaterThan( 0, $latest, "Page #1 revision ID updated in object" );
356  $this->assertEquals( $latest, $checkIds[0], "Revision #1 in Status for hook" );
357 
358  $latest2 = $page2->getLatest();
359  $page2->doDeleteArticleReal( $pageTitle2 );
360 
361  $this->assertGreaterThan( 0, $latest2, "Page #2 revision ID updated in object" );
362  $this->assertEquals( $latest2, $checkIds[1], "Revision #2 in Status for hook" );
363  }
364  }
365 
366  public function testUpdatePage() {
367  $checkIds = [];
368 
369  $this->setMwGlobals( 'wgHooks', [
370  'PageContentInsertComplete' => [ function (
372  $summary, $minor, $u1, $u2, &$flags, Revision $revision
373  ) {
374  // types/refs checked
375  } ],
376  'PageContentSaveComplete' => [ function (
378  $summary, $minor, $u1, $u2, &$flags, Revision $revision,
379  Status &$status, $baseRevId
380  ) use ( &$checkIds ) {
381  $checkIds[] = $status->value['revision']->getId();
382  // types/refs checked
383  } ],
384  ] );
385 
386  $text = "one";
387  $edit = [
388  'wpTextbox1' => $text,
389  'wpSummary' => 'first update',
390  ];
391 
392  $page = $this->assertEdit( 'EditPageTest_testUpdatePage', "zero", null, $edit,
394  "expected successfull update with given text" );
395  $this->assertGreaterThan( 0, $checkIds[0], "First event rev ID set" );
396 
397  $this->forceRevisionDate( $page, '20120101000000' );
398 
399  $text = "two";
400  $edit = [
401  'wpTextbox1' => $text,
402  'wpSummary' => 'second update',
403  ];
404 
405  $this->assertEdit( 'EditPageTest_testUpdatePage', null, null, $edit,
407  "expected successfull update with given text" );
408  $this->assertGreaterThan( 0, $checkIds[1], "Second edit hook rev ID set" );
409  $this->assertGreaterThan( $checkIds[0], $checkIds[1], "Second event rev ID is higher" );
410  }
411 
412  public function testUpdatePageTrx() {
413  $text = "one";
414  $edit = [
415  'wpTextbox1' => $text,
416  'wpSummary' => 'first update',
417  ];
418 
419  $page = $this->assertEdit( 'EditPageTest_testTrxUpdatePage', "zero", null, $edit,
421  "expected successfull update with given text" );
422 
423  $this->forceRevisionDate( $page, '20120101000000' );
424 
425  $checkIds = [];
426  $this->setMwGlobals( 'wgHooks', [
427  'PageContentSaveComplete' => [ function (
429  $summary, $minor, $u1, $u2, &$flags, Revision $revision,
430  Status &$status, $baseRevId
431  ) use ( &$checkIds ) {
432  $checkIds[] = $status->value['revision']->getId();
433  // types/refs checked
434  } ],
435  ] );
436 
437  wfGetDB( DB_MASTER )->begin( __METHOD__ );
438 
439  $text = "two";
440  $edit = [
441  'wpTextbox1' => $text,
442  'wpSummary' => 'second update',
443  ];
444 
445  $this->assertEdit( 'EditPageTest_testTrxUpdatePage', null, null, $edit,
447  "expected successfull update with given text" );
448 
449  $text = "three";
450  $edit = [
451  'wpTextbox1' => $text,
452  'wpSummary' => 'third update',
453  ];
454 
455  $this->assertEdit( 'EditPageTest_testTrxUpdatePage', null, null, $edit,
457  "expected successfull update with given text" );
458 
459  wfGetDB( DB_MASTER )->commit( __METHOD__ );
460 
461  $this->assertGreaterThan( 0, $checkIds[0], "First event rev ID set" );
462  $this->assertGreaterThan( 0, $checkIds[1], "Second edit hook rev ID set" );
463  $this->assertGreaterThan( $checkIds[0], $checkIds[1], "Second event rev ID is higher" );
464  }
465 
466  public static function provideSectionEdit() {
467  $text = 'Intro
468 
469 == one ==
470 first section.
471 
472 == two ==
473 second section.
474 ';
475 
476  $sectionOne = '== one ==
477 hello
478 ';
479 
480  $newSection = '== new section ==
481 
482 hello
483 ';
484 
485  $textWithNewSectionOne = preg_replace(
486  '/== one ==.*== two ==/ms',
487  "$sectionOne\n== two ==", $text
488  );
489 
490  $textWithNewSectionAdded = "$text\n$newSection";
491 
492  return [
493  [ # 0
494  $text,
495  '',
496  'hello',
497  'replace all',
498  'hello'
499  ],
500 
501  [ # 1
502  $text,
503  '1',
504  $sectionOne,
505  'replace first section',
506  $textWithNewSectionOne,
507  ],
508 
509  [ # 2
510  $text,
511  'new',
512  'hello',
513  'new section',
514  $textWithNewSectionAdded,
515  ],
516  ];
517  }
518 
523  public function testSectionEdit( $base, $section, $text, $summary, $expected ) {
524  $edit = [
525  'wpTextbox1' => $text,
526  'wpSummary' => $summary,
527  'wpSection' => $section,
528  ];
529 
530  $this->assertEdit( 'EditPageTest_testSectionEdit', $base, null, $edit,
531  EditPage::AS_SUCCESS_UPDATE, $expected,
532  "expected successfull update of section" );
533  }
534 
535  public static function provideAutoMerge() {
536  $tests = [];
537 
538  $tests[] = [ # 0: plain conflict
539  "Elmo", # base edit user
540  "one\n\ntwo\n\nthree\n",
541  [ # adam's edit
542  'wpStarttime' => 1,
543  'wpTextbox1' => "ONE\n\ntwo\n\nthree\n",
544  ],
545  [ # berta's edit
546  'wpStarttime' => 2,
547  'wpTextbox1' => "(one)\n\ntwo\n\nthree\n",
548  ],
550  "ONE\n\ntwo\n\nthree\n", # expected text
551  'expected edit conflict', # message
552  ];
553 
554  $tests[] = [ # 1: successful merge
555  "Elmo", # base edit user
556  "one\n\ntwo\n\nthree\n",
557  [ # adam's edit
558  'wpStarttime' => 1,
559  'wpTextbox1' => "ONE\n\ntwo\n\nthree\n",
560  ],
561  [ # berta's edit
562  'wpStarttime' => 2,
563  'wpTextbox1' => "one\n\ntwo\n\nTHREE\n",
564  ],
565  EditPage::AS_SUCCESS_UPDATE, # expected code
566  "ONE\n\ntwo\n\nTHREE\n", # expected text
567  'expected automatic merge', # message
568  ];
569 
570  $text = "Intro\n\n";
571  $text .= "== first section ==\n\n";
572  $text .= "one\n\ntwo\n\nthree\n\n";
573  $text .= "== second section ==\n\n";
574  $text .= "four\n\nfive\n\nsix\n\n";
575 
576  // extract the first section.
577  $section = preg_replace( '/.*(== first section ==.*)== second section ==.*/sm', '$1', $text );
578 
579  // generate expected text after merge
580  $expected = str_replace( 'one', 'ONE', str_replace( 'three', 'THREE', $text ) );
581 
582  $tests[] = [ # 2: merge in section
583  "Elmo", # base edit user
584  $text,
585  [ # adam's edit
586  'wpStarttime' => 1,
587  'wpTextbox1' => str_replace( 'one', 'ONE', $section ),
588  'wpSection' => '1'
589  ],
590  [ # berta's edit
591  'wpStarttime' => 2,
592  'wpTextbox1' => str_replace( 'three', 'THREE', $section ),
593  'wpSection' => '1'
594  ],
595  EditPage::AS_SUCCESS_UPDATE, # expected code
596  $expected, # expected text
597  'expected automatic section merge', # message
598  ];
599 
600  // see whether it makes a difference who did the base edit
601  $testsWithAdam = array_map( function ( $test ) {
602  $test[0] = 'Adam'; // change base edit user
603  return $test;
604  }, $tests );
605 
606  $testsWithBerta = array_map( function ( $test ) {
607  $test[0] = 'Berta'; // change base edit user
608  return $test;
609  }, $tests );
610 
611  return array_merge( $tests, $testsWithAdam, $testsWithBerta );
612  }
613 
618  public function testAutoMerge( $baseUser, $text, $adamsEdit, $bertasEdit,
619  $expectedCode, $expectedText, $message = null
620  ) {
621  $this->markTestSkippedIfNoDiff3();
622 
623  // create page
624  $ns = $this->getDefaultWikitextNS();
625  $title = Title::newFromText( 'EditPageTest_testAutoMerge', $ns );
627 
628  if ( $page->exists() ) {
629  $page->doDeleteArticle( "clean slate for testing" );
630  }
631 
632  $baseEdit = [
633  'wpTextbox1' => $text,
634  ];
635 
636  $page = $this->assertEdit( 'EditPageTest_testAutoMerge', null,
637  $baseUser, $baseEdit, null, null, __METHOD__ );
638 
639  $this->forceRevisionDate( $page, '20120101000000' );
640 
641  $edittime = $page->getTimestamp();
642 
643  // start timestamps for conflict detection
644  if ( !isset( $adamsEdit['wpStarttime'] ) ) {
645  $adamsEdit['wpStarttime'] = 1;
646  }
647 
648  if ( !isset( $bertasEdit['wpStarttime'] ) ) {
649  $bertasEdit['wpStarttime'] = 2;
650  }
651 
653  $adamsTime = wfTimestamp(
654  TS_MW,
655  (int)wfTimestamp( TS_UNIX, $starttime ) + (int)$adamsEdit['wpStarttime']
656  );
657  $bertasTime = wfTimestamp(
658  TS_MW,
659  (int)wfTimestamp( TS_UNIX, $starttime ) + (int)$bertasEdit['wpStarttime']
660  );
661 
662  $adamsEdit['wpStarttime'] = $adamsTime;
663  $bertasEdit['wpStarttime'] = $bertasTime;
664 
665  $adamsEdit['wpSummary'] = 'Adam\'s edit';
666  $bertasEdit['wpSummary'] = 'Bertas\'s edit';
667 
668  $adamsEdit['wpEdittime'] = $edittime;
669  $bertasEdit['wpEdittime'] = $edittime;
670 
671  // first edit
672  $this->assertEdit( 'EditPageTest_testAutoMerge', null, 'Adam', $adamsEdit,
673  EditPage::AS_SUCCESS_UPDATE, null, "expected successfull update" );
674 
675  // second edit
676  $this->assertEdit( 'EditPageTest_testAutoMerge', null, 'Berta', $bertasEdit,
677  $expectedCode, $expectedText, $message );
678  }
679 
684  $title = Title::newFromText( 'Dummy:NonTextPageForEditPage' );
686 
687  $article = new Article( $title );
688  $article->getContext()->setTitle( $title );
689  $ep = new EditPage( $article );
690  $ep->setContextTitle( $title );
691 
692  $user = $GLOBALS['wgUser'];
693 
694  $edit = [
695  'wpTextbox1' => serialize( 'non-text content' ),
696  'wpEditToken' => $user->getEditToken(),
697  'wpEdittime' => '',
698  'wpStarttime' => wfTimestampNow()
699  ];
700 
701  $req = new FauxRequest( $edit, true );
702  $ep->importFormData( $req );
703 
704  $this->setExpectedException(
705  'MWException',
706  'This content model is not supported: testing'
707  );
708 
709  $ep->internalAttemptSave( $result, false );
710  }
711 
712 }
static newFromName($name, $validate= 'valid')
Static factory method for creation from username.
Definition: User.php:568
testAutoMerge($baseUser, $text, $adamsEdit, $bertasEdit, $expectedCode, $expectedText, $message=null)
provideAutoMerge EditPage
static factory(Title $title)
Create a WikiPage object of the appropriate class for the given title.
Definition: WikiPage.php:99
testExtractSectionTitle($section, $title)
provideExtractSectionTitle EditPage::extractSectionTitle
wfGetDB($db, $groups=[], $wiki=false)
Get a Database object.
the array() calling protocol came about after MediaWiki 1.4rc1.
getLatest()
Get the page_latest field.
Definition: WikiPage.php:538
testCreatePage($desc, $pageTitle, $user, $editText, $expectedCode, $expectedText, $ignoreBlank=false)
provideCreatePages EditPage
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
processing should stop and the error should be shown to the user * false
Definition: hooks.txt:189
The edit page/HTML interface (split from Article) The actual database and text munging is still in Ar...
Definition: EditPage.php:38
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return an< a > element with HTML attributes $attribs and contents $html will be returned If you return $ret will be returned and may include noclasses after processing after in associative array form externallinks including delete and has completed for all link tables whether this was an auto creation 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 message
Definition: hooks.txt:1924
clear()
Clear the object.
Definition: WikiPage.php:225
Class for viewing MediaWiki article and history.
Definition: Article.php:34
null for the local wiki Added in
Definition: hooks.txt:1418
This code would result in ircNotify being run twice when an article is and once for brion Hooks can return three possible true was required This is the default since MediaWiki *some string
Definition: hooks.txt:177
Using a hook running we can avoid having all this option specific stuff in our mainline code Using the function array $article
Definition: hooks.txt:78
it s the revision text itself In either if gzip is the revision text is gzipped $flags
Definition: hooks.txt:2548
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
static provideSectionEdit()
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
getDefaultWikitextNS()
Returns the ID of a namespace that defaults to Wikitext.
static provideExtractSectionTitle()
you have access to all of the normal MediaWiki so you can get a DB use the cache
Definition: maintenance.txt:52
wfTimestamp($outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return true
Definition: hooks.txt:1798
when a variable name is used in a function
Definition: design.txt:93
$GLOBALS['IP']
static provideAutoMerge()
if($limit) $timestamp
assertEditedTextEquals($expected, $actual, $msg= '')
User input text is passed to rtrim() by edit page.
static getContentText(Content $content=null)
Convenience function for getting flat text from a Content object.
static provideCreatePages()
$summary
const AS_SUCCESS_UPDATE
Status: Article successfully updated.
Definition: EditPage.php:42
testCreatePageTrx($desc, $pageTitle, $user, $editText, $expectedCode, $expectedText, $ignoreBlank=false)
provideCreatePages EditPage
wfTimestampNow()
Convenience function; returns MediaWiki timestamp for the present time.
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 and we might be restricted by PHP settings such as safe mode or open_basedir We cannot assume that the software even has read access anywhere useful Many shared hosts run all users web applications under the same user
Wikitext formatted, in the key only.
Definition: distributors.txt:9
Base interface for content objects.
Definition: Content.php:34
Base class that store and restore the Language objects.
assertEdit($title, $baseText, $user=null, array $edit, $expectedCode=null, $expectedText=null, $message=null)
Performs an edit and checks the result.
testSectionEdit($base, $section, $text, $summary, $expected)
provideSectionEdit EditPage
namespace and then decline to actually register it file or subcat img or subcat $title
Definition: hooks.txt:912
design txt This is a brief overview of the new design More thorough and up to date information is available on the documentation wiki at etc Handles the details of getting and saving to the user table of the and dealing with sessions and cookies OutputPage Encapsulates the entire HTML page that will be sent in response to any server request It is used by calling its functions to add text
Definition: design.txt:12
static makeContent($text, Title $title=null, $modelId=null, $format=null)
Convenience function for creating a Content object from a given textual representation.
const AS_SUCCESS_NEW_ARTICLE
Status: Article successfully created.
Definition: EditPage.php:47
static extractSectionTitle($text)
Extract the section title from current section text, if any.
Definition: EditPage.php:2713
Editing.
usually copyright or history_copyright This message must be in HTML not wikitext if the section is included from a template $section
Definition: hooks.txt:2715
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:242
const TS_MW
MediaWiki concatenated string timestamp (YYYYMMDDHHMMSS)
Class representing a MediaWiki article and history.
Definition: WikiPage.php:29
$wgExtraNamespaces
Additional namespaces.
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
this hook is for auditing only $req
Definition: hooks.txt:965
and how to run hooks for an and one after Each event has a preferably in CamelCase For ArticleDelete hook A clump of code and data that should be run when an event happens This can be either a function and a chunk of or an object and a method hook function The function part of a third party developers and local administrators to define code that will be run at certain points in the mainline code
Definition: hooks.txt:23
testCheckDirectEditingDisallowed_forNonTextContent()
testAutoMerge
forceRevisionDate(WikiPage $page, $timestamp)
markTestSkippedIfNoDiff3()
Check, if $wgDiff3 is set and ready to merge Will mark the calling test as skipped, if not ready.
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 $content
Definition: hooks.txt:1004
$wgContentHandlers
Plugins for page content model handling.
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
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 $status
Definition: hooks.txt:1004
as see the revision history and available at free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to merge
Definition: LICENSE.txt:10
const AS_BLANK_ARTICLE
Status: user tried to create a blank page and wpIgnoreBlankArticle == false.
Definition: EditPage.php:104
const DB_MASTER
Definition: Defines.php:47
doDeleteArticleReal($reason, $suppress=false, $u1=null, $u2=null, &$error= '', User $user=null)
Back-end article deletion Deletes the article with database consistency, writes logs, purges caches.
Definition: WikiPage.php:2783
const TS_UNIX
Unix time - the number of seconds since 1970-01-01 00:00:00 UTC.
serialize()
Definition: ApiMessage.php:94
const AS_CONFLICT_DETECTED
Status: (non-resolvable) edit conflict.
Definition: EditPage.php:109
setMwGlobals($pairs, $value=null)
static getCanonicalNamespaces($rebuild=false)
Returns array of all defined namespaces with their canonical (English) names.
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
$starttime
Definition: api.php:40