MediaWiki REL1_31
ApiFormatBaseTest.php
Go to the documentation of this file.
1<?php
2
3use Wikimedia\TestingAccessWrapper;
4
10
11 protected $printerName = 'mockbase';
12
13 public function getMockFormatter( ApiMain $main = null, $format, $methods = [] ) {
14 if ( $main === null ) {
16 $context->setRequest( new FauxRequest( [], true ) );
17 $main = new ApiMain( $context );
18 }
19
20 $mock = $this->getMockBuilder( ApiFormatBase::class )
21 ->setConstructorArgs( [ $main, $format ] )
22 ->setMethods( array_unique( array_merge( $methods, [ 'getMimeType', 'execute' ] ) ) )
23 ->getMock();
24 if ( !in_array( 'getMimeType', $methods, true ) ) {
25 $mock->method( 'getMimeType' )->willReturn( 'text/x-mock' );
26 }
27 return $mock;
28 }
29
30 protected function encodeData( array $params, array $data, $options = [] ) {
31 $options += [
32 'name' => 'mock',
33 'class' => ApiFormatBase::class,
34 'factory' => function ( ApiMain $main, $format ) use ( $options ) {
35 $mock = $this->getMockFormatter( $main, $format );
36 $mock->expects( $this->once() )->method( 'execute' )
37 ->willReturnCallback( function () use ( $mock ) {
38 $mock->printText( "Format {$mock->getFormat()}: " );
39 $mock->printText( "<b>ok</b>" );
40 } );
41
42 if ( isset( $options['status'] ) ) {
43 $mock->setHttpStatus( $options['status'] );
44 }
45
46 return $mock;
47 },
48 'returnPrinter' => true,
49 ];
50
51 $this->setMwGlobals( [
52 'wgApiFrameOptions' => 'DENY',
53 ] );
54
55 $ret = parent::encodeData( $params, $data, $options );
56 $printer = TestingAccessWrapper::newFromObject( $ret['printer'] );
57 $text = $ret['text'];
58
59 if ( $options['name'] !== 'mockfm' ) {
60 $ct = 'text/x-mock';
61 $file = 'api-result.mock';
62 $status = isset( $options['status'] ) ? $options['status'] : null;
63 } elseif ( isset( $params['wrappedhtml'] ) ) {
64 $ct = 'text/mediawiki-api-prettyprint-wrapped';
65 $file = 'api-result-wrapped.json';
66 $status = null;
67
68 // Replace varying field
69 $text = preg_replace( '/"time":\d+/', '"time":1234', $text );
70 } else {
71 $ct = 'text/html';
72 $file = 'api-result.html';
73 $status = null;
74
75 // Strip OutputPage-generated HTML
76 if ( preg_match( '!<pre class="api-pretty-content">.*</pre>!s', $text, $m ) ) {
77 $text = $m[0];
78 }
79 }
80
81 $response = $printer->getMain()->getRequest()->response();
82 $this->assertSame( "$ct; charset=utf-8", strtolower( $response->getHeader( 'Content-Type' ) ) );
83 $this->assertSame( 'DENY', $response->getHeader( 'X-Frame-Options' ) );
84 $this->assertSame( $file, $printer->getFilename() );
85 $this->assertSame( "inline; filename=$file", $response->getHeader( 'Content-Disposition' ) );
86 $this->assertSame( $status, $response->getStatusCode() );
87
88 return $text;
89 }
90
91 public static function provideGeneralEncoding() {
92 return [
93 'normal' => [
94 [],
95 "Format MOCK: <b>ok</b>",
96 [],
97 [ 'name' => 'mock' ]
98 ],
99 'normal ignores wrappedhtml' => [
100 [],
101 "Format MOCK: <b>ok</b>",
102 [ 'wrappedhtml' => 1 ],
103 [ 'name' => 'mock' ]
104 ],
105 'HTML format' => [
106 [],
107 '<pre class="api-pretty-content">Format MOCK: &lt;b>ok&lt;/b></pre>',
108 [],
109 [ 'name' => 'mockfm' ]
110 ],
111 'wrapped HTML format' => [
112 [],
113 // phpcs:ignore Generic.Files.LineLength.TooLong
114 '{"status":200,"statustext":"OK","html":"<pre class=\"api-pretty-content\">Format MOCK: &lt;b>ok&lt;/b></pre>","modules":["mediawiki.apipretty"],"continue":null,"time":1234}',
115 [ 'wrappedhtml' => 1 ],
116 [ 'name' => 'mockfm' ]
117 ],
118 'normal, with set status' => [
119 [],
120 "Format MOCK: <b>ok</b>",
121 [],
122 [ 'name' => 'mock', 'status' => 400 ]
123 ],
124 'HTML format, with set status' => [
125 [],
126 '<pre class="api-pretty-content">Format MOCK: &lt;b>ok&lt;/b></pre>',
127 [],
128 [ 'name' => 'mockfm', 'status' => 400 ]
129 ],
130 'wrapped HTML format, with set status' => [
131 [],
132 // phpcs:ignore Generic.Files.LineLength.TooLong
133 '{"status":400,"statustext":"Bad Request","html":"<pre class=\"api-pretty-content\">Format MOCK: &lt;b>ok&lt;/b></pre>","modules":["mediawiki.apipretty"],"continue":null,"time":1234}',
134 [ 'wrappedhtml' => 1 ],
135 [ 'name' => 'mockfm', 'status' => 400 ]
136 ],
137 'wrapped HTML format, cross-domain-policy' => [
138 [ 'continue' => '< CrOsS-DoMaIn-PoLiCy >' ],
139 // phpcs:ignore Generic.Files.LineLength.TooLong
140 '{"status":200,"statustext":"OK","html":"<pre class=\"api-pretty-content\">Format MOCK: &lt;b>ok&lt;/b></pre>","modules":["mediawiki.apipretty"],"continue":"\u003C CrOsS-DoMaIn-PoLiCy \u003E","time":1234}',
141 [ 'wrappedhtml' => 1 ],
142 [ 'name' => 'mockfm' ]
143 ],
144 ];
145 }
146
150 public function testFilenameEncoding( $filename, $expect ) {
151 $ret = parent::encodeData( [], [], [
152 'name' => 'mock',
153 'class' => ApiFormatBase::class,
154 'factory' => function ( ApiMain $main, $format ) use ( $filename ) {
155 $mock = $this->getMockFormatter( $main, $format, [ 'getFilename' ] );
156 $mock->method( 'getFilename' )->willReturn( $filename );
157 return $mock;
158 },
159 'returnPrinter' => true,
160 ] );
161 $response = $ret['printer']->getMain()->getRequest()->response();
162
163 $this->assertSame( "inline; $expect", $response->getHeader( 'Content-Disposition' ) );
164 }
165
166 public static function provideFilenameEncoding() {
167 return [
168 'something simple' => [
169 'foo.xyz', 'filename=foo.xyz'
170 ],
171 'more complicated, but still simple' => [
172 'foo.!#$%&\'*+-^_`|~', 'filename=foo.!#$%&\'*+-^_`|~'
173 ],
174 'Needs quoting' => [
175 'foo\\bar.xyz', 'filename="foo\\\\bar.xyz"'
176 ],
177 'Needs quoting (2)' => [
178 'foo (bar).xyz', 'filename="foo (bar).xyz"'
179 ],
180 'Needs quoting (3)' => [
181 "foo\t\"b\x5car\"\0.xyz", "filename=\"foo\x5c\t\x5c\"b\x5c\x5car\x5c\"\x5c\0.xyz\""
182 ],
183 'Non-ASCII characters' => [
184 'fóo bár.🙌!',
185 "filename=\"f\xF3o b\xE1r.?!\"; filename*=UTF-8''f%C3%B3o%20b%C3%A1r.%F0%9F%99%8C!"
186 ]
187 ];
188 }
189
190 public function testBasics() {
191 $printer = $this->getMockFormatter( null, 'mock' );
192 $this->assertTrue( $printer->canPrintErrors() );
193 $this->assertSame(
194 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Data_formats',
195 $printer->getHelpUrls()
196 );
197 }
198
199 public function testDisable() {
200 $this->setMwGlobals( [
201 'wgApiFrameOptions' => 'DENY',
202 ] );
203
204 $printer = $this->getMockFormatter( null, 'mock' );
205 $printer->method( 'execute' )->willReturnCallback( function () use ( $printer ) {
206 $printer->printText( 'Foo' );
207 } );
208 $this->assertFalse( $printer->isDisabled() );
209 $printer->disable();
210 $this->assertTrue( $printer->isDisabled() );
211
212 $printer->setHttpStatus( 400 );
213 $printer->initPrinter();
214 $printer->execute();
215 ob_start();
216 $printer->closePrinter();
217 $this->assertSame( '', ob_get_clean() );
218 $response = $printer->getMain()->getRequest()->response();
219 $this->assertNull( $response->getHeader( 'Content-Type' ) );
220 $this->assertNull( $response->getHeader( 'X-Frame-Options' ) );
221 $this->assertNull( $response->getHeader( 'Content-Disposition' ) );
222 $this->assertNull( $response->getStatusCode() );
223 }
224
225 public function testNullMimeType() {
226 $this->setMwGlobals( [
227 'wgApiFrameOptions' => 'DENY',
228 ] );
229
230 $printer = $this->getMockFormatter( null, 'mock', [ 'getMimeType' ] );
231 $printer->method( 'execute' )->willReturnCallback( function () use ( $printer ) {
232 $printer->printText( 'Foo' );
233 } );
234 $printer->method( 'getMimeType' )->willReturn( null );
235 $this->assertNull( $printer->getMimeType(), 'sanity check' );
236
237 $printer->initPrinter();
238 $printer->execute();
239 ob_start();
240 $printer->closePrinter();
241 $this->assertSame( 'Foo', ob_get_clean() );
242 $response = $printer->getMain()->getRequest()->response();
243 $this->assertNull( $response->getHeader( 'Content-Type' ) );
244 $this->assertNull( $response->getHeader( 'X-Frame-Options' ) );
245 $this->assertNull( $response->getHeader( 'Content-Disposition' ) );
246
247 $printer = $this->getMockFormatter( null, 'mockfm', [ 'getMimeType' ] );
248 $printer->method( 'execute' )->willReturnCallback( function () use ( $printer ) {
249 $printer->printText( 'Foo' );
250 } );
251 $printer->method( 'getMimeType' )->willReturn( null );
252 $this->assertNull( $printer->getMimeType(), 'sanity check' );
253 $this->assertTrue( $printer->getIsHtml(), 'sanity check' );
254
255 $printer->initPrinter();
256 $printer->execute();
257 ob_start();
258 $printer->closePrinter();
259 $this->assertSame( 'Foo', ob_get_clean() );
260 $response = $printer->getMain()->getRequest()->response();
261 $this->assertSame(
262 'text/html; charset=utf-8', strtolower( $response->getHeader( 'Content-Type' ) )
263 );
264 $this->assertSame( 'DENY', $response->getHeader( 'X-Frame-Options' ) );
265 $this->assertSame(
266 'inline; filename=api-result.html', $response->getHeader( 'Content-Disposition' )
267 );
268 }
269
270 public function testApiFrameOptions() {
271 $this->setMwGlobals( [ 'wgApiFrameOptions' => 'DENY' ] );
272 $printer = $this->getMockFormatter( null, 'mock' );
273 $printer->initPrinter();
274 $this->assertSame(
275 'DENY',
276 $printer->getMain()->getRequest()->response()->getHeader( 'X-Frame-Options' )
277 );
278
279 $this->setMwGlobals( [ 'wgApiFrameOptions' => 'SAMEORIGIN' ] );
280 $printer = $this->getMockFormatter( null, 'mock' );
281 $printer->initPrinter();
282 $this->assertSame(
283 'SAMEORIGIN',
284 $printer->getMain()->getRequest()->response()->getHeader( 'X-Frame-Options' )
285 );
286
287 $this->setMwGlobals( [ 'wgApiFrameOptions' => false ] );
288 $printer = $this->getMockFormatter( null, 'mock' );
289 $printer->initPrinter();
290 $this->assertNull(
291 $printer->getMain()->getRequest()->response()->getHeader( 'X-Frame-Options' )
292 );
293 }
294
295 public function testForceDefaultParams() {
297 $context->setRequest( new FauxRequest( [ 'foo' => '1', 'bar' => '2', 'baz' => '3' ], true ) );
298 $main = new ApiMain( $context );
299 $allowedParams = [
300 'foo' => [],
301 'bar' => [ ApiBase::PARAM_DFLT => 'bar?' ],
302 'baz' => 'baz!',
303 ];
304
305 $printer = $this->getMockFormatter( $main, 'mock', [ 'getAllowedParams' ] );
306 $printer->method( 'getAllowedParams' )->willReturn( $allowedParams );
307 $this->assertEquals(
308 [ 'foo' => '1', 'bar' => '2', 'baz' => '3' ],
309 $printer->extractRequestParams(),
310 'sanity check'
311 );
312
313 $printer = $this->getMockFormatter( $main, 'mock', [ 'getAllowedParams' ] );
314 $printer->method( 'getAllowedParams' )->willReturn( $allowedParams );
315 $printer->forceDefaultParams();
316 $this->assertEquals(
317 [ 'foo' => null, 'bar' => 'bar?', 'baz' => 'baz!' ],
318 $printer->extractRequestParams()
319 );
320 }
321
322 public function testGetAllowedParams() {
323 $printer = $this->getMockFormatter( null, 'mock' );
324 $this->assertSame( [], $printer->getAllowedParams() );
325
326 $printer = $this->getMockFormatter( null, 'mockfm' );
327 $this->assertSame( [
328 'wrappedhtml' => [
329 ApiBase::PARAM_DFLT => false,
330 ApiBase::PARAM_HELP_MSG => 'apihelp-format-param-wrappedhtml',
331 ]
332 ], $printer->getAllowedParams() );
333 }
334
335 public function testGetExamplesMessages() {
336 $printer = TestingAccessWrapper::newFromObject( $this->getMockFormatter( null, 'mock' ) );
337 $this->assertSame( [
338 'action=query&meta=siteinfo&siprop=namespaces&format=mock'
339 => [ 'apihelp-format-example-generic', 'MOCK' ]
340 ], $printer->getExamplesMessages() );
341
342 $printer = TestingAccessWrapper::newFromObject( $this->getMockFormatter( null, 'mockfm' ) );
343 $this->assertSame( [
344 'action=query&meta=siteinfo&siprop=namespaces&format=mockfm'
345 => [ 'apihelp-format-example-generic', 'MOCK' ]
346 ], $printer->getExamplesMessages() );
347 }
348
352 public function testHtmlHeader( $post, $registerNonHtml, $expect ) {
354 $request = new FauxRequest( [ 'a' => 1, 'b' => 2 ], $post );
355 $request->setRequestURL( 'http://example.org/wx/api.php' );
356 $context->setRequest( $request );
357 $context->setLanguage( 'qqx' );
358 $main = new ApiMain( $context );
359 $printer = $this->getMockFormatter( $main, 'mockfm' );
360 $mm = $printer->getMain()->getModuleManager();
361 $mm->addModule( 'mockfm', 'format', ApiFormatBase::class, function () {
362 return $mock;
363 } );
364 if ( $registerNonHtml ) {
365 $mm->addModule( 'mock', 'format', ApiFormatBase::class, function () {
366 return $mock;
367 } );
368 }
369
370 $printer->initPrinter();
371 $printer->execute();
372 ob_start();
373 $printer->closePrinter();
374 $text = ob_get_clean();
375 $this->assertContains( $expect, $text );
376 }
377
378 public static function provideHtmlHeader() {
379 return [
380 [ false, false, '(api-format-prettyprint-header-only-html: MOCK)' ],
381 [ true, false, '(api-format-prettyprint-header-only-html: MOCK)' ],
382 // phpcs:ignore Generic.Files.LineLength.TooLong
383 [ false, true, '(api-format-prettyprint-header-hyperlinked: MOCK, mock, <a rel="nofollow" class="external free" href="http://example.org/wx/api.php?a=1&amp;b=2&amp;format=mock">http://example.org/wx/api.php?a=1&amp;b=2&amp;format=mock</a>)' ],
384 [ true, true, '(api-format-prettyprint-header: MOCK, mock)' ],
385 ];
386 }
387
388}
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
const PARAM_DFLT
(null|boolean|integer|string) Default value of the parameter.
Definition ApiBase.php:48
const PARAM_HELP_MSG
(string|array|Message) Specify an alternative i18n documentation message for this parameter.
Definition ApiBase.php:124
API ApiFormatBase.
static provideGeneralEncoding()
Return general data to be encoded for testing.
getMockFormatter(ApiMain $main=null, $format, $methods=[])
testFilenameEncoding( $filename, $expect)
provideFilenameEncoding
encodeData(array $params, array $data, $options=[])
Get the formatter output for the given input data.
testHtmlHeader( $post, $registerNonHtml, $expect)
provideHtmlHeader
This is the main API class, used for both external and internal processing.
Definition ApiMain.php:43
WebRequest clone which takes values from a provided array.
setMwGlobals( $pairs, $value=null)
Sets a global, maintaining a stashed version of the previous global to be restored in tearDown.
Group all the pieces relevant to the context of a request into one instance.
the array() calling protocol came about after MediaWiki 1.4rc1.
do that in ParserLimitReportFormat instead use this to modify the parameters of the image all existing parser cache entries will be invalid To avoid you ll need to handle that somehow(e.g. with the RejectParserCacheValue hook) because MediaWiki won 't do it for you. & $defaults also a ContextSource after deleting those rows but within the same transaction you ll probably need to make sure the header is varied on $request
Definition hooks.txt:2806
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:2001
do that in ParserLimitReportFormat instead use this to modify the parameters of the image all existing parser cache entries will be invalid To avoid you ll need to handle that somehow(e.g. with the RejectParserCacheValue hook) because MediaWiki won 't do it for you. & $defaults also a ContextSource after deleting those rows but within the same transaction you ll probably need to make sure the header is varied on and they can depend only on the ResourceLoaderContext $context
Definition hooks.txt:2811
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses & $ret
Definition hooks.txt:2005
Status::newGood()` to allow deletion, and then `return false` from the hook function. Ensure you consume the 'ChangeTagAfterDelete' hook to carry out custom deletion actions. $tag:name of the tag $user:user initiating the action & $status:Status object. See above. 'ChangeTagsListActive':Allows you to nominate which of the tags your extension uses are in active use. & $tags:list of all active tags. Append to this array. 'ChangeTagsAfterUpdateTags':Called after tags have been updated with the ChangeTags::updateTags function. Params:$addedTags:tags effectively added in the update $removedTags:tags effectively removed in the update $prevTags:tags that were present prior to the update $rc_id:recentchanges table id $rev_id:revision table id $log_id:logging table id $params:tag params $rc:RecentChange being tagged when the tagging accompanies the action or null $user:User who performed the tagging when the tagging is subsequent to the action or null 'ChangeTagsAllowedAdd':Called when checking if a user can add tags to a change. & $allowedTags:List of all the tags the user is allowed to add. Any tags the user wants to add( $addTags) that are not in this array will cause it to fail. You may add or remove tags to this array as required. $addTags:List of tags user intends to add. $user:User who is adding the tags. 'ChangeUserGroups':Called before user groups are changed. $performer:The User who will perform the change $user:The User whose groups will be changed & $add:The groups that will be added & $remove:The groups that will be removed 'Collation::factory':Called if $wgCategoryCollation is an unknown collation. $collationName:Name of the collation in question & $collationObject:Null. Replace with a subclass of the Collation class that implements the collation given in $collationName. 'ConfirmEmailComplete':Called after a user 's email has been confirmed successfully. $user:user(object) whose email is being confirmed 'ContentAlterParserOutput':Modify parser output for a given content object. Called by Content::getParserOutput after parsing has finished. Can be used for changes that depend on the result of the parsing but have to be done before LinksUpdate is called(such as adding tracking categories based on the rendered HTML). $content:The Content to render $title:Title of the page, as context $parserOutput:ParserOutput to manipulate 'ContentGetParserOutput':Customize parser output for a given content object, called by AbstractContent::getParserOutput. May be used to override the normal model-specific rendering of page content. $content:The Content to render $title:Title of the page, as context $revId:The revision ID, as context $options:ParserOptions for rendering. To avoid confusing the parser cache, the output can only depend on parameters provided to this hook function, not on global state. $generateHtml:boolean, indicating whether full HTML should be generated. If false, generation of HTML may be skipped, but other information should still be present in the ParserOutput object. & $output:ParserOutput, to manipulate or replace 'ContentHandlerDefaultModelFor':Called when the default content model is determined for a given title. May be used to assign a different model for that title. $title:the Title in question & $model:the model name. Use with CONTENT_MODEL_XXX constants. 'ContentHandlerForModelID':Called when a ContentHandler is requested for a given content model name, but no entry for that model exists in $wgContentHandlers. Note:if your extension implements additional models via this hook, please use GetContentModels hook to make them known to core. $modeName:the requested content model name & $handler:set this to a ContentHandler object, if desired. 'ContentModelCanBeUsedOn':Called to determine whether that content model can be used on a given page. This is especially useful to prevent some content models to be used in some special location. $contentModel:ID of the content model in question $title:the Title in question. & $ok:Output parameter, whether it is OK to use $contentModel on $title. Handler functions that modify $ok should generally return false to prevent further hooks from further modifying $ok. 'ContribsPager::getQueryInfo':Before the contributions query is about to run & $pager:Pager object for contributions & $queryInfo:The query for the contribs Pager 'ContribsPager::reallyDoQuery':Called before really executing the query for My Contributions & $data:an array of results of all contribs queries $pager:The ContribsPager object hooked into $offset:Index offset, inclusive $limit:Exact query limit $descending:Query direction, false for ascending, true for descending 'ContributionsLineEnding':Called before a contributions HTML line is finished $page:SpecialPage object for contributions & $ret:the HTML line $row:the DB row for this line & $classes:the classes to add to the surrounding< li > & $attribs:associative array of other HTML attributes for the< li > element. Currently only data attributes reserved to MediaWiki are allowed(see Sanitizer::isReservedDataAttribute). 'ContributionsToolLinks':Change tool links above Special:Contributions $id:User identifier $title:User page title & $tools:Array of tool links $specialPage:SpecialPage instance for context and services. Can be either SpecialContributions or DeletedContributionsPage. Extensions should type hint against a generic SpecialPage though. 'ConvertContent':Called by AbstractContent::convert when a conversion to another content model is requested. Handler functions that modify $result should generally return false to disable further attempts at conversion. $content:The Content object to be converted. $toModel:The ID of the content model to convert to. $lossy:boolean indicating whether lossy conversion is allowed. & $result:Output parameter, in case the handler function wants to provide a converted Content object. Note that $result->getContentModel() must return $toModel. 'CustomEditor':When invoking the page editor Return true to allow the normal editor to be used, or false if implementing a custom editor, e.g. for a special namespace, etc. $article:Article being edited $user:User performing the edit 'DatabaseOraclePostInit':Called after initialising an Oracle database $db:the DatabaseOracle object 'DeletedContribsPager::reallyDoQuery':Called before really executing the query for Special:DeletedContributions Similar to ContribsPager::reallyDoQuery & $data:an array of results of all contribs queries $pager:The DeletedContribsPager object hooked into $offset:Index offset, inclusive $limit:Exact query limit $descending:Query direction, false for ascending, true for descending 'DeletedContributionsLineEnding':Called before a DeletedContributions HTML line is finished. Similar to ContributionsLineEnding $page:SpecialPage object for DeletedContributions & $ret:the HTML line $row:the DB row for this line & $classes:the classes to add to the surrounding< li > & $attribs:associative array of other HTML attributes for the< li > element. Currently only data attributes reserved to MediaWiki are allowed(see Sanitizer::isReservedDataAttribute). 'DeleteUnknownPreferences':Called by the cleanupPreferences.php maintenance script to build a WHERE clause with which to delete preferences that are not known about. This hook is used by extensions that have dynamically-named preferences that should not be deleted in the usual cleanup process. For example, the Gadgets extension creates preferences prefixed with 'gadget-', and so anything with that prefix is excluded from the deletion. &where:An array that will be passed as the $cond parameter to IDatabase::select() to determine what will be deleted from the user_properties table. $db:The IDatabase object, useful for accessing $db->buildLike() etc. 'DifferenceEngineAfterLoadNewText':called in DifferenceEngine::loadNewText() after the new revision 's content has been loaded into the class member variable $differenceEngine->mNewContent but before returning true from this function. $differenceEngine:DifferenceEngine object 'DifferenceEngineLoadTextAfterNewContentIsLoaded':called in DifferenceEngine::loadText() after the new revision 's content has been loaded into the class member variable $differenceEngine->mNewContent but before checking if the variable 's value is null. This hook can be used to inject content into said class member variable. $differenceEngine:DifferenceEngine object 'DifferenceEngineMarkPatrolledLink':Allows extensions to change the "mark as patrolled" link which is shown both on the diff header as well as on the bottom of a page, usually wrapped in a span element which has class="patrollink". $differenceEngine:DifferenceEngine object & $markAsPatrolledLink:The "mark as patrolled" link HTML(string) $rcid:Recent change ID(rc_id) for this change(int) 'DifferenceEngineMarkPatrolledRCID':Allows extensions to possibly change the rcid parameter. For example the rcid might be set to zero due to the user being the same as the performer of the change but an extension might still want to show it under certain conditions. & $rcid:rc_id(int) of the change or 0 $differenceEngine:DifferenceEngine object $change:RecentChange object $user:User object representing the current user 'DifferenceEngineNewHeader':Allows extensions to change the $newHeader variable, which contains information about the new revision, such as the revision 's author, whether the revision was marked as a minor edit or not, etc. $differenceEngine:DifferenceEngine object & $newHeader:The string containing the various #mw-diff-otitle[1-5] divs, which include things like revision author info, revision comment, RevisionDelete link and more $formattedRevisionTools:Array containing revision tools, some of which may have been injected with the DiffRevisionTools hook $nextlink:String containing the link to the next revision(if any) $status
Definition hooks.txt:1255
this hook is for auditing only $response
Definition hooks.txt:783
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:37
$params