MediaWiki  1.23.2
GlobalTest.php
Go to the documentation of this file.
1 <?php
2 
4  protected function setUp() {
5  parent::setUp();
6 
7  $readOnlyFile = tempnam( wfTempDir(), "mwtest_readonly" );
8  unlink( $readOnlyFile );
9 
10  $this->setMwGlobals( array(
11  'wgReadOnlyFile' => $readOnlyFile,
12  'wgUrlProtocols' => array(
13  'http://',
14  'https://',
15  'mailto:',
16  '//',
17  'file://', # Non-default
18  ),
19  ) );
20  }
21 
22  protected function tearDown() {
23  global $wgReadOnlyFile;
24 
25  if ( file_exists( $wgReadOnlyFile ) ) {
26  unlink( $wgReadOnlyFile );
27  }
28 
29  parent::tearDown();
30  }
31 
36  public function testWfArrayDiff2( $a, $b, $expected ) {
37  $this->assertEquals(
38  wfArrayDiff2( $a, $b ), $expected
39  );
40  }
41 
42  // @todo Provide more tests
43  public static function provideForWfArrayDiff2() {
44  // $a $b $expected
45  return array(
46  array(
47  array( 'a', 'b' ),
48  array( 'a', 'b' ),
49  array(),
50  ),
51  array(
52  array( array( 'a' ), array( 'a', 'b', 'c' ) ),
53  array( array( 'a' ), array( 'a', 'b' ) ),
54  array( 1 => array( 'a', 'b', 'c' ) ),
55  ),
56  );
57  }
58 
62  public function testRandom() {
63  # This could hypothetically fail, but it shouldn't ;)
64  $this->assertFalse(
65  wfRandom() == wfRandom() );
66  }
67 
71  public function testUrlencode() {
72  $this->assertEquals(
73  "%E7%89%B9%E5%88%A5:Contributions/Foobar",
74  wfUrlencode( "\xE7\x89\xB9\xE5\x88\xA5:Contributions/Foobar" ) );
75  }
76 
80  public function testExpandIRI() {
81  $this->assertEquals(
82  "https://te.wikibooks.org/wiki/ఉబుంటు_వాడుకరి_మార్గదర్శని",
83  wfExpandIRI( "https://te.wikibooks.org/wiki/%E0%B0%89%E0%B0%AC%E0%B1%81%E0%B0%82%E0%B0%9F%E0%B1%81_%E0%B0%B5%E0%B0%BE%E0%B0%A1%E0%B1%81%E0%B0%95%E0%B0%B0%E0%B0%BF_%E0%B0%AE%E0%B0%BE%E0%B0%B0%E0%B1%8D%E0%B0%97%E0%B0%A6%E0%B0%B0%E0%B1%8D%E0%B0%B6%E0%B0%A8%E0%B0%BF" ) );
84  }
85 
89  public function testReadOnlyEmpty() {
90  global $wgReadOnly;
91  $wgReadOnly = null;
92 
93  $this->assertFalse( wfReadOnly() );
94  $this->assertFalse( wfReadOnly() );
95  }
96 
100  public function testReadOnlySet() {
101  global $wgReadOnly, $wgReadOnlyFile;
102 
103  $f = fopen( $wgReadOnlyFile, "wt" );
104  fwrite( $f, 'Message' );
105  fclose( $f );
106  $wgReadOnly = null; # Check on $wgReadOnlyFile
107 
108  $this->assertTrue( wfReadOnly() );
109  $this->assertTrue( wfReadOnly() ); # Check cached
110 
111  unlink( $wgReadOnlyFile );
112  $wgReadOnly = null; # Clean cache
113 
114  $this->assertFalse( wfReadOnly() );
115  $this->assertFalse( wfReadOnly() );
116  }
117 
118  public static function provideArrayToCGI() {
119  return array(
120  array( array(), '' ), // empty
121  array( array( 'foo' => 'bar' ), 'foo=bar' ), // string test
122  array( array( 'foo' => '' ), 'foo=' ), // empty string test
123  array( array( 'foo' => 1 ), 'foo=1' ), // number test
124  array( array( 'foo' => true ), 'foo=1' ), // true test
125  array( array( 'foo' => false ), '' ), // false test
126  array( array( 'foo' => null ), '' ), // null test
127  array( array( 'foo' => 'A&B=5+6@!"\'' ), 'foo=A%26B%3D5%2B6%40%21%22%27' ), // urlencoding test
128  array( array( 'foo' => 'bar', 'baz' => 'is', 'asdf' => 'qwerty' ), 'foo=bar&baz=is&asdf=qwerty' ), // multi-item test
129  array( array( 'foo' => array( 'bar' => 'baz' ) ), 'foo%5Bbar%5D=baz' ),
130  array( array( 'foo' => array( 'bar' => 'baz', 'qwerty' => 'asdf' ) ), 'foo%5Bbar%5D=baz&foo%5Bqwerty%5D=asdf' ),
131  array( array( 'foo' => array( 'bar', 'baz' ) ), 'foo%5B0%5D=bar&foo%5B1%5D=baz' ),
132  array( array( 'foo' => array( 'bar' => array( 'bar' => 'baz' ) ) ), 'foo%5Bbar%5D%5Bbar%5D=baz' ),
133  );
134  }
135 
140  public function testArrayToCGI( $array, $result ) {
141  $this->assertEquals( $result, wfArrayToCgi( $array ) );
142  }
143 
147  public function testArrayToCGI2() {
148  $this->assertEquals(
149  "baz=bar&foo=bar",
150  wfArrayToCgi(
151  array( 'baz' => 'bar' ),
152  array( 'foo' => 'bar', 'baz' => 'overridden value' ) ) );
153  }
154 
155  public static function provideCgiToArray() {
156  return array(
157  array( '', array() ), // empty
158  array( 'foo=bar', array( 'foo' => 'bar' ) ), // string
159  array( 'foo=', array( 'foo' => '' ) ), // empty string
160  array( 'foo', array( 'foo' => '' ) ), // missing =
161  array( 'foo=bar&qwerty=asdf', array( 'foo' => 'bar', 'qwerty' => 'asdf' ) ), // multiple value
162  array( 'foo=A%26B%3D5%2B6%40%21%22%27', array( 'foo' => 'A&B=5+6@!"\'' ) ), // urldecoding test
163  array( 'foo%5Bbar%5D=baz', array( 'foo' => array( 'bar' => 'baz' ) ) ),
164  array( 'foo%5Bbar%5D=baz&foo%5Bqwerty%5D=asdf', array( 'foo' => array( 'bar' => 'baz', 'qwerty' => 'asdf' ) ) ),
165  array( 'foo%5B0%5D=bar&foo%5B1%5D=baz', array( 'foo' => array( 0 => 'bar', 1 => 'baz' ) ) ),
166  array( 'foo%5Bbar%5D%5Bbar%5D=baz', array( 'foo' => array( 'bar' => array( 'bar' => 'baz' ) ) ) ),
167  );
168  }
169 
174  public function testCgiToArray( $cgi, $result ) {
175  $this->assertEquals( $result, wfCgiToArray( $cgi ) );
176  }
177 
178  public static function provideCgiRoundTrip() {
179  return array(
180  array( '' ),
181  array( 'foo=bar' ),
182  array( 'foo=' ),
183  array( 'foo=bar&baz=biz' ),
184  array( 'foo=A%26B%3D5%2B6%40%21%22%27' ),
185  array( 'foo%5Bbar%5D=baz' ),
186  array( 'foo%5B0%5D=bar&foo%5B1%5D=baz' ),
187  array( 'foo%5Bbar%5D%5Bbar%5D=baz' ),
188  );
189  }
190 
195  public function testCgiRoundTrip( $cgi ) {
196  $this->assertEquals( $cgi, wfArrayToCgi( wfCgiToArray( $cgi ) ) );
197  }
198 
202  public function testMimeTypeMatch() {
203  $this->assertEquals(
204  'text/html',
205  mimeTypeMatch( 'text/html',
206  array( 'application/xhtml+xml' => 1.0,
207  'text/html' => 0.7,
208  'text/plain' => 0.3 ) ) );
209  $this->assertEquals(
210  'text/*',
211  mimeTypeMatch( 'text/html',
212  array( 'image/*' => 1.0,
213  'text/*' => 0.5 ) ) );
214  $this->assertEquals(
215  '*/*',
216  mimeTypeMatch( 'text/html',
217  array( '*/*' => 1.0 ) ) );
218  $this->assertNull(
219  mimeTypeMatch( 'text/html',
220  array( 'image/png' => 1.0,
221  'image/svg+xml' => 0.5 ) ) );
222  }
223 
227  public function testNegotiateType() {
228  $this->assertEquals(
229  'text/html',
231  array( 'application/xhtml+xml' => 1.0,
232  'text/html' => 0.7,
233  'text/plain' => 0.5,
234  'text/*' => 0.2 ),
235  array( 'text/html' => 1.0 ) ) );
236  $this->assertEquals(
237  'application/xhtml+xml',
239  array( 'application/xhtml+xml' => 1.0,
240  'text/html' => 0.7,
241  'text/plain' => 0.5,
242  'text/*' => 0.2 ),
243  array( 'application/xhtml+xml' => 1.0,
244  'text/html' => 0.5 ) ) );
245  $this->assertEquals(
246  'text/html',
248  array( 'text/html' => 1.0,
249  'text/plain' => 0.5,
250  'text/*' => 0.5,
251  'application/xhtml+xml' => 0.2 ),
252  array( 'application/xhtml+xml' => 1.0,
253  'text/html' => 0.5 ) ) );
254  $this->assertEquals(
255  'text/html',
257  array( 'text/*' => 1.0,
258  'image/*' => 0.7,
259  '*/*' => 0.3 ),
260  array( 'application/xhtml+xml' => 1.0,
261  'text/html' => 0.5 ) ) );
262  $this->assertNull(
264  array( 'text/*' => 1.0 ),
265  array( 'application/xhtml+xml' => 1.0 ) ) );
266  }
267 
272  public function testDebugFunctionTest() {
273 
274  global $wgDebugLogFile, $wgDebugTimestamps;
275 
276  $old_log_file = $wgDebugLogFile;
277  $wgDebugLogFile = tempnam( wfTempDir(), 'mw-' );
278  # @todo FIXME: $wgDebugTimestamps should be tested
279  $old_wgDebugTimestamps = $wgDebugTimestamps;
280  $wgDebugTimestamps = false;
281 
282  wfDebug( "This is a normal string" );
283  $this->assertEquals( "This is a normal string", file_get_contents( $wgDebugLogFile ) );
284  unlink( $wgDebugLogFile );
285 
286  wfDebug( "This is nöt an ASCII string" );
287  $this->assertEquals( "This is nöt an ASCII string", file_get_contents( $wgDebugLogFile ) );
288  unlink( $wgDebugLogFile );
289 
290  wfDebug( "\00305This has böth UTF and control chars\003" );
291  $this->assertEquals( " 05This has böth UTF and control chars ", file_get_contents( $wgDebugLogFile ) );
292  unlink( $wgDebugLogFile );
293 
294  wfDebugMem();
295  $this->assertGreaterThan( 1000, preg_replace( '/\D/', '', file_get_contents( $wgDebugLogFile ) ) );
296  unlink( $wgDebugLogFile );
297 
298  wfDebugMem( true );
299  $this->assertGreaterThan( 1000000, preg_replace( '/\D/', '', file_get_contents( $wgDebugLogFile ) ) );
300  unlink( $wgDebugLogFile );
301 
302  $wgDebugLogFile = $old_log_file;
303  $wgDebugTimestamps = $old_wgDebugTimestamps;
304  }
305 
309  public function testClientAcceptsGzipTest() {
310 
311  $settings = array(
312  'gzip' => true,
313  'bzip' => false,
314  '*' => false,
315  'compress, gzip' => true,
316  'gzip;q=1.0' => true,
317  'foozip' => false,
318  'foo*zip' => false,
319  'gzip;q=abcde' => true, //is this REALLY valid?
320  'gzip;q=12345678.9' => true,
321  ' gzip' => true,
322  );
323 
324  if ( isset( $_SERVER['HTTP_ACCEPT_ENCODING'] ) ) {
325  $old_server_setting = $_SERVER['HTTP_ACCEPT_ENCODING'];
326  }
327 
328  foreach ( $settings as $encoding => $expect ) {
329  $_SERVER['HTTP_ACCEPT_ENCODING'] = $encoding;
330 
331  $this->assertEquals( $expect, wfClientAcceptsGzip( true ),
332  "'$encoding' => " . wfBoolToStr( $expect ) );
333  }
334 
335  if ( isset( $old_server_setting ) ) {
336  $_SERVER['HTTP_ACCEPT_ENCODING'] = $old_server_setting;
337  }
338  }
339 
343  public function testSwapVarsTest() {
344  $var1 = 1;
345  $var2 = 2;
346 
347  $this->assertEquals( $var1, 1, 'var1 is set originally' );
348  $this->assertEquals( $var2, 2, 'var1 is set originally' );
349 
350  swap( $var1, $var2 );
351 
352  $this->assertEquals( $var1, 2, 'var1 is swapped' );
353  $this->assertEquals( $var2, 1, 'var2 is swapped' );
354  }
355 
359  public function testWfPercentTest() {
360 
361  $pcts = array(
362  array( 6 / 7, '0.86%', 2, false ),
363  array( 3 / 3, '1%' ),
364  array( 22 / 7, '3.14286%', 5 ),
365  array( 3 / 6, '0.5%' ),
366  array( 1 / 3, '0%', 0 ),
367  array( 10 / 3, '0%', -1 ),
368  array( 3 / 4 / 5, '0.1%', 1 ),
369  array( 6 / 7 * 8, '6.8571428571%', 10 ),
370  );
371 
372  foreach ( $pcts as $pct ) {
373  if ( !isset( $pct[2] ) ) {
374  $pct[2] = 2;
375  }
376  if ( !isset( $pct[3] ) ) {
377  $pct[3] = true;
378  }
379 
380  $this->assertEquals( wfPercent( $pct[0], $pct[2], $pct[3] ), $pct[1], $pct[1] );
381  }
382  }
383 
389  public function testWfShorthandToInteger( $shorthand, $expected ) {
390  $this->assertEquals( $expected,
391  wfShorthandToInteger( $shorthand )
392  );
393  }
394 
396  public static function provideShorthand() {
397  return array(
398  # Null, empty ...
399  array( '', -1 ),
400  array( ' ', -1 ),
401  array( null, -1 ),
402 
403  # Failures returns 0 :(
404  array( 'ABCDEFG', 0 ),
405  array( 'Ak', 0 ),
406 
407  # Int, strings with spaces
408  array( 1, 1 ),
409  array( ' 1 ', 1 ),
410  array( 1023, 1023 ),
411  array( ' 1023 ', 1023 ),
412 
413  # kilo, Mega, Giga
414  array( '1k', 1024 ),
415  array( '1K', 1024 ),
416  array( '1m', 1024 * 1024 ),
417  array( '1M', 1024 * 1024 ),
418  array( '1g', 1024 * 1024 * 1024 ),
419  array( '1G', 1024 * 1024 * 1024 ),
420 
421  # Negatives
422  array( -1, -1 ),
423  array( -500, -500 ),
424  array( '-500', -500 ),
425  array( '-1k', -1024 ),
426 
427  # Zeroes
428  array( '0', 0 ),
429  array( '0k', 0 ),
430  array( '0M', 0 ),
431  array( '0G', 0 ),
432  array( '-0', 0 ),
433  array( '-0k', 0 ),
434  array( '-0M', 0 ),
435  array( '-0G', 0 ),
436  );
437  }
438 
450  public function testMerge( $old, $mine, $yours, $expectedMergeResult, $expectedText ) {
451  $this->checkHasDiff3();
452 
453  $mergedText = null;
454  $isMerged = wfMerge( $old, $mine, $yours, $mergedText );
455 
456  $msg = 'Merge should be a ';
457  $msg .= $expectedMergeResult ? 'success' : 'failure';
458  $this->assertEquals( $expectedMergeResult, $isMerged, $msg );
459 
460  if ( $isMerged ) {
461  // Verify the merged text
462  $this->assertEquals( $expectedText, $mergedText,
463  'is merged text as expected?' );
464  }
465  }
466 
467  public static function provideMerge() {
468  $EXPECT_MERGE_SUCCESS = true;
469  $EXPECT_MERGE_FAILURE = false;
470 
471  return array(
472  // #0: clean merge
473  array(
474  // old:
475  "one one one\n" . // trimmed
476  "\n" .
477  "two two two",
478 
479  // mine:
480  "one one one ONE ONE\n" .
481  "\n" .
482  "two two two\n", // with tailing whitespace
483 
484  // yours:
485  "one one one\n" .
486  "\n" .
487  "two two TWO TWO", // trimmed
488 
489  // ok:
490  $EXPECT_MERGE_SUCCESS,
491 
492  // result:
493  "one one one ONE ONE\n" .
494  "\n" .
495  "two two TWO TWO\n", // note: will always end in a newline
496  ),
497 
498  // #1: conflict, fail
499  array(
500  // old:
501  "one one one", // trimmed
502 
503  // mine:
504  "one one one ONE ONE\n" .
505  "\n" .
506  "bla bla\n" .
507  "\n", // with tailing whitespace
508 
509  // yours:
510  "one one one\n" .
511  "\n" .
512  "two two", // trimmed
513 
514  $EXPECT_MERGE_FAILURE,
515 
516  // result:
517  null,
518  ),
519  );
520  }
521 
526  public function testMakeUrlIndexes( $url, $expected ) {
527  $index = wfMakeUrlIndexes( $url );
528  $this->assertEquals( $expected, $index, "wfMakeUrlIndexes(\"$url\")" );
529  }
530 
531  public static function provideMakeUrlIndexes() {
532  return array(
533  array(
534  // just a regular :)
535  'https://bugzilla.wikimedia.org/show_bug.cgi?id=28627',
536  array( 'https://org.wikimedia.bugzilla./show_bug.cgi?id=28627' )
537  ),
538  array(
539  // mailtos are handled special
540  // is this really right though? that final . probably belongs earlier?
541  'mailto:wiki@wikimedia.org',
542  array( 'mailto:org.wikimedia@wiki.' )
543  ),
544 
545  // file URL cases per bug 28627...
546  array(
547  // three slashes: local filesystem path Unix-style
548  'file:///whatever/you/like.txt',
549  array( 'file://./whatever/you/like.txt' )
550  ),
551  array(
552  // three slashes: local filesystem path Windows-style
553  'file:///c:/whatever/you/like.txt',
554  array( 'file://./c:/whatever/you/like.txt' )
555  ),
556  array(
557  // two slashes: UNC filesystem path Windows-style
558  'file://intranet/whatever/you/like.txt',
559  array( 'file://intranet./whatever/you/like.txt' )
560  ),
561  // Multiple-slash cases that can sorta work on Mozilla
562  // if you hack it just right are kinda pathological,
563  // and unreliable cross-platform or on IE which means they're
564  // unlikely to appear on intranets.
565  //
566  // Those will survive the algorithm but with results that
567  // are less consistent.
568 
569  // protocol-relative URL cases per bug 29854...
570  array(
571  '//bugzilla.wikimedia.org/show_bug.cgi?id=28627',
572  array(
573  'http://org.wikimedia.bugzilla./show_bug.cgi?id=28627',
574  'https://org.wikimedia.bugzilla./show_bug.cgi?id=28627'
575  )
576  ),
577  );
578  }
579 
584  public function testWfMatchesDomainList( $url, $domains, $expected, $description ) {
585  $actual = wfMatchesDomainList( $url, $domains );
586  $this->assertEquals( $expected, $actual, $description );
587  }
588 
589  public static function provideWfMatchesDomainList() {
590  $a = array();
591  $protocols = array( 'HTTP' => 'http:', 'HTTPS' => 'https:', 'protocol-relative' => '' );
592  foreach ( $protocols as $pDesc => $p ) {
593  $a = array_merge( $a, array(
594  array( "$p//www.example.com", array(), false, "No matches for empty domains array, $pDesc URL" ),
595  array( "$p//www.example.com", array( 'www.example.com' ), true, "Exact match in domains array, $pDesc URL" ),
596  array( "$p//www.example.com", array( 'example.com' ), true, "Match without subdomain in domains array, $pDesc URL" ),
597  array( "$p//www.example2.com", array( 'www.example.com', 'www.example2.com', 'www.example3.com' ), true, "Exact match with other domains in array, $pDesc URL" ),
598  array( "$p//www.example2.com", array( 'example.com', 'example2.com', 'example3,com' ), true, "Match without subdomain with other domains in array, $pDesc URL" ),
599  array( "$p//www.example4.com", array( 'example.com', 'example2.com', 'example3,com' ), false, "Domain not in array, $pDesc URL" ),
600  array( "$p//nds-nl.wikipedia.org", array( 'nl.wikipedia.org' ), false, "Non-matching substring of domain, $pDesc URL" ),
601  ) );
602  }
603 
604  return $a;
605  }
606 
610  public function testWfMkdirParents() {
611  // Should not return true if file exists instead of directory
612  $fname = $this->getNewTempFile();
616  $this->assertFalse( $ok );
617  }
618 
623  public function testWfShellMaintenanceCmd( $script, $parameters, $options, $expected, $description ) {
624  if ( wfIsWindows() ) {
625  // Approximation that's good enough for our purposes just now
626  $expected = str_replace( "'", '"', $expected );
627  }
628  $actual = wfShellMaintenanceCmd( $script, $parameters, $options );
629  $this->assertEquals( $expected, $actual, $description );
630  }
631 
632  public static function provideWfShellMaintenanceCmdList() {
633  global $wgPhpCli;
634 
635  return array(
636  array( 'eval.php', array( '--help', '--test' ), array(),
637  "'$wgPhpCli' 'eval.php' '--help' '--test'",
638  "Called eval.php --help --test" ),
639  array( 'eval.php', array( '--help', '--test space' ), array( 'php' => 'php5' ),
640  "'php5' 'eval.php' '--help' '--test space'",
641  "Called eval.php --help --test with php option" ),
642  array( 'eval.php', array( '--help', '--test', 'X' ), array( 'wrapper' => 'MWScript.php' ),
643  "'$wgPhpCli' 'MWScript.php' 'eval.php' '--help' '--test' 'X'",
644  "Called eval.php --help --test with wrapper option" ),
645  array( 'eval.php', array( '--help', '--test', 'y' ), array( 'php' => 'php5', 'wrapper' => 'MWScript.php' ),
646  "'php5' 'MWScript.php' 'eval.php' '--help' '--test' 'y'",
647  "Called eval.php --help --test with wrapper and php option" ),
648  );
649  }
650  /* @TODO many more! */
651 }
strings
it sets a lot of them automatically from query strings
Definition: design.txt:93
$result
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. $reader:XMLReader object $logInfo:Array of information Return false to stop further processing of the tag 'ImportHandlePageXMLTag':When parsing a XML tag in a page. $reader:XMLReader object $pageInfo:Array of information Return false to stop further processing of the tag 'ImportHandleRevisionXMLTag':When parsing a XML tag in a page revision. $reader:XMLReader object $pageInfo:Array of page information $revisionInfo:Array of revision information Return false to stop further processing of the tag 'ImportHandleToplevelXMLTag':When parsing a top level XML tag. $reader:XMLReader object Return false to stop further processing of the tag 'ImportHandleUploadXMLTag':When parsing a XML tag in a file upload. $reader:XMLReader object $revisionInfo:Array of information Return false to stop further processing of the tag '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 '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. '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 '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 '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 wfIsTrustedProxy() $ip:IP being check $result:Change this value to override the result of wfIsTrustedProxy() '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 User::isValidEmailAddr(), 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. '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 '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) '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. '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:1528
wfPercent
wfPercent( $nr, $acc=2, $round=true)
Definition: GlobalFunctions.php:2657
GlobalTest\testMimeTypeMatch
testMimeTypeMatch()
@covers mimeTypeMatch
Definition: GlobalTest.php:202
php
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
Definition: skin.txt:62
wfShellMaintenanceCmd
wfShellMaintenanceCmd( $script, array $parameters=array(), array $options=array())
Alias to wfShellWikiCmd()
Definition: GlobalFunctions.php:3046
wfMerge
wfMerge( $old, $mine, $yours, &$result)
wfMerge attempts to merge differences between three texts.
Definition: GlobalFunctions.php:3086
wfMkdirParents
wfMkdirParents( $dir, $mode=null, $caller=null)
Make directory, and make all parent directories if they don't exist.
Definition: GlobalFunctions.php:2590
GlobalTest\testCgiRoundTrip
testCgiRoundTrip( $cgi)
@dataProvider provideCgiRoundTrip @covers wfArrayToCgi
Definition: GlobalTest.php:195
$f
$f
Definition: UtfNormalTest2.php:38
wfNegotiateType
wfNegotiateType( $cprefs, $sprefs)
Returns the 'best' match between a client's requested internet media types and the server's list of a...
Definition: GlobalFunctions.php:2346
wfMakeUrlIndexes
wfMakeUrlIndexes( $url)
Make URL indexes, appropriate for the el_index field of externallinks.
Definition: GlobalFunctions.php:848
wfSuppressWarnings
wfSuppressWarnings( $end=false)
Reference-counted warning suppression.
Definition: GlobalFunctions.php:2387
wfUrlencode
wfUrlencode( $s)
We want some things to be included as literal characters in our title URLs for prettiness,...
Definition: GlobalFunctions.php:330
wfArrayDiff2
if(!defined( 'MEDIAWIKI')) wfArrayDiff2( $a, $b)
Like array_diff( $a, $b ) except that it works with two-dimensional arrays.
Definition: GlobalFunctions.php:113
$fname
if(!defined( 'MEDIAWIKI')) $fname
This file is not a valid entry point, perform no further processing unless MEDIAWIKI is defined.
Definition: Setup.php:35
wfReadOnly
wfReadOnly()
Check whether the wiki is in read-only mode.
Definition: GlobalFunctions.php:1313
GlobalTest\testExpandIRI
testExpandIRI()
@covers wfExpandIRI
Definition: GlobalTest.php:80
wfExpandIRI
wfExpandIRI( $url)
Take a URL, make sure it's expanded to fully qualified, and replace any encoded non-ASCII Unicode cha...
Definition: GlobalFunctions.php:825
cache
you have access to all of the normal MediaWiki so you can get a DB use the cache
Definition: maintenance.txt:52
GlobalTest\testClientAcceptsGzipTest
testClientAcceptsGzipTest()
@covers wfClientAcceptsGzip
Definition: GlobalTest.php:309
GlobalTest\testWfArrayDiff2
testWfArrayDiff2( $a, $b, $expected)
@dataProvider provideForWfArrayDiff2 @covers wfArrayDiff2
Definition: GlobalTest.php:36
wfBoolToStr
wfBoolToStr( $value)
Convenience function converts boolean values into "true" or "false" (string) values.
Definition: GlobalFunctions.php:3771
GlobalTest\testRandom
testRandom()
@covers wfRandom
Definition: GlobalTest.php:62
GlobalTest\testMerge
testMerge( $old, $mine, $yours, $expectedMergeResult, $expectedText)
Definition: GlobalTest.php:450
GlobalTest\tearDown
tearDown()
Definition: GlobalTest.php:22
MediaWikiTestCase\checkHasDiff3
checkHasDiff3()
Check, if $wgDiff3 is set and ready to merge Will mark the calling test as skipped,...
Definition: MediaWikiTestCase.php:959
GlobalTest\testWfPercentTest
testWfPercentTest()
@covers wfPercent
Definition: GlobalTest.php:359
mimeTypeMatch
mimeTypeMatch( $type, $avail)
Checks if a given MIME type matches any of the keys in the given array.
Definition: GlobalFunctions.php:2318
GlobalTest\provideArrayToCGI
static provideArrayToCGI()
Definition: GlobalTest.php:118
wfRestoreWarnings
wfRestoreWarnings()
Restore error level to previous value.
Definition: GlobalFunctions.php:2417
MediaWikiTestCase\setMwGlobals
setMwGlobals( $pairs, $value=null)
Definition: MediaWikiTestCase.php:302
MediaWikiTestCase\getNewTempFile
getNewTempFile()
Obtains a new temporary file name.
Definition: MediaWikiTestCase.php:156
MediaWikiTestCase
Definition: MediaWikiTestCase.php:6
GlobalTest
Definition: GlobalTest.php:3
swap
swap(&$x, &$y)
Swap two variables.
Definition: GlobalFunctions.php:2547
wfShorthandToInteger
wfShorthandToInteger( $string='')
Converts shorthand byte notation to integer form.
Definition: GlobalFunctions.php:3889
wfCgiToArray
wfCgiToArray( $query)
This is the logical opposite of wfArrayToCgi(): it accepts a query string as its argument and returns...
Definition: GlobalFunctions.php:412
GlobalTest\testWfShellMaintenanceCmd
testWfShellMaintenanceCmd( $script, $parameters, $options, $expected, $description)
@dataProvider provideWfShellMaintenanceCmdList @covers wfShellMaintenanceCmd
Definition: GlobalTest.php:623
array
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
global
when a variable name is used in a it is silently declared as a new masking the global
Definition: design.txt:93
GlobalTest\testCgiToArray
testCgiToArray( $cgi, $result)
@dataProvider provideCgiToArray @covers wfCgiToArray
Definition: GlobalTest.php:174
GlobalTest\testReadOnlySet
testReadOnlySet()
@covers wfReadOnly
Definition: GlobalTest.php:100
$options
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 & $options
Definition: hooks.txt:1530
GlobalTest\provideMakeUrlIndexes
static provideMakeUrlIndexes()
Definition: GlobalTest.php:531
$ok
$ok
Definition: UtfNormalTest.php:71
GlobalTest\setUp
setUp()
Definition: GlobalTest.php:4
wfDebug
wfDebug( $text, $dest='all')
Sends a line to the debug log if enabled or, optionally, to a comment in output.
Definition: GlobalFunctions.php:933
wfClientAcceptsGzip
wfClientAcceptsGzip( $force=false)
Definition: GlobalFunctions.php:2029
wfIsWindows
wfIsWindows()
Check if the operating system is Windows.
Definition: GlobalFunctions.php:2524
GlobalTest\testDebugFunctionTest
testDebugFunctionTest()
@covers wfDebug @covers wfDebugMem
Definition: GlobalTest.php:272
GlobalTest\testSwapVarsTest
testSwapVarsTest()
@covers swap
Definition: GlobalTest.php:343
wfDebugMem
wfDebugMem( $exact=false)
Send a line giving PHP memory usage.
Definition: GlobalFunctions.php:1010
GlobalTest\provideMerge
static provideMerge()
Definition: GlobalTest.php:467
GlobalTest\testWfMatchesDomainList
testWfMatchesDomainList( $url, $domains, $expected, $description)
@dataProvider provideWfMatchesDomainList @covers wfMatchesDomainList
Definition: GlobalTest.php:584
GlobalTest\provideWfMatchesDomainList
static provideWfMatchesDomainList()
Definition: GlobalTest.php:589
GlobalTest\testWfShorthandToInteger
testWfShorthandToInteger( $shorthand, $expected)
test
Definition: GlobalTest.php:389
GlobalTest\provideShorthand
static provideShorthand()
array( shorthand, expected integer )
Definition: GlobalTest.php:396
wfRandom
wfRandom()
Get a random decimal value between 0 and 1, in a way not likely to give duplicate values for any real...
Definition: GlobalFunctions.php:281
wfTempDir
wfTempDir()
Tries to get the system directory for temporary files.
Definition: GlobalFunctions.php:2564
wfMatchesDomainList
wfMatchesDomainList( $url, $domains)
Check whether a given URL has a domain that occurs in a given set of domains.
Definition: GlobalFunctions.php:902
GlobalTest\testUrlencode
testUrlencode()
@covers wfUrlencode
Definition: GlobalTest.php:71
GlobalTest\testArrayToCGI2
testArrayToCGI2()
@covers wfArrayToCgi
Definition: GlobalTest.php:147
on
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 on
Definition: hooks.txt:86
as
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
GlobalTest\testArrayToCGI
testArrayToCGI( $array, $result)
@dataProvider provideArrayToCGI @covers wfArrayToCgi
Definition: GlobalTest.php:140
GlobalTest\provideWfShellMaintenanceCmdList
static provideWfShellMaintenanceCmdList()
Definition: GlobalTest.php:632
GlobalTest\testReadOnlyEmpty
testReadOnlyEmpty()
@covers wfReadOnly
Definition: GlobalTest.php:89
GlobalTest\provideCgiToArray
static provideCgiToArray()
Definition: GlobalTest.php:155
GlobalTest\testMakeUrlIndexes
testMakeUrlIndexes( $url, $expected)
@dataProvider provideMakeUrlIndexes() @covers wfMakeUrlIndexes
Definition: GlobalTest.php:526
GlobalTest\provideForWfArrayDiff2
static provideForWfArrayDiff2()
Definition: GlobalTest.php:43
GlobalTest\testNegotiateType
testNegotiateType()
@covers wfNegotiateType
Definition: GlobalTest.php:227
GlobalTest\provideCgiRoundTrip
static provideCgiRoundTrip()
Definition: GlobalTest.php:178
wfArrayToCgi
wfArrayToCgi( $array1, $array2=null, $prefix='')
This function takes two arrays as input, and returns a CGI-style string, e.g.
Definition: GlobalFunctions.php:367
GlobalTest\testWfMkdirParents
testWfMkdirParents()
@covers wfMkdirParents
Definition: GlobalTest.php:610