MediaWiki  1.23.0
TitleTest.php
Go to the documentation of this file.
1 <?php
2 
9 class TitleTest extends MediaWikiTestCase {
10  protected function setUp() {
11  parent::setUp();
12 
13  $this->setMwGlobals( array(
14  'wgLanguageCode' => 'en',
15  'wgContLang' => Language::factory( 'en' ),
16  // User language
17  'wgLang' => Language::factory( 'en' ),
18  'wgAllowUserJs' => false,
19  'wgDefaultLanguageVariant' => false,
20  ) );
21  }
22 
26  public function testLegalChars() {
27  $titlechars = Title::legalChars();
28 
29  foreach ( range( 1, 255 ) as $num ) {
30  $chr = chr( $num );
31  if ( strpos( "#[]{}<>|", $chr ) !== false || preg_match( "/[\\x00-\\x1f\\x7f]/", $chr ) ) {
32  $this->assertFalse( (bool)preg_match( "/[$titlechars]/", $chr ), "chr($num) = $chr is not a valid titlechar" );
33  } else {
34  $this->assertTrue( (bool)preg_match( "/[$titlechars]/", $chr ), "chr($num) = $chr is a valid titlechar" );
35  }
36  }
37  }
38 
45  public function testSecureAndSplit() {
46  $this->setMwGlobals( array(
47  'wgLocalInterwikis' => array( 'localtestiw' ),
48  'wgHooks' => array(
49  'InterwikiLoadPrefix' => array(
50  function ( $prefix, &$data ) {
51  if ( $prefix === 'localtestiw' ) {
52  $data = array( 'iw_url' => 'localtestiw' );
53  } elseif ( $prefix === 'remotetestiw' ) {
54  $data = array( 'iw_url' => 'remotetestiw' );
55  }
56  return false;
57  }
58  )
59  )
60  ));
61  // Valid
62  foreach ( array(
63  'Sandbox',
64  'A "B"',
65  'A \'B\'',
66  '.com',
67  '~',
68  '#',
69  '"',
70  '\'',
71  'Talk:Sandbox',
72  'Talk:Foo:Sandbox',
73  'File:Example.svg',
74  'File_talk:Example.svg',
75  'Foo/.../Sandbox',
76  'Sandbox/...',
77  'A~~',
78  // Length is 256 total, but only title part matters
79  'Category:' . str_repeat( 'x', 248 ),
80  str_repeat( 'x', 252 ),
81  // interwiki prefix
82  'localtestiw: #anchor',
83  'localtestiw:foo',
84  'localtestiw: foo # anchor',
85  'localtestiw: Talk: Sandbox # anchor',
86  'remotetestiw:',
87  'remotetestiw: Talk: # anchor',
88  'remotetestiw: #bar',
89  'remotetestiw: Talk:',
90  'remotetestiw: Talk: Foo'
91  ) as $text ) {
92  $this->assertInstanceOf( 'Title', Title::newFromText( $text ), "Valid: $text" );
93  }
94 
95  // Invalid
96  foreach ( array(
97  '',
98  ':',
99  '__ __',
100  ' __ ',
101  // Bad characters forbidden regardless of wgLegalTitleChars
102  'A [ B',
103  'A ] B',
104  'A { B',
105  'A } B',
106  'A < B',
107  'A > B',
108  'A | B',
109  // URL encoding
110  'A%20B',
111  'A%23B',
112  'A%2523B',
113  // XML/HTML character entity references
114  // Note: Commented out because they are not marked invalid by the PHP test as
115  // Title::newFromText runs Sanitizer::decodeCharReferencesAndNormalize first.
116  //'A &eacute; B',
117  //'A &#233; B',
118  //'A &#x00E9; B',
119  // Subject of NS_TALK does not roundtrip to NS_MAIN
120  'Talk:File:Example.svg',
121  // Directory navigation
122  '.',
123  '..',
124  './Sandbox',
125  '../Sandbox',
126  'Foo/./Sandbox',
127  'Foo/../Sandbox',
128  'Sandbox/.',
129  'Sandbox/..',
130  // Tilde
131  'A ~~~ Name',
132  'A ~~~~ Signature',
133  'A ~~~~~ Timestamp',
134  str_repeat( 'x', 256 ),
135  // Namespace prefix without actual title
136  'Talk:',
137  'Talk:#',
138  'Category: ',
139  'Category: #bar',
140  // interwiki prefix
141  'localtestiw:',
142  'localtestiw: Talk: # anchor',
143  'localtestiw: Talk:'
144  ) as $text ) {
145  $this->assertNull( Title::newFromText( $text ), "Invalid: $text" );
146  }
147  }
148 
149  public static function provideConvertByteClassToUnicodeClass() {
150  return array(
151  array(
152  ' %!"$&\'()*,\\-.\\/0-9:;=?@A-Z\\\\^_`a-z~\\x80-\\xFF+',
153  ' %!"$&\'()*,\\-./0-9:;=?@A-Z\\\\\\^_`a-z~+\\u0080-\\uFFFF',
154  ),
155  array(
156  'QWERTYf-\\xFF+',
157  'QWERTYf-\\x7F+\\u0080-\\uFFFF',
158  ),
159  array(
160  'QWERTY\\x66-\\xFD+',
161  'QWERTYf-\\x7F+\\u0080-\\uFFFF',
162  ),
163  array(
164  'QWERTYf-y+',
165  'QWERTYf-y+',
166  ),
167  array(
168  'QWERTYf-\\x80+',
169  'QWERTYf-\\x7F+\\u0080-\\uFFFF',
170  ),
171  array(
172  'QWERTY\\x66-\\x80+\\x23',
173  'QWERTYf-\\x7F+#\\u0080-\\uFFFF',
174  ),
175  array(
176  'QWERTY\\x66-\\x80+\\xD3',
177  'QWERTYf-\\x7F+\\u0080-\\uFFFF',
178  ),
179  array(
180  '\\\\\\x99',
181  '\\\\\\u0080-\\uFFFF',
182  ),
183  array(
184  '-\\x99',
185  '\\-\\u0080-\\uFFFF',
186  ),
187  array(
188  'QWERTY\\-\\x99',
189  'QWERTY\\-\\u0080-\\uFFFF',
190  ),
191  array(
192  '\\\\x99',
193  '\\\\x99',
194  ),
195  array(
196  'A-\\x9F',
197  'A-\\x7F\\u0080-\\uFFFF',
198  ),
199  array(
200  '\\x66-\\x77QWERTY\\x88-\\x91FXZ',
201  'f-wQWERTYFXZ\\u0080-\\uFFFF',
202  ),
203  array(
204  '\\x66-\\x99QWERTY\\xAA-\\xEEFXZ',
205  'f-\\x7FQWERTYFXZ\\u0080-\\uFFFF',
206  ),
207  );
208  }
209 
214  public function testConvertByteClassToUnicodeClass( $byteClass, $unicodeClass ) {
215  $this->assertEquals( $unicodeClass, Title::convertByteClassToUnicodeClass( $byteClass ) );
216  }
217 
223  public function testBug31100FixSpecialName( $text, $expectedParam ) {
224  $title = Title::newFromText( $text );
225  $fixed = $title->fixSpecialName();
226  $stuff = explode( '/', $fixed->getDBkey(), 2 );
227  if ( count( $stuff ) == 2 ) {
228  $par = $stuff[1];
229  } else {
230  $par = null;
231  }
232  $this->assertEquals( $expectedParam, $par, "Bug 31100 regression check: Title->fixSpecialName() should preserve parameter" );
233  }
234 
235  public static function provideBug31100() {
236  return array(
237  array( 'Special:Version', null ),
238  array( 'Special:Version/', '' ),
239  array( 'Special:Version/param', 'param' ),
240  );
241  }
242 
253  public function testIsValidMoveOperation( $source, $target, $expected ) {
255  $nt = Title::newFromText( $target );
256  $errors = $title->isValidMoveOperation( $nt, false );
257  if ( $expected === true ) {
258  $this->assertTrue( $errors );
259  } else {
260  $errors = $this->flattenErrorsArray( $errors );
261  foreach ( (array)$expected as $error ) {
262  $this->assertContains( $error, $errors );
263  }
264  }
265  }
266 
270  public function dataTestIsValidMoveOperation() {
271  return array(
272  array( 'Test', 'Test', 'selfmove' ),
273  array( 'File:Test.jpg', 'Page', 'imagenocrossnamespace' )
274  );
275  }
276 
288  public function testWgWhitelistReadRegexp( $whitelistRegexp, $source, $action, $expected ) {
289  // $wgWhitelistReadRegexp must be an array. Since the provided test cases
290  // usually have only one regex, it is more concise to write the lonely regex
291  // as a string. Thus we cast to an array() to honor $wgWhitelistReadRegexp
292  // type requisite.
293  if ( is_string( $whitelistRegexp ) ) {
294  $whitelistRegexp = array( $whitelistRegexp );
295  }
296 
298 
299  global $wgGroupPermissions;
300  $oldPermissions = $wgGroupPermissions;
301  // Disallow all so we can ensure our regex works
302  $wgGroupPermissions = array();
303  $wgGroupPermissions['*']['read'] = false;
304 
305  global $wgWhitelistRead;
306  $oldWhitelist = $wgWhitelistRead;
307  // Undo any LocalSettings explicite whitelists so they won't cause a
308  // failing test to succeed. Set it to some random non sense just
309  // to make sure we properly test Title::checkReadPermissions()
310  $wgWhitelistRead = array( 'some random non sense title' );
311 
312  global $wgWhitelistReadRegexp;
313  $oldWhitelistRegexp = $wgWhitelistReadRegexp;
314  $wgWhitelistReadRegexp = $whitelistRegexp;
315 
316  // Just use $wgUser which in test is a user object for '127.0.0.1'
317  global $wgUser;
318  // Invalidate user rights cache to take in account $wgGroupPermissions
319  // change above.
320  $wgUser->clearInstanceCache();
321  $errors = $title->userCan( $action, $wgUser );
322 
323  // Restore globals
324  $wgGroupPermissions = $oldPermissions;
325  $wgWhitelistRead = $oldWhitelist;
326  $wgWhitelistReadRegexp = $oldWhitelistRegexp;
327 
328  if ( is_bool( $expected ) ) {
329  # Forge the assertion message depending on the assertion expectation
330  $allowableness = $expected
331  ? " should be allowed"
332  : " should NOT be allowed";
333  $this->assertEquals( $expected, $errors, "User action '$action' on [[$source]] $allowableness." );
334  } else {
335  $errors = $this->flattenErrorsArray( $errors );
336  foreach ( (array)$expected as $error ) {
337  $this->assertContains( $error, $errors );
338  }
339  }
340  }
341 
345  public function dataWgWhitelistReadRegexp() {
346  $ALLOWED = true;
347  $DISALLOWED = false;
348 
349  return array(
350  // Everything, if this doesn't work, we're really in trouble
351  array( '/.*/', 'Main_Page', 'read', $ALLOWED ),
352  array( '/.*/', 'Main_Page', 'edit', $DISALLOWED ),
353 
354  // We validate against the title name, not the db key
355  array( '/^Main_Page$/', 'Main_Page', 'read', $DISALLOWED ),
356  // Main page
357  array( '/^Main/', 'Main_Page', 'read', $ALLOWED ),
358  array( '/^Main.*/', 'Main_Page', 'read', $ALLOWED ),
359  // With spaces
360  array( '/Mic\sCheck/', 'Mic Check', 'read', $ALLOWED ),
361  // Unicode multibyte
362  // ...without unicode modifier
363  array( '/Unicode Test . Yes/', 'Unicode Test Ñ Yes', 'read', $DISALLOWED ),
364  // ...with unicode modifier
365  array( '/Unicode Test . Yes/u', 'Unicode Test Ñ Yes', 'read', $ALLOWED ),
366  // Case insensitive
367  array( '/MiC ChEcK/', 'mic check', 'read', $DISALLOWED ),
368  array( '/MiC ChEcK/i', 'mic check', 'read', $ALLOWED ),
369 
370  // From DefaultSettings.php:
371  array( "@^UsEr.*@i", 'User is banned', 'read', $ALLOWED ),
372  array( "@^UsEr.*@i", 'User:John Doe', 'read', $ALLOWED ),
373 
374  // With namespaces:
375  array( '/^Special:NewPages$/', 'Special:NewPages', 'read', $ALLOWED ),
376  array( null, 'Special:Newpages', 'read', $DISALLOWED ),
377 
378  );
379  }
380 
381  public function flattenErrorsArray( $errors ) {
382  $result = array();
383  foreach ( $errors as $error ) {
384  $result[] = $error[0];
385  }
386 
387  return $result;
388  }
389 
390  public static function provideTestIsValidMoveOperation() {
391  return array(
392  array( 'Test', 'Test', 'selfmove' ),
393  array( 'File:Test.jpg', 'Page', 'imagenocrossnamespace' )
394  );
395  }
396 
401  public function testGetPageViewLanguage( $expected, $titleText, $contLang, $lang, $variant, $msg = '' ) {
402  global $wgLanguageCode, $wgContLang, $wgLang, $wgDefaultLanguageVariant, $wgAllowUserJs;
403 
404  // Setup environnement for this test
405  $wgLanguageCode = $contLang;
406  $wgContLang = Language::factory( $contLang );
407  $wgLang = Language::factory( $lang );
408  $wgDefaultLanguageVariant = $variant;
409  $wgAllowUserJs = true;
410 
411  $title = Title::newFromText( $titleText );
412  $this->assertInstanceOf( 'Title', $title,
413  "Test must be passed a valid title text, you gave '$titleText'"
414  );
415  $this->assertEquals( $expected,
416  $title->getPageViewLanguage()->getCode(),
417  $msg
418  );
419  }
420 
421  public static function provideGetPageViewLanguage() {
422  # Format:
423  # - expected
424  # - Title name
425  # - wgContLang (expected in most case)
426  # - wgLang (on some specific pages)
427  # - wgDefaultLanguageVariant
428  # - Optional message
429  return array(
430  array( 'fr', 'Help:I_need_somebody', 'fr', 'fr', false ),
431  array( 'es', 'Help:I_need_somebody', 'es', 'zh-tw', false ),
432  array( 'zh', 'Help:I_need_somebody', 'zh', 'zh-tw', false ),
433 
434  array( 'es', 'Help:I_need_somebody', 'es', 'zh-tw', 'zh-cn' ),
435  array( 'es', 'MediaWiki:About', 'es', 'zh-tw', 'zh-cn' ),
436  array( 'es', 'MediaWiki:About/', 'es', 'zh-tw', 'zh-cn' ),
437  array( 'de', 'MediaWiki:About/de', 'es', 'zh-tw', 'zh-cn' ),
438  array( 'en', 'MediaWiki:Common.js', 'es', 'zh-tw', 'zh-cn' ),
439  array( 'en', 'MediaWiki:Common.css', 'es', 'zh-tw', 'zh-cn' ),
440  array( 'en', 'User:JohnDoe/Common.js', 'es', 'zh-tw', 'zh-cn' ),
441  array( 'en', 'User:JohnDoe/Monobook.css', 'es', 'zh-tw', 'zh-cn' ),
442 
443  array( 'zh-cn', 'Help:I_need_somebody', 'zh', 'zh-tw', 'zh-cn' ),
444  array( 'zh', 'MediaWiki:About', 'zh', 'zh-tw', 'zh-cn' ),
445  array( 'zh', 'MediaWiki:About/', 'zh', 'zh-tw', 'zh-cn' ),
446  array( 'de', 'MediaWiki:About/de', 'zh', 'zh-tw', 'zh-cn' ),
447  array( 'zh-cn', 'MediaWiki:About/zh-cn', 'zh', 'zh-tw', 'zh-cn' ),
448  array( 'zh-tw', 'MediaWiki:About/zh-tw', 'zh', 'zh-tw', 'zh-cn' ),
449  array( 'en', 'MediaWiki:Common.js', 'zh', 'zh-tw', 'zh-cn' ),
450  array( 'en', 'MediaWiki:Common.css', 'zh', 'zh-tw', 'zh-cn' ),
451  array( 'en', 'User:JohnDoe/Common.js', 'zh', 'zh-tw', 'zh-cn' ),
452  array( 'en', 'User:JohnDoe/Monobook.css', 'zh', 'zh-tw', 'zh-cn' ),
453 
454  array( 'zh-tw', 'Special:NewPages', 'es', 'zh-tw', 'zh-cn' ),
455  array( 'zh-tw', 'Special:NewPages', 'zh', 'zh-tw', 'zh-cn' ),
456 
457  );
458  }
459 
464  public function testGetBaseText( $title, $expected, $msg = '' ) {
466  $this->assertEquals( $expected,
467  $title->getBaseText(),
468  $msg
469  );
470  }
471 
472  public static function provideBaseTitleCases() {
473  return array(
474  # Title, expected base, optional message
475  array( 'User:John_Doe/subOne/subTwo', 'John Doe/subOne' ),
476  array( 'User:Foo/Bar/Baz', 'Foo/Bar' ),
477  );
478  }
479 
484  public function testGetRootText( $title, $expected, $msg = '' ) {
486  $this->assertEquals( $expected,
487  $title->getRootText(),
488  $msg
489  );
490  }
491 
492  public static function provideRootTitleCases() {
493  return array(
494  # Title, expected base, optional message
495  array( 'User:John_Doe/subOne/subTwo', 'John Doe' ),
496  array( 'User:Foo/Bar/Baz', 'Foo' ),
497  );
498  }
499 
505  public function testGetSubpageText( $title, $expected, $msg = '' ) {
507  $this->assertEquals( $expected,
508  $title->getSubpageText(),
509  $msg
510  );
511  }
512 
513  public static function provideSubpageTitleCases() {
514  return array(
515  # Title, expected base, optional message
516  array( 'User:John_Doe/subOne/subTwo', 'subTwo' ),
517  array( 'User:John_Doe/subOne', 'subOne' ),
518  );
519  }
520 
521  public function provideNewFromTitleValue() {
522  return array(
523  array( new TitleValue( NS_MAIN, 'Foo' ) ),
524  array( new TitleValue( NS_MAIN, 'Foo', 'bar' ) ),
525  array( new TitleValue( NS_USER, 'Hansi_Maier' ) ),
526  );
527  }
528 
534 
535  $dbkey = str_replace( ' ', '_', $value->getText() );
536  $this->assertEquals( $dbkey, $title->getDBkey() );
537  $this->assertEquals( $value->getNamespace(), $title->getNamespace() );
538  $this->assertEquals( $value->getFragment(), $title->getFragment() );
539  }
540 
541  public function provideGetTitleValue() {
542  return array(
543  array( 'Foo' ),
544  array( 'Foo#bar' ),
545  array( 'User:Hansi_Maier' ),
546  );
547  }
548 
552  public function testGetTitleValue( $text ) {
553  $title = Title::newFromText( $text );
554  $value = $title->getTitleValue();
555 
556  $dbkey = str_replace( ' ', '_', $value->getText() );
557  $this->assertEquals( $title->getDBkey(), $dbkey );
558  $this->assertEquals( $title->getNamespace(), $value->getNamespace() );
559  $this->assertEquals( $title->getFragment(), $value->getFragment() );
560  }
561 
562  public function provideGetFragment() {
563  return array(
564  array( 'Foo', '' ),
565  array( 'Foo#bar', 'bar' ),
566  array( 'Foo#bär', 'bär' ),
567 
568  // Inner whitespace is normalized
569  array( 'Foo#bar_bar', 'bar bar' ),
570  array( 'Foo#bar bar', 'bar bar' ),
571  array( 'Foo#bar bar', 'bar bar' ),
572 
573  // Leading whitespace is kept, trailing whitespace is trimmed.
574  // XXX: Is this really want we want?
575  array( 'Foo#_bar_bar_', ' bar bar' ),
576  array( 'Foo# bar bar ', ' bar bar' ),
577  );
578  }
579 
586  public function testGetFragment( $full, $fragment ) {
587  $title = Title::newFromText( $full );
588  $this->assertEquals( $fragment, $title->getFragment() );
589  }
590 }
$wgUser
$wgUser
Definition: Setup.php:552
$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
Title\newFromText
static newFromText( $text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
Definition: Title.php:189
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
TitleTest\testLegalChars
testLegalChars()
@covers Title::legalChars
Definition: TitleTest.php:26
TitleTest\provideBug31100
static provideBug31100()
Definition: TitleTest.php:235
TitleTest\provideConvertByteClassToUnicodeClass
static provideConvertByteClassToUnicodeClass()
Definition: TitleTest.php:149
TitleTest\testConvertByteClassToUnicodeClass
testConvertByteClassToUnicodeClass( $byteClass, $unicodeClass)
@dataProvider provideConvertByteClassToUnicodeClass @covers Title::convertByteClassToUnicodeClass
Definition: TitleTest.php:214
TitleTest\testGetPageViewLanguage
testGetPageViewLanguage( $expected, $titleText, $contLang, $lang, $variant, $msg='')
@dataProvider provideGetPageViewLanguage @covers Title::getPageViewLanguage
Definition: TitleTest.php:401
TitleTest\provideBaseTitleCases
static provideBaseTitleCases()
Definition: TitleTest.php:472
TitleTest\provideGetFragment
provideGetFragment()
Definition: TitleTest.php:562
TitleTest\provideSubpageTitleCases
static provideSubpageTitleCases()
Definition: TitleTest.php:513
TitleTest\testSecureAndSplit
testSecureAndSplit()
See also mediawiki.Title.test.js @covers Title::secureAndSplit.
Definition: TitleTest.php:45
TitleTest\provideTestIsValidMoveOperation
static provideTestIsValidMoveOperation()
Definition: TitleTest.php:390
$wgContLang
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 content language as $wgContLang
Definition: design.txt:56
Title\convertByteClassToUnicodeClass
static convertByteClassToUnicodeClass( $byteClass)
Utility method for converting a character sequence from bytes to Unicode.
Definition: Title.php:572
TitleTest\testGetSubpageText
testGetSubpageText( $title, $expected, $msg='')
Definition: TitleTest.php:505
TitleTest\testGetFragment
testGetFragment( $full, $fragment)
@dataProvider provideGetFragment
Definition: TitleTest.php:586
NS_MAIN
const NS_MAIN
Definition: Defines.php:79
MediaWikiTestCase\setMwGlobals
setMwGlobals( $pairs, $value=null)
Definition: MediaWikiTestCase.php:302
MediaWikiTestCase
Definition: MediaWikiTestCase.php:6
TitleTest\dataWgWhitelistReadRegexp
dataWgWhitelistReadRegexp()
Provides test parameter values for testWgWhitelistReadRegexp()
Definition: TitleTest.php:345
array
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
TitleTest\testIsValidMoveOperation
testIsValidMoveOperation( $source, $target, $expected)
Auth-less test of Title::isValidMoveOperation.
Definition: TitleTest.php:253
global
when a variable name is used in a it is silently declared as a new masking the global
Definition: design.txt:93
TitleTest
@group Database ^— needed for language cache stuff
Definition: TitleTest.php:9
TitleTest\dataTestIsValidMoveOperation
dataTestIsValidMoveOperation()
Provides test parameter values for testIsValidMoveOperation()
Definition: TitleTest.php:270
TitleTest\provideGetPageViewLanguage
static provideGetPageViewLanguage()
Definition: TitleTest.php:421
Title\newFromTitleValue
static newFromTitleValue(TitleValue $titleValue)
Create a new Title from a TitleValue.
Definition: Title.php:169
$title
presenting them properly to the user as errors is done by the caller $title
Definition: hooks.txt:1324
$value
$value
Definition: styleTest.css.php:45
TitleTest\flattenErrorsArray
flattenErrorsArray( $errors)
Definition: TitleTest.php:381
Title\newFromDBkey
static newFromDBkey( $key)
Create a new Title from a prefixed DB key.
Definition: Title.php:152
TitleTest\testGetBaseText
testGetBaseText( $title, $expected, $msg='')
@dataProvider provideBaseTitleCases @covers Title::getBaseText
Definition: TitleTest.php:464
TitleTest\testNewFromTitleValue
testNewFromTitleValue(TitleValue $value)
@dataProvider provideNewFromTitleValue
Definition: TitleTest.php:532
TitleTest\testGetTitleValue
testGetTitleValue( $text)
@dataProvider provideGetTitleValue
Definition: TitleTest.php:552
TitleTest\provideNewFromTitleValue
provideNewFromTitleValue()
Definition: TitleTest.php:521
Title
Represents a title within MediaWiki.
Definition: Title.php:35
$wgLang
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 $wgLang
Definition: design.txt:56
TitleTest\provideRootTitleCases
static provideRootTitleCases()
Definition: TitleTest.php:492
TitleTest\testGetRootText
testGetRootText( $title, $expected, $msg='')
@dataProvider provideRootTitleCases @covers Title::getRootText
Definition: TitleTest.php:484
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
NS_USER
const NS_USER
Definition: Defines.php:81
$source
if(PHP_SAPI !='cli') $source
Definition: mwdoc-filter.php:18
TitleTest\testBug31100FixSpecialName
testBug31100FixSpecialName( $text, $expectedParam)
@dataProvider provideBug31100 @covers Title::fixSpecialName
Definition: TitleTest.php:223
TitleTest\provideGetTitleValue
provideGetTitleValue()
Definition: TitleTest.php:541
Language\factory
static factory( $code)
Get a cached or new language object for a given language code.
Definition: Language.php:184
TitleTest\testWgWhitelistReadRegexp
testWgWhitelistReadRegexp( $whitelistRegexp, $source, $action, $expected)
Auth-less test of Title::userCan.
Definition: TitleTest.php:288
Title\legalChars
static legalChars()
Get a regex character class describing the legal characters in a link.
Definition: Title.php:529
$error
usually copyright or history_copyright This message must be in HTML not wikitext $subpages will be ignored and the rest of subPageSubtitle() will run. 'SkinTemplateBuildNavUrlsNav_urlsAfterPermalink' whether MediaWiki currently thinks this is a CSS JS page Hooks may change this value to override the return value of Title::isCssOrJsPage(). 'TitleIsAlwaysKnown' whether MediaWiki currently thinks this page is known isMovable() always returns false. $title whether MediaWiki currently thinks this page is movable Hooks may change this value to override the return value of Title::isMovable(). 'TitleIsWikitextPage' whether MediaWiki currently thinks this is a wikitext page Hooks may change this value to override the return value of Title::isWikitextPage() 'TitleMove' use UploadVerification and UploadVerifyFile instead where the first element is the message key and the remaining elements are used as parameters to the message based on mime etc Preferred in most cases over UploadVerification object with all info about the upload string as detected by MediaWiki Handlers will typically only apply for specific mime types object & $error
Definition: hooks.txt:2573
message
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 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:1624
TitleTest\setUp
setUp()
Definition: TitleTest.php:10
TitleValue
Represents a page (or page fragment) title within MediaWiki.
Definition: TitleValue.php:36