MediaWiki  1.27.1
testHelpers.inc
Go to the documentation of this file.
1 <?php
37 interface ITestRecorder {
38 
42  public function start();
43 
50  public function record( $test, $subtest, $result );
51 
55  public function report();
56 
60  public function end();
61 
62 }
63 
64 class TestRecorder implements ITestRecorder {
65  public $parent;
66  public $term;
67 
68  function __construct( $parent ) {
69  $this->parent = $parent;
70  $this->term = $parent->term;
71  }
72 
73  function start() {
74  $this->total = 0;
75  $this->success = 0;
76  }
77 
78  function record( $test, $subtest, $result ) {
79  $this->total++;
80  $this->success += ( $result ? 1 : 0 );
81  }
82 
83  function end() {
84  // dummy
85  }
86 
87  function report() {
88  if ( $this->total > 0 ) {
89  $this->reportPercentage( $this->success, $this->total );
90  } else {
91  throw new MWException( "No tests found.\n" );
92  }
93  }
94 
95  function reportPercentage( $success, $total ) {
96  $ratio = wfPercent( 100 * $success / $total );
97  print $this->term->color( 1 ) . "Passed $success of $total tests ($ratio)... ";
98 
99  if ( $success == $total ) {
100  print $this->term->color( 32 ) . "ALL TESTS PASSED!";
101  } else {
102  $failed = $total - $success;
103  print $this->term->color( 31 ) . "$failed tests failed!";
104  }
105 
106  print $this->term->reset() . "\n";
107 
108  return ( $success == $total );
109  }
110 }
111 
113  protected $lb; // /< Database load balancer
114  protected $db; // /< Database connection to the main DB
115  protected $curRun; // /< run ID number for the current run
116  protected $prevRun; // /< run ID number for the previous run, if any
117  protected $results; // /< Result array
118 
123  function __construct( $parent ) {
124  parent::__construct( $parent );
125 
126  $this->lb = wfGetLBFactory()->newMainLB();
127  // This connection will have the wiki's table prefix, not parsertest_
128  $this->db = $this->lb->getConnection( DB_MASTER );
129  }
130 
135  function start() {
136  parent::start();
137 
138  if ( !$this->db->tableExists( 'testrun', __METHOD__ )
139  || !$this->db->tableExists( 'testitem', __METHOD__ )
140  ) {
141  print "WARNING> `testrun` table not found in database.\n";
142  $this->prevRun = false;
143  } else {
144  // We'll make comparisons against the previous run later...
145  $this->prevRun = $this->db->selectField( 'testrun', 'MAX(tr_id)' );
146  }
147 
148  $this->results = [];
149  }
150 
151  function getName( $test, $subtest ) {
152  if ( $subtest ) {
153  return "$test subtest #$subtest";
154  } else {
155  return $test;
156  }
157  }
158 
159  function record( $test, $subtest, $result ) {
160  parent::record( $test, $subtest, $result );
161  $this->results[ $this->getName( $test, $subtest ) ] = $result;
162  }
163 
164  function report() {
165  if ( $this->prevRun ) {
166  // f = fail, p = pass, n = nonexistent
167  // codes show before then after
168  $table = [
169  'fp' => 'previously failing test(s) now PASSING! :)',
170  'pn' => 'previously PASSING test(s) removed o_O',
171  'np' => 'new PASSING test(s) :)',
172 
173  'pf' => 'previously passing test(s) now FAILING! :(',
174  'fn' => 'previously FAILING test(s) removed O_o',
175  'nf' => 'new FAILING test(s) :(',
176  'ff' => 'still FAILING test(s) :(',
177  ];
178 
179  $prevResults = [];
180 
181  $res = $this->db->select( 'testitem', [ 'ti_name', 'ti_success' ],
182  [ 'ti_run' => $this->prevRun ], __METHOD__ );
183 
184  foreach ( $res as $row ) {
185  if ( !$this->parent->regex
186  || preg_match( "/{$this->parent->regex}/i", $row->ti_name )
187  ) {
188  $prevResults[$row->ti_name] = $row->ti_success;
189  }
190  }
191 
192  $combined = array_keys( $this->results + $prevResults );
193 
194  # Determine breakdown by change type
195  $breakdown = [];
196  foreach ( $combined as $test ) {
197  if ( !isset( $prevResults[$test] ) ) {
198  $before = 'n';
199  } elseif ( $prevResults[$test] == 1 ) {
200  $before = 'p';
201  } else /* if ( $prevResults[$test] == 0 )*/ {
202  $before = 'f';
203  }
204 
205  if ( !isset( $this->results[$test] ) ) {
206  $after = 'n';
207  } elseif ( $this->results[$test] == 1 ) {
208  $after = 'p';
209  } else /*if ( $this->results[$test] == 0 ) */ {
210  $after = 'f';
211  }
212 
213  $code = $before . $after;
214 
215  if ( isset( $table[$code] ) ) {
216  $breakdown[$code][$test] = $this->getTestStatusInfo( $test, $after );
217  }
218  }
219 
220  # Write out results
221  foreach ( $table as $code => $label ) {
222  if ( !empty( $breakdown[$code] ) ) {
223  $count = count( $breakdown[$code] );
224  printf( "\n%4d %s\n", $count, $label );
225 
226  foreach ( $breakdown[$code] as $differing_test_name => $statusInfo ) {
227  print " * $differing_test_name [$statusInfo]\n";
228  }
229  }
230  }
231  } else {
232  print "No previous test runs to compare against.\n";
233  }
234 
235  print "\n";
236  parent::report();
237  }
238 
247  private function getTestStatusInfo( $testname, $after ) {
248  // If we're looking at a test that has just been removed, then say when it first appeared.
249  if ( $after == 'n' ) {
250  $changedRun = $this->db->selectField( 'testitem',
251  'MIN(ti_run)',
252  [ 'ti_name' => $testname ],
253  __METHOD__ );
254  $appear = $this->db->selectRow( 'testrun',
255  [ 'tr_date', 'tr_mw_version' ],
256  [ 'tr_id' => $changedRun ],
257  __METHOD__ );
258 
259  return "First recorded appearance: "
260  . date( "d-M-Y H:i:s", strtotime( $appear->tr_date ) )
261  . ", " . $appear->tr_mw_version;
262  }
263 
264  // Otherwise, this test has previous recorded results.
265  // See when this test last had a different result to what we're seeing now.
266  $conds = [
267  'ti_name' => $testname,
268  'ti_success' => ( $after == 'f' ? "1" : "0" ) ];
269 
270  if ( $this->curRun ) {
271  $conds[] = "ti_run != " . $this->db->addQuotes( $this->curRun );
272  }
273 
274  $changedRun = $this->db->selectField( 'testitem', 'MAX(ti_run)', $conds, __METHOD__ );
275 
276  // If no record of ever having had a different result.
277  if ( is_null( $changedRun ) ) {
278  if ( $after == "f" ) {
279  return "Has never passed";
280  } else {
281  return "Has never failed";
282  }
283  }
284 
285  // Otherwise, we're looking at a test whose status has changed.
286  // (i.e. it used to work, but now doesn't; or used to fail, but is now fixed.)
287  // In this situation, give as much info as we can as to when it changed status.
288  $pre = $this->db->selectRow( 'testrun',
289  [ 'tr_date', 'tr_mw_version' ],
290  [ 'tr_id' => $changedRun ],
291  __METHOD__ );
292  $post = $this->db->selectRow( 'testrun',
293  [ 'tr_date', 'tr_mw_version' ],
294  [ "tr_id > " . $this->db->addQuotes( $changedRun ) ],
295  __METHOD__,
296  [ "LIMIT" => 1, "ORDER BY" => 'tr_id' ]
297  );
298 
299  if ( $post ) {
300  $postDate = date( "d-M-Y H:i:s", strtotime( $post->tr_date ) ) . ", {$post->tr_mw_version}";
301  } else {
302  $postDate = 'now';
303  }
304 
305  return ( $after == "f" ? "Introduced" : "Fixed" ) . " between "
306  . date( "d-M-Y H:i:s", strtotime( $pre->tr_date ) ) . ", " . $pre->tr_mw_version
307  . " and $postDate";
308  }
309 
313  function end() {
314  $this->lb->closeAll();
315  parent::end();
316  }
317 }
318 
320  public $version;
321 
326  function start() {
327  $this->db->begin( __METHOD__ );
328 
329  if ( !$this->db->tableExists( 'testrun' )
330  || !$this->db->tableExists( 'testitem' )
331  ) {
332  print "WARNING> `testrun` table not found in database. Trying to create table.\n";
333  $this->db->sourceFile( $this->db->patchPath( 'patch-testrun.sql' ) );
334  echo "OK, resuming.\n";
335  }
336 
337  parent::start();
338 
339  $this->db->insert( 'testrun',
340  [
341  'tr_date' => $this->db->timestamp(),
342  'tr_mw_version' => $this->version,
343  'tr_php_version' => PHP_VERSION,
344  'tr_db_version' => $this->db->getServerVersion(),
345  'tr_uname' => php_uname()
346  ],
347  __METHOD__ );
348  if ( $this->db->getType() === 'postgres' ) {
349  $this->curRun = $this->db->currentSequenceValue( 'testrun_id_seq' );
350  } else {
351  $this->curRun = $this->db->insertId();
352  }
353  }
354 
361  function record( $test, $subtest, $result ) {
362  parent::record( $test, $subtest, $result );
363 
364  $this->db->insert( 'testitem',
365  [
366  'ti_run' => $this->curRun,
367  'ti_name' => $this->getName( $test, $subtest ),
368  'ti_success' => $result ? 1 : 0,
369  ],
370  __METHOD__ );
371  }
372 
376  function end() {
377  $this->db->commit( __METHOD__ );
378  parent::end();
379  }
380 }
381 
382 class TestFileIterator implements Iterator {
383  private $file;
384  private $fh;
389  private $parserTest;
390  private $index = 0;
391  private $test;
392  private $section = null;
394  private $sectionData = [];
395  private $lineNum;
396  private $eof;
397  # Create a fake parser tests which never run anything unless
398  # asked to do so. This will avoid running hooks for a disabled test
400  private $nextSubTest = 0;
401 
403  $this->file = $file;
404  $this->fh = fopen( $this->file, "rt" );
405 
406  if ( !$this->fh ) {
407  throw new MWException( "Couldn't open file '$file'\n" );
408  }
409 
410  $this->parserTest = $parserTest;
411  $this->delayedParserTest = new DelayedParserTest();
412 
413  $this->lineNum = $this->index = 0;
414  }
415 
416  function rewind() {
417  if ( fseek( $this->fh, 0 ) ) {
418  throw new MWException( "Couldn't fseek to the start of '$this->file'\n" );
419  }
420 
421  $this->index = -1;
422  $this->lineNum = 0;
423  $this->eof = false;
424  $this->next();
425 
426  return true;
427  }
428 
429  function current() {
430  return $this->test;
431  }
432 
433  function key() {
434  return $this->index;
435  }
436 
437  function next() {
438  if ( $this->readNextTest() ) {
439  $this->index++;
440  return true;
441  } else {
442  $this->eof = true;
443  }
444  }
445 
446  function valid() {
447  return $this->eof != true;
448  }
449 
450  function setupCurrentTest() {
451  // "input" and "result" are old section names allowed
452  // for backwards-compatibility.
453  $input = $this->checkSection( [ 'wikitext', 'input' ], false );
454  $result = $this->checkSection( [ 'html/php', 'html/*', 'html', 'result' ], false );
455  // some tests have "with tidy" and "without tidy" variants
456  $tidy = $this->checkSection( [ 'html/php+tidy', 'html+tidy' ], false );
457  if ( $tidy != false ) {
458  if ( $this->nextSubTest == 0 ) {
459  if ( $result != false ) {
460  $this->nextSubTest = 1; // rerun non-tidy variant later
461  }
462  $result = $tidy;
463  } else {
464  $this->nextSubTest = 0; // go on to next test after this
465  $tidy = false;
466  }
467  }
468 
469  if ( !isset( $this->sectionData['options'] ) ) {
470  $this->sectionData['options'] = '';
471  }
472 
473  if ( !isset( $this->sectionData['config'] ) ) {
474  $this->sectionData['config'] = '';
475  }
476 
477  $isDisabled = preg_match( '/\\bdisabled\\b/i', $this->sectionData['options'] ) &&
478  !$this->parserTest->runDisabled;
479  $isParsoidOnly = preg_match( '/\\bparsoid\\b/i', $this->sectionData['options'] ) &&
480  $result == 'html' &&
481  !$this->parserTest->runParsoid;
482  $isFiltered = !preg_match( "/" . $this->parserTest->regex . "/i", $this->sectionData['test'] );
483  if ( $input == false || $result == false || $isDisabled || $isParsoidOnly || $isFiltered ) {
484  # disabled test
485  return false;
486  }
487 
488  # We are really going to run the test, run pending hooks and hooks function
489  wfDebug( __METHOD__ . " unleashing delayed test for: {$this->sectionData['test']}" );
490  $hooksResult = $this->delayedParserTest->unleash( $this->parserTest );
491  if ( !$hooksResult ) {
492  # Some hook reported an issue. Abort.
493  throw new MWException( "Problem running requested parser hook from the test file" );
494  }
495 
496  $this->test = [
497  'test' => ParserTest::chomp( $this->sectionData['test'] ),
498  'subtest' => $this->nextSubTest,
499  'input' => ParserTest::chomp( $this->sectionData[$input] ),
500  'result' => ParserTest::chomp( $this->sectionData[$result] ),
501  'options' => ParserTest::chomp( $this->sectionData['options'] ),
502  'config' => ParserTest::chomp( $this->sectionData['config'] ),
503  ];
504  if ( $tidy != false ) {
505  $this->test['options'] .= " tidy";
506  }
507  return true;
508  }
509 
510  function readNextTest() {
511  # Run additional subtests of previous test
512  while ( $this->nextSubTest > 0 ) {
513  if ( $this->setupCurrentTest() ) {
514  return true;
515  }
516  }
517 
518  $this->clearSection();
519  # Reset hooks for the delayed test object
520  $this->delayedParserTest->reset();
521 
522  while ( false !== ( $line = fgets( $this->fh ) ) ) {
523  $this->lineNum++;
524  $matches = [];
525 
526  if ( preg_match( '/^!!\s*(\S+)/', $line, $matches ) ) {
527  $this->section = strtolower( $matches[1] );
528 
529  if ( $this->section == 'endarticle' ) {
530  $this->checkSection( 'text' );
531  $this->checkSection( 'article' );
532 
533  $this->parserTest->addArticle(
534  ParserTest::chomp( $this->sectionData['article'] ),
535  $this->sectionData['text'], $this->lineNum );
536 
537  $this->clearSection();
538 
539  continue;
540  }
541 
542  if ( $this->section == 'endhooks' ) {
543  $this->checkSection( 'hooks' );
544 
545  foreach ( explode( "\n", $this->sectionData['hooks'] ) as $line ) {
546  $line = trim( $line );
547 
548  if ( $line ) {
549  $this->delayedParserTest->requireHook( $line );
550  }
551  }
552 
553  $this->clearSection();
554 
555  continue;
556  }
557 
558  if ( $this->section == 'endfunctionhooks' ) {
559  $this->checkSection( 'functionhooks' );
560 
561  foreach ( explode( "\n", $this->sectionData['functionhooks'] ) as $line ) {
562  $line = trim( $line );
563 
564  if ( $line ) {
565  $this->delayedParserTest->requireFunctionHook( $line );
566  }
567  }
568 
569  $this->clearSection();
570 
571  continue;
572  }
573 
574  if ( $this->section == 'endtransparenthooks' ) {
575  $this->checkSection( 'transparenthooks' );
576 
577  foreach ( explode( "\n", $this->sectionData['transparenthooks'] ) as $line ) {
578  $line = trim( $line );
579 
580  if ( $line ) {
581  $this->delayedParserTest->requireTransparentHook( $line );
582  }
583  }
584 
585  $this->clearSection();
586 
587  continue;
588  }
589 
590  if ( $this->section == 'end' ) {
591  $this->checkSection( 'test' );
592  do {
593  if ( $this->setupCurrentTest() ) {
594  return true;
595  }
596  } while ( $this->nextSubTest > 0 );
597  # go on to next test (since this was disabled)
598  $this->clearSection();
599  $this->delayedParserTest->reset();
600  continue;
601  }
602 
603  if ( isset( $this->sectionData[$this->section] ) ) {
604  throw new MWException( "duplicate section '$this->section' "
605  . "at line {$this->lineNum} of $this->file\n" );
606  }
607 
608  $this->sectionData[$this->section] = '';
609 
610  continue;
611  }
612 
613  if ( $this->section ) {
614  $this->sectionData[$this->section] .= $line;
615  }
616  }
617 
618  return false;
619  }
620 
624  private function clearSection() {
625  $this->sectionData = [];
626  $this->section = null;
627 
628  }
629 
643  private function checkSection( $tokens, $fatal = true ) {
644  if ( is_null( $this->section ) ) {
645  throw new MWException( __METHOD__ . " can not verify a null section!\n" );
646  }
647  if ( !is_array( $tokens ) ) {
648  $tokens = [ $tokens ];
649  }
650  if ( count( $tokens ) == 0 ) {
651  throw new MWException( __METHOD__ . " can not verify zero sections!\n" );
652  }
653 
654  $data = $this->sectionData;
655  $tokens = array_filter( $tokens, function ( $token ) use ( $data ) {
656  return isset( $data[$token] );
657  } );
658 
659  if ( count( $tokens ) == 0 ) {
660  if ( !$fatal ) {
661  return false;
662  }
663  throw new MWException( sprintf(
664  "'%s' without '%s' at line %s of %s\n",
665  $this->section,
666  implode( ',', $tokens ),
667  $this->lineNum,
668  $this->file
669  ) );
670  }
671  if ( count( $tokens ) > 1 ) {
672  throw new MWException( sprintf(
673  "'%s' with unexpected tokens '%s' at line %s of %s\n",
674  $this->section,
675  implode( ',', $tokens ),
676  $this->lineNum,
677  $this->file
678  ) );
679  }
680 
681  return array_values( $tokens )[0];
682  }
683 }
684 
690  function current() {
691  $test = parent::current();
692  if ( $test ) {
693  return [
694  $test['test'],
695  $test['input'],
696  $test['result'],
697  $test['options'],
698  $test['config'],
699  ];
700  } else {
701  return $test;
702  }
703  }
704 }
705 
710 
712  private $hooks;
713  private $fnHooks;
715 
716  public function __construct() {
717  $this->reset();
718  }
719 
724  public function reset() {
725  $this->hooks = [];
726  $this->fnHooks = [];
727  $this->transparentHooks = [];
728  }
729 
737  public function unleash( &$parserTest ) {
738  if ( !( $parserTest instanceof ParserTest || $parserTest instanceof NewParserTest ) ) {
739  throw new MWException( __METHOD__ . " must be passed an instance of ParserTest or "
740  . "NewParserTest classes\n" );
741  }
742 
743  # Trigger delayed hooks. Any failure will make us abort
744  foreach ( $this->hooks as $hook ) {
745  $ret = $parserTest->requireHook( $hook );
746  if ( !$ret ) {
747  return false;
748  }
749  }
750 
751  # Trigger delayed function hooks. Any failure will make us abort
752  foreach ( $this->fnHooks as $fnHook ) {
753  $ret = $parserTest->requireFunctionHook( $fnHook );
754  if ( !$ret ) {
755  return false;
756  }
757  }
758 
759  # Trigger delayed transparent hooks. Any failure will make us abort
760  foreach ( $this->transparentHooks as $hook ) {
761  $ret = $parserTest->requireTransparentHook( $hook );
762  if ( !$ret ) {
763  return false;
764  }
765  }
766 
767  # Delayed execution was successful.
768  return true;
769  }
770 
776  public function requireHook( $hook ) {
777  $this->hooks[] = $hook;
778  }
779 
785  public function requireFunctionHook( $fnHook ) {
786  $this->fnHooks[] = $fnHook;
787  }
788 
794  public function requireTransparentHook( $hook ) {
795  $this->transparentHooks[] = $hook;
796  }
797 
798 }
799 
803 class DjVuSupport {
804 
808  public function __construct() {
810 
811  $wgDjvuRenderer = $wgDjvuRenderer ? $wgDjvuRenderer : '/usr/bin/ddjvu';
812  $wgDjvuDump = $wgDjvuDump ? $wgDjvuDump : '/usr/bin/djvudump';
813  $wgDjvuToXML = $wgDjvuToXML ? $wgDjvuToXML : '/usr/bin/djvutoxml';
814  $wgDjvuTxt = $wgDjvuTxt ? $wgDjvuTxt : '/usr/bin/djvutxt';
815 
816  if ( !in_array( 'djvu', $wgFileExtensions ) ) {
817  $wgFileExtensions[] = 'djvu';
818  }
819  }
820 
826  public function isEnabled() {
828 
829  return is_executable( $wgDjvuRenderer )
830  && is_executable( $wgDjvuDump )
831  && is_executable( $wgDjvuToXML )
832  && is_executable( $wgDjvuTxt );
833  }
834 }
835 
839 class TidySupport {
840  private $internalTidy;
841  private $externalTidy;
842 
846  public function __construct() {
847  global $wgTidyBin;
848 
849  $this->internalTidy = extension_loaded( 'tidy' ) &&
850  class_exists( 'tidy' ) && !wfIsHHVM();
851 
852  $this->externalTidy = is_executable( $wgTidyBin ) ||
854  !== false;
855  }
856 
862  public function isInternal() {
863  return $this->internalTidy;
864  }
865 
871  public function isEnabled() {
872  return $this->internalTidy || $this->externalTidy;
873  }
874 }
isInternal()
Returns true if we should use internal tidy.
record($test, $subtest, $result)
Called after each test.
Definition: testHelpers.inc:78
__construct($parent)
Definition: testHelpers.inc:68
record($test, $subtest, $result)
Called after each test.
wfPercent($nr, $acc=2, $round=true)
requireFunctionHook($fnHook)
Similar to ParserTest object but does not run anything Use unleash() to really execute the hook funct...
wfIsHHVM()
Check if we are running under HHVM.
$success
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses & $ret
Definition: hooks.txt:1798
$sectionData
String|null: current test section being analyzed.
$wgDjvuTxt
Path of the djvutxt DJVU text extraction utility Enable this and $wgDjvuDump to enable text layer ext...
__construct($file, $parserTest)
static locateExecutableInDefaultPaths($names, $versionInfo=false)
Same as locateExecutable(), but checks in getPossibleBinPaths() by default.
Definition: Installer.php:1195
when a variable name is used in a it is silently declared as a new local masking the global
Definition: design.txt:93
static chomp($s)
Remove last character if it is a newline utility.
Definition: parserTest.inc:352
getName($test, $subtest)
which are not or by specifying more than one search term(only pages containing all of the search terms will appear in the result).</td >< td >
__construct()
Initialises DjVu tools global with default values.
wfDebug($text, $dest= 'all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
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
checkSection($tokens, $fatal=true)
Verify the current section data has some value for the given token name(s) (first parameter)...
__construct($parent)
This should be called before the table prefix is changed.
record($test, $subtest, $result)
Record an individual test item's success or failure to the db.
We ve cleaned up the code here by removing clumps of infrequently used code and moving them off somewhere else It s much easier for someone working with this code to see what s _really_ going and make changes or fix bugs In we can take all the code that deals with the little used title reversing we can concentrate it all in an extension file
Definition: hooks.txt:93
__construct()
Determine if there is a usable tidy.
reportPercentage($success, $total)
Definition: testHelpers.inc:95
$res
Definition: database.txt:21
Although marked as a stub, can work independently.
$wgDjvuRenderer
Path of the ddjvu DJVU renderer Enable this and $wgDjvuDump to enable djvu rendering example: $wgDjvu...
report()
Called before finishing the test run.
start()
Set up result recording; insert a record for the run with the date and all that fun stuff...
reset()
Init/reset or forgot about the current delayed test.
$tokens
A class to delay execution of a parser test hooks.
Using a hook running we can avoid having all this option specific stuff in our mainline code Using hooks
Definition: hooks.txt:73
start()
Called at beginning of the parser test run.
unleash(&$parserTest)
Called whenever we actually want to run the hook.
Initialize and detect the DjVu files support.
clearSection()
Clear section name and its data.
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
An iterator for use as a phpunit data provider.
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 modifiable & $code
Definition: hooks.txt:762
end()
Called at the end of the parser test run.
Initialize and detect the tidy support.
requireTransparentHook($hook)
Similar to ParserTest object but does not run anything Use unleash() to really execute the hook funct...
$wgFileExtensions
This is the list of preferred extensions for uploading files.
end()
Called at the end of the parser test run.
Definition: testHelpers.inc:83
$wgDjvuDump
Path of the djvudump executable Enable this and $wgDjvuRenderer to enable djvu rendering example: $wg...
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
report()
Called before finishing the test run.
wfGetLBFactory()
Get the load balancer factory object.
Interface to record parser test results.
Definition: testHelpers.inc:37
end()
Commit transaction and clean up for result recording.
report()
Called before finishing the test run.
Definition: testHelpers.inc:87
getTestStatusInfo($testname, $after)
Returns a string giving information about when a test last had a status change.
isEnabled()
Returns true if the DjVu tools are usable.
$line
Definition: cdb.php:59
$wgDjvuToXML
Path of the djvutoxml executable This works like djvudump except much, much slower as of version 3...
ParserTest MediaWikiParserTest $parserTest
An instance of ParserTest (parserTests.php) or MediaWikiParserTest (phpunit)
$hooks
Initialized on construction.
$count
end()
Close the DB connection.
const DB_MASTER
Definition: Defines.php:47
requireHook($hook)
Similar to ParserTest object but does not run anything Use unleash() to really execute the hook...
start()
Called at beginning of the parser test run.
Definition: testHelpers.inc:73
record($test, $subtest, $result)
Called after each test.
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 temp or archived zone change it to an object instance and return false override the list derivative used the name of the old file when set the default code will be skipped $pre
Definition: hooks.txt:1306
isEnabled()
Returns true if tidy is usable.
$matches
start()
Set up result recording; insert a record for the run with the date and all that fun stuff...