MediaWiki  master
ContentHandlerTest.php
Go to the documentation of this file.
1 <?php
2 
5 
11 
12  protected function setUp() {
13  parent::setUp();
14 
15  $this->setMwGlobals( [
16  'wgExtraNamespaces' => [
17  12312 => 'Dummy',
18  12313 => 'Dummy_talk',
19  ],
20  // The below tests assume that namespaces not mentioned here (Help, User, MediaWiki, ..)
21  // default to CONTENT_MODEL_WIKITEXT.
22  'wgNamespaceContentModels' => [
23  12312 => 'testing',
24  ],
25  'wgContentHandlers' => [
32  'testing-callbacks' => function ( $modelId ) {
33  return new DummyContentHandlerForTesting( $modelId );
34  }
35  ],
36  ] );
37 
38  // Reset LinkCache
39  MediaWikiServices::getInstance()->resetServiceForTesting( 'LinkCache' );
40  }
41 
42  protected function tearDown() {
43  // Reset LinkCache
44  MediaWikiServices::getInstance()->resetServiceForTesting( 'LinkCache' );
45 
46  parent::tearDown();
47  }
48 
49  public function addDBDataOnce() {
50  $this->insertPage( 'Not_Main_Page', 'This is not a main page' );
51  $this->insertPage( 'Smithee', 'A smithee is one who smiths. See also [[Alan Smithee]]' );
52  }
53 
54  public static function dataGetDefaultModelFor() {
55  return [
56  [ 'Help:Foo', CONTENT_MODEL_WIKITEXT ],
57  [ 'Help:Foo.js', CONTENT_MODEL_WIKITEXT ],
58  [ 'Help:Foo.css', CONTENT_MODEL_WIKITEXT ],
59  [ 'Help:Foo.json', CONTENT_MODEL_WIKITEXT ],
60  [ 'Help:Foo/bar.js', CONTENT_MODEL_WIKITEXT ],
61  [ 'User:Foo', CONTENT_MODEL_WIKITEXT ],
62  [ 'User:Foo.js', CONTENT_MODEL_WIKITEXT ],
63  [ 'User:Foo.css', CONTENT_MODEL_WIKITEXT ],
64  [ 'User:Foo.json', CONTENT_MODEL_WIKITEXT ],
65  [ 'User:Foo/bar.js', CONTENT_MODEL_JAVASCRIPT ],
66  [ 'User:Foo/bar.css', CONTENT_MODEL_CSS ],
67  [ 'User:Foo/bar.json', CONTENT_MODEL_JSON ],
68  [ 'User:Foo/bar.json.nope', CONTENT_MODEL_WIKITEXT ],
69  [ 'User talk:Foo/bar.css', CONTENT_MODEL_WIKITEXT ],
70  [ 'User:Foo/bar.js.xxx', CONTENT_MODEL_WIKITEXT ],
71  [ 'User:Foo/bar.xxx', CONTENT_MODEL_WIKITEXT ],
72  [ 'MediaWiki:Foo.js', CONTENT_MODEL_JAVASCRIPT ],
73  [ 'MediaWiki:Foo.JS', CONTENT_MODEL_WIKITEXT ],
74  [ 'MediaWiki:Foo.css', CONTENT_MODEL_CSS ],
75  [ 'MediaWiki:Foo.css.xxx', CONTENT_MODEL_WIKITEXT ],
76  [ 'MediaWiki:Foo.CSS', CONTENT_MODEL_WIKITEXT ],
77  [ 'MediaWiki:Foo.json', CONTENT_MODEL_JSON ],
78  [ 'MediaWiki:Foo.JSON', CONTENT_MODEL_WIKITEXT ],
79  ];
80  }
81 
86  public function testGetDefaultModelFor( $title, $expectedModelId ) {
88  $this->assertEquals( $expectedModelId, ContentHandler::getDefaultModelFor( $title ) );
89  }
90 
95  public function testGetForTitle( $title, $expectedContentModel ) {
97  MediaWikiServices::getInstance()->getLinkCache()->addBadLinkObj( $title );
99  $this->assertEquals( $expectedContentModel, $handler->getModelID() );
100  }
101 
102  public static function dataGetLocalizedName() {
103  return [
104  [ null, null ],
105  [ "xyzzy", null ],
106 
107  // XXX: depends on content language
108  [ CONTENT_MODEL_JAVASCRIPT, '/javascript/i' ],
109  ];
110  }
111 
116  public function testGetLocalizedName( $id, $expected ) {
118 
119  if ( $expected ) {
120  $this->assertNotNull( $name, "no name found for content model $id" );
121  $this->assertTrue( preg_match( $expected, $name ) > 0,
122  "content model name for #$id did not match pattern $expected"
123  );
124  } else {
125  $this->assertEquals( $id, $name, "localization of unknown model $id should have "
126  . "fallen back to use the model id directly."
127  );
128  }
129  }
130 
131  public static function dataGetPageLanguage() {
132  global $wgLanguageCode;
133 
134  return [
135  [ "Main", $wgLanguageCode ],
136  [ "Dummy:Foo", $wgLanguageCode ],
137  [ "MediaWiki:common.js", 'en' ],
138  [ "User:Foo/common.js", 'en' ],
139  [ "MediaWiki:common.css", 'en' ],
140  [ "User:Foo/common.css", 'en' ],
141  [ "User:Foo", $wgLanguageCode ],
142 
143  [ CONTENT_MODEL_JAVASCRIPT, 'javascript' ],
144  ];
145  }
146 
151  public function testGetPageLanguage( $title, $expected ) {
152  if ( is_string( $title ) ) {
154  MediaWikiServices::getInstance()->getLinkCache()->addBadLinkObj( $title );
155  }
156 
157  $expected = wfGetLangObj( $expected );
158 
160  $lang = $handler->getPageLanguage( $title );
161 
162  $this->assertInstanceOf( Language::class, $lang );
163  $this->assertEquals( $expected->getCode(), $lang->getCode() );
164  }
165 
166  public static function dataGetContentText_Null() {
167  return [
168  [ 'fail' ],
169  [ 'serialize' ],
170  [ 'ignore' ],
171  ];
172  }
173 
178  public function testGetContentText_Null( $contentHandlerTextFallback ) {
179  $this->setMwGlobals( 'wgContentHandlerTextFallback', $contentHandlerTextFallback );
180 
181  $content = null;
182 
184  $this->assertEquals( '', $text );
185  }
186 
187  public static function dataGetContentText_TextContent() {
188  return [
189  [ 'fail' ],
190  [ 'serialize' ],
191  [ 'ignore' ],
192  ];
193  }
194 
199  public function testGetContentText_TextContent( $contentHandlerTextFallback ) {
200  $this->setMwGlobals( 'wgContentHandlerTextFallback', $contentHandlerTextFallback );
201 
202  $content = new WikitextContent( "hello world" );
203 
205  $this->assertEquals( $content->getText(), $text );
206  }
207 
214  $this->setMwGlobals( 'wgContentHandlerTextFallback', 'fail' );
215 
216  $content = new DummyContentForTesting( "hello world" );
217 
219  }
220 
225  $this->setMwGlobals( 'wgContentHandlerTextFallback', 'serialize' );
226 
227  $content = new DummyContentForTesting( "hello world" );
228 
230  $this->assertEquals( $content->serialize(), $text );
231  }
232 
237  $this->setMwGlobals( 'wgContentHandlerTextFallback', 'ignore' );
238 
239  $content = new DummyContentForTesting( "hello world" );
240 
242  $this->assertNull( $text );
243  }
244 
245  public static function dataMakeContent() {
246  return [
247  [ 'hallo', 'Help:Test', null, null, CONTENT_MODEL_WIKITEXT, false ],
248  [ 'hallo', 'MediaWiki:Test.js', null, null, CONTENT_MODEL_JAVASCRIPT, false ],
249  [ serialize( 'hallo' ), 'Dummy:Test', null, null, "testing", false ],
250 
251  [
252  'hallo',
253  'Help:Test',
254  null,
257  false
258  ],
259  [
260  'hallo',
261  'MediaWiki:Test.js',
262  null,
265  false
266  ],
267  [ serialize( 'hallo' ), 'Dummy:Test', null, "testing", "testing", false ],
268 
269  [ 'hallo', 'Help:Test', CONTENT_MODEL_CSS, null, CONTENT_MODEL_CSS, false ],
270  [
271  'hallo',
272  'MediaWiki:Test.js',
274  null,
276  false
277  ],
278  [
279  serialize( 'hallo' ),
280  'Dummy:Test',
282  null,
284  false
285  ],
286 
287  [ 'hallo', 'Help:Test', CONTENT_MODEL_WIKITEXT, "testing", null, true ],
288  [ 'hallo', 'MediaWiki:Test.js', CONTENT_MODEL_CSS, "testing", null, true ],
289  [ 'hallo', 'Dummy:Test', CONTENT_MODEL_JAVASCRIPT, "testing", null, true ],
290  ];
291  }
292 
297  public function testMakeContent( $data, $title, $modelId, $format,
298  $expectedModelId, $shouldFail
299  ) {
301  MediaWikiServices::getInstance()->getLinkCache()->addBadLinkObj( $title );
302  try {
303  $content = ContentHandler::makeContent( $data, $title, $modelId, $format );
304 
305  if ( $shouldFail ) {
306  $this->fail( "ContentHandler::makeContent should have failed!" );
307  }
308 
309  $this->assertEquals( $expectedModelId, $content->getModel(), 'bad model id' );
310  $this->assertEquals( $data, $content->serialize(), 'bad serialized data' );
311  } catch ( MWException $ex ) {
312  if ( !$shouldFail ) {
313  $this->fail( "ContentHandler::makeContent failed unexpectedly: " . $ex->getMessage() );
314  } else {
315  // dummy, so we don't get the "test did not perform any assertions" message.
316  $this->assertTrue( true );
317  }
318  }
319  }
320 
327  public function testGetAutosummary() {
328  $this->setContentLang( 'en' );
329 
331  $title = Title::newFromText( 'Help:Test' );
332  // Create a new content object with no content
334  // first check, if we become a blank page created summary with the right bitmask
335  $autoSummary = $content->getAutosummary( null, $newContent, 97 );
336  $this->assertEquals( $autoSummary,
337  wfMessage( 'autosumm-newblank' )->inContentLanguage()->text() );
338  // now check, what we become with another bitmask
339  $autoSummary = $content->getAutosummary( null, $newContent, 92 );
340  $this->assertEquals( $autoSummary, '' );
341  }
342 
347  public function testGetChangeTag() {
348  $this->setMwGlobals( 'wgSoftwareTags', [ 'mw-contentmodelchange' => true ] );
349  $wikitextContentHandler = new DummyContentHandlerForTesting( CONTENT_MODEL_WIKITEXT );
350  // Create old content object with javascript content model
352  // Create new content object with wikitext content model
354  // Get the tag for this edit
355  $tag = $wikitextContentHandler->getChangeTag( $oldContent, $newContent, EDIT_UPDATE );
356  $this->assertSame( $tag, 'mw-contentmodelchange' );
357  }
358 
362  public function testSupportsCategories() {
364  $this->assertTrue( $handler->supportsCategories(), 'content model supports categories' );
365  }
366 
370  public function testSupportsDirectEditing() {
372  $this->assertFalse( $handler->supportsDirectEditing(), 'direct editing is not supported' );
373  }
374 
375  public static function dummyHookHandler( $foo, &$text, $bar ) {
376  if ( $text === null || $text === false ) {
377  return false;
378  }
379 
380  $text = strtoupper( $text );
381 
382  return true;
383  }
384 
385  public function provideGetModelForID() {
386  return [
393  [ 'testing-callbacks', DummyContentHandlerForTesting::class ],
394  ];
395  }
396 
401  public function testGetModelForID( $modelId, $handlerClass ) {
403 
404  $this->assertInstanceOf( $handlerClass, $handler );
405  }
406 
410  public function testGetFieldsForSearchIndex() {
411  $searchEngine = $this->newSearchEngine();
412 
414 
415  $fields = $handler->getFieldsForSearchIndex( $searchEngine );
416 
417  $this->assertArrayHasKey( 'category', $fields );
418  $this->assertArrayHasKey( 'external_link', $fields );
419  $this->assertArrayHasKey( 'outgoing_link', $fields );
420  $this->assertArrayHasKey( 'template', $fields );
421  $this->assertArrayHasKey( 'content_model', $fields );
422  }
423 
424  private function newSearchEngine() {
425  $searchEngine = $this->getMockBuilder( SearchEngine::class )
426  ->getMock();
427 
428  $searchEngine->expects( $this->any() )
429  ->method( 'makeSearchFieldMapping' )
430  ->will( $this->returnCallback( function ( $name, $type ) {
432  } ) );
433 
434  return $searchEngine;
435  }
436 
440  public function testDataIndexFields() {
441  $mockEngine = $this->createMock( SearchEngine::class );
442  $title = Title::newFromText( 'Not_Main_Page', NS_MAIN );
443  $page = new WikiPage( $title );
444 
445  $this->setTemporaryHook( 'SearchDataForIndex',
446  function (
447  &$fields,
449  WikiPage $page,
452  ) {
453  $fields['testDataField'] = 'test content';
454  } );
455 
456  $output = $page->getContent()->getParserOutput( $title );
457  $data = $page->getContentHandler()->getDataForSearchIndex( $page, $output, $mockEngine );
458  $this->assertArrayHasKey( 'text', $data );
459  $this->assertArrayHasKey( 'text_bytes', $data );
460  $this->assertArrayHasKey( 'language', $data );
461  $this->assertArrayHasKey( 'testDataField', $data );
462  $this->assertEquals( 'test content', $data['testDataField'] );
463  $this->assertEquals( 'wikitext', $data['content_model'] );
464  }
465 
469  public function testParserOutputForIndexing() {
470  $title = Title::newFromText( 'Smithee', NS_MAIN );
471  $page = new WikiPage( $title );
472 
473  $out = $page->getContentHandler()->getParserOutputForIndexing( $page );
474  $this->assertInstanceOf( ParserOutput::class, $out );
475  $this->assertContains( 'one who smiths', $out->getRawText() );
476  }
477 
481  public function testGetContentModelsHook() {
482  $this->setTemporaryHook( 'GetContentModels', function ( &$models ) {
483  $models[] = 'Ferrari';
484  } );
485  $this->assertContains( 'Ferrari', ContentHandler::getContentModels() );
486  }
487 
492  $this->mergeMwGlobalArrayValue( 'wgHooks', [
493  'GetSlotDiffRenderer' => [],
494  ] );
495 
496  // test default renderer
497  $contentHandler = new WikitextContentHandler( CONTENT_MODEL_WIKITEXT );
498  $slotDiffRenderer = $contentHandler->getSlotDiffRenderer( RequestContext::getMain() );
499  $this->assertInstanceOf( TextSlotDiffRenderer::class, $slotDiffRenderer );
500  }
501 
505  public function testGetSlotDiffRenderer_bc() {
506  $this->mergeMwGlobalArrayValue( 'wgHooks', [
507  'GetSlotDiffRenderer' => [],
508  ] );
509 
510  // test B/C renderer
511  $customDifferenceEngine = $this->getMockBuilder( DifferenceEngine::class )
512  ->disableOriginalConstructor()
513  ->getMock();
514  // hack to track object identity across cloning
515  $customDifferenceEngine->objectId = 12345;
516  $customContentHandler = $this->getMockBuilder( ContentHandler::class )
517  ->setConstructorArgs( [ 'foo', [] ] )
518  ->setMethods( [ 'createDifferenceEngine' ] )
519  ->getMockForAbstractClass();
520  $customContentHandler->expects( $this->any() )
521  ->method( 'createDifferenceEngine' )
522  ->willReturn( $customDifferenceEngine );
524  $slotDiffRenderer = $customContentHandler->getSlotDiffRenderer( RequestContext::getMain() );
525  $this->assertInstanceOf( DifferenceEngineSlotDiffRenderer::class, $slotDiffRenderer );
526  $this->assertSame(
527  $customDifferenceEngine->objectId,
528  TestingAccessWrapper::newFromObject( $slotDiffRenderer )->differenceEngine->objectId
529  );
530  }
531 
535  public function testGetSlotDiffRenderer_nobc() {
536  $this->mergeMwGlobalArrayValue( 'wgHooks', [
537  'GetSlotDiffRenderer' => [],
538  ] );
539 
540  // test that B/C renderer does not get used when getSlotDiffRendererInternal is overridden
541  $customDifferenceEngine = $this->getMockBuilder( DifferenceEngine::class )
542  ->disableOriginalConstructor()
543  ->getMock();
544  $customSlotDiffRenderer = $this->getMockBuilder( SlotDiffRenderer::class )
545  ->disableOriginalConstructor()
546  ->getMockForAbstractClass();
547  $customContentHandler2 = $this->getMockBuilder( ContentHandler::class )
548  ->setConstructorArgs( [ 'bar', [] ] )
549  ->setMethods( [ 'createDifferenceEngine', 'getSlotDiffRendererInternal' ] )
550  ->getMockForAbstractClass();
551  $customContentHandler2->expects( $this->any() )
552  ->method( 'createDifferenceEngine' )
553  ->willReturn( $customDifferenceEngine );
554  $customContentHandler2->expects( $this->any() )
555  ->method( 'getSlotDiffRendererInternal' )
556  ->willReturn( $customSlotDiffRenderer );
558  $slotDiffRenderer = $customContentHandler2->getSlotDiffRenderer( RequestContext::getMain() );
559  $this->assertSame( $customSlotDiffRenderer, $slotDiffRenderer );
560  }
561 
565  public function testGetSlotDiffRenderer_hook() {
566  $this->mergeMwGlobalArrayValue( 'wgHooks', [
567  'GetSlotDiffRenderer' => [],
568  ] );
569 
570  // test that the hook handler takes precedence
571  $customDifferenceEngine = $this->getMockBuilder( DifferenceEngine::class )
572  ->disableOriginalConstructor()
573  ->getMock();
574  $customContentHandler = $this->getMockBuilder( ContentHandler::class )
575  ->setConstructorArgs( [ 'foo', [] ] )
576  ->setMethods( [ 'createDifferenceEngine' ] )
577  ->getMockForAbstractClass();
578  $customContentHandler->expects( $this->any() )
579  ->method( 'createDifferenceEngine' )
580  ->willReturn( $customDifferenceEngine );
583  $customSlotDiffRenderer = $this->getMockBuilder( SlotDiffRenderer::class )
584  ->disableOriginalConstructor()
585  ->getMockForAbstractClass();
586  $customContentHandler2 = $this->getMockBuilder( ContentHandler::class )
587  ->setConstructorArgs( [ 'bar', [] ] )
588  ->setMethods( [ 'createDifferenceEngine', 'getSlotDiffRendererInternal' ] )
589  ->getMockForAbstractClass();
590  $customContentHandler2->expects( $this->any() )
591  ->method( 'createDifferenceEngine' )
592  ->willReturn( $customDifferenceEngine );
593  $customContentHandler2->expects( $this->any() )
594  ->method( 'getSlotDiffRendererInternal' )
595  ->willReturn( $customSlotDiffRenderer );
598  $customSlotDiffRenderer2 = $this->getMockBuilder( SlotDiffRenderer::class )
599  ->disableOriginalConstructor()
600  ->getMockForAbstractClass();
601  $this->setTemporaryHook( 'GetSlotDiffRenderer',
602  function ( $handler, &$slotDiffRenderer ) use ( $customSlotDiffRenderer2 ) {
603  $slotDiffRenderer = $customSlotDiffRenderer2;
604  } );
605 
606  $slotDiffRenderer = $customContentHandler->getSlotDiffRenderer( RequestContext::getMain() );
607  $this->assertSame( $customSlotDiffRenderer2, $slotDiffRenderer );
608  $slotDiffRenderer = $customContentHandler2->getSlotDiffRenderer( RequestContext::getMain() );
609  $this->assertSame( $customSlotDiffRenderer2, $slotDiffRenderer );
610  }
611 
612 }
testGetDefaultModelFor( $title, $expectedModelId)
dataGetDefaultModelFor ContentHandler::getDefaultModelFor
Dummy implementation of SearchIndexFieldDefinition for testing purposes.
const CONTENT_MODEL_WIKITEXT
Definition: Defines.php:215
testGetContentText_NonTextContent_fail()
ContentHandler::getContentText should have thrown an exception for non-text Content object MWExceptio...
testGetSlotDiffRenderer_hook()
ContentHandler::getSlotDiffRenderer.
testGetLocalizedName( $id, $expected)
dataGetLocalizedName ContentHandler::getLocalizedName
const NS_MAIN
Definition: Defines.php:60
testGetModelForID( $modelId, $handlerClass)
ContentHandler::getForModelID provideGetModelForID.
processing should stop and the error should be shown to the user * false
Definition: hooks.txt:187
serialize()
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
testSupportsDirectEditing()
ContentHandler::supportsDirectEditing.
if(!isset( $args[0])) $lang
static getContentModels()
static getDefaultModelFor(Title $title)
Returns the name of the default content model to be used for the page with the given title...
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency MediaWikiServices
Definition: injection.txt:23
testGetSlotDiffRenderer_default()
ContentHandler::getSlotDiffRenderer.
const CONTENT_MODEL_TEXT
Definition: Defines.php:218
const EDIT_UPDATE
Definition: Defines.php:133
static getLocalizedName( $name, Language $lang=null)
Returns the localized name for a given content model.
const CONTENT_MODEL_JSON
Definition: Defines.php:219
This list may contain false positives That usually means there is additional text with links below the first Each row contains links to the first and second as well as the first line of the second redirect text
testGetChangeTag()
Test software tag that is added when content model of the page changes ContentHandler::getChangeTag.
testGetAutosummary()
ContentHandler::getAutosummary.
wfGetLangObj( $langcode=false)
Return a Language object from $langcode.
static configuration should be added through ResourceLoaderGetConfigVars instead can be used to get the real title e g db for database replication lag or jobqueue for job queue size converted to pseudo seconds It is possible to add more fields and they will be returned to the user in the API response after the basic globals have been set but before ordinary actions take place $output
Definition: hooks.txt:2205
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that When $user is not it can be in the form of< username >< more info > e g for bot passwords intended to be added to log contexts Fields it might only if the login was with a bot password it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping see BaseTemplate::getToolbox and BaseTemplate::makeListItem for details on the format of individual items inside of this array or by returning and letting standard HTTP rendering take place modifiable or by returning false and taking over the output modifiable modifiable after all normalizations have been except for the $wgMaxImageArea check set to true or false to override the $wgMaxImageArea check result gives extension the possibility to transform it themselves $handler
Definition: hooks.txt:767
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that When $user is not it can be in the form of< username >< more info > e g for bot passwords intended to be added to log contexts Fields it might only if the login was with a bot password it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping see BaseTemplate::getToolbox and BaseTemplate::makeListItem for details on the format of individual items inside of this array or by returning and letting standard HTTP rendering take place modifiable or by returning false and taking over the output $out
Definition: hooks.txt:767
testDataIndexFields()
ContentHandler::getDataForSearchIndex.
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return true
Definition: hooks.txt:1972
$wgLanguageCode
Site language code.
testGetForTitle( $title, $expectedContentModel)
dataGetDefaultModelFor ContentHandler::getForTitle
testGetSlotDiffRenderer_bc()
ContentHandler::getSlotDiffRenderer.
either a unescaped string or a HtmlArmor object after in associative array form externallinks including delete and has completed for all link tables whether this was an auto creation use $formDescriptor instead default is conds Array Extra conditions for the No matching items in log is displayed if loglist is empty msgKey Array If you want a nice box with a set this to the key of the message First element is the message additional optional elements are parameters for the key that are processed with wfMessage() -> params() ->parseAsBlock() - offset Set to overwrite offset parameter in $wgRequest set to '' to unset offset - wrap String Wrap the message in html(usually something like "&lt
static getMain()
Get the RequestContext object associated with the main request.
static dummyHookHandler( $foo, &$text, $bar)
static getForModelID( $modelId)
Returns the ContentHandler singleton for the given model ID.
static getContentText(Content $content=null)
Convenience function for getting flat text from a Content object.
testMakeContent( $data, $title, $modelId, $format, $expectedModelId, $shouldFail)
dataMakeContent ContentHandler::makeContent
testGetContentModelsHook()
ContentHandler::getContentModels.
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that When $user is not null
Definition: hooks.txt:767
namespace and then decline to actually register it file or subcat img or subcat $title
Definition: hooks.txt:912
testGetPageLanguage( $title, $expected)
dataGetPageLanguage ContentHandler::getPageLanguage
static getForTitle(Title $title)
Returns the appropriate ContentHandler singleton for the given title.
testGetSlotDiffRenderer_nobc()
ContentHandler::getSlotDiffRenderer.
getContentHandler()
Returns the ContentHandler instance to be used to deal with the content of this WikiPage.
Definition: WikiPage.php:286
testSupportsCategories()
ContentHandler::supportsCategories.
testGetFieldsForSearchIndex()
ContentHandler::getFieldsForSearchIndex.
the value to return A Title object or null for latest all implement SearchIndexField $engine
Definition: hooks.txt:2886
CONTENT_MODEL_JAVASCRIPT
Allow users to upload files.
ContentHandler Database.
testParserOutputForIndexing()
ContentHandler::getParserOutputForIndexing.
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
testGetContentText_Null( $contentHandlerTextFallback)
dataGetContentText_Null ContentHandler::getContentText
you have access to all of the normal MediaWiki so you can get a DB use the etc For full docs on the Maintenance class
Definition: maintenance.txt:52
static dataGetContentText_TextContent()
Content handler for wiki text pages.
getContent( $audience=RevisionRecord::FOR_PUBLIC, User $user=null)
Get the content of the current revision.
Definition: WikiPage.php:816
const CONTENT_MODEL_CSS
Definition: Defines.php:217
const CONTENT_FORMAT_JAVASCRIPT
Definition: Defines.php:232
Allows to change the fields on the form that will be generated $name
Definition: hooks.txt:271
const CONTENT_FORMAT_WIKITEXT
Definition: Defines.php:230
testGetContentText_NonTextContent_serialize()
ContentHandler::getContentText.
static makeContent( $text, Title $title=null, $modelId=null, $format=null)
Convenience function for creating a Content object from a given textual representation.
$content
Definition: pageupdater.txt:72
testGetContentText_NonTextContent_ignore()
ContentHandler::getContentText.
testGetContentText_TextContent( $contentHandlerTextFallback)
dataGetContentText_TextContent ContentHandler::getContentText
static newFromText( $text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
Definition: Title.php:322