MediaWiki  1.33.0
ApiFormatBaseTest.php
Go to the documentation of this file.
1 <?php
2 
3 use Wikimedia\TestingAccessWrapper;
4 
10 
11  protected $printerName = 'mockbase';
12 
13  protected function setUp() {
14  parent::setUp();
15  $this->setMwGlobals( [
16  'wgServer' => 'http://example.org'
17  ] );
18  }
19 
20  public function getMockFormatter( ApiMain $main = null, $format, $methods = [] ) {
21  if ( $main === null ) {
23  $context->setRequest( new FauxRequest( [], true ) );
24  $main = new ApiMain( $context );
25  }
26 
27  $mock = $this->getMockBuilder( ApiFormatBase::class )
28  ->setConstructorArgs( [ $main, $format ] )
29  ->setMethods( array_unique( array_merge( $methods, [ 'getMimeType', 'execute' ] ) ) )
30  ->getMock();
31  if ( !in_array( 'getMimeType', $methods, true ) ) {
32  $mock->method( 'getMimeType' )->willReturn( 'text/x-mock' );
33  }
34  return $mock;
35  }
36 
37  protected function encodeData( array $params, array $data, $options = [] ) {
38  $options += [
39  'name' => 'mock',
40  'class' => ApiFormatBase::class,
41  'factory' => function ( ApiMain $main, $format ) use ( $options ) {
42  $mock = $this->getMockFormatter( $main, $format );
43  $mock->expects( $this->once() )->method( 'execute' )
44  ->willReturnCallback( function () use ( $mock ) {
45  $mock->printText( "Format {$mock->getFormat()}: " );
46  $mock->printText( "<b>ok</b>" );
47  } );
48 
49  if ( isset( $options['status'] ) ) {
50  $mock->setHttpStatus( $options['status'] );
51  }
52 
53  return $mock;
54  },
55  'returnPrinter' => true,
56  ];
57 
58  $this->setMwGlobals( [
59  'wgApiFrameOptions' => 'DENY',
60  ] );
61 
62  $ret = parent::encodeData( $params, $data, $options );
63  $printer = TestingAccessWrapper::newFromObject( $ret['printer'] );
64  $text = $ret['text'];
65 
66  if ( $options['name'] !== 'mockfm' ) {
67  $ct = 'text/x-mock';
68  $file = 'api-result.mock';
69  $status = $options['status'] ?? null;
70  } elseif ( isset( $params['wrappedhtml'] ) ) {
71  $ct = 'text/mediawiki-api-prettyprint-wrapped';
72  $file = 'api-result-wrapped.json';
73  $status = null;
74 
75  // Replace varying field
76  $text = preg_replace( '/"time":\d+/', '"time":1234', $text );
77  } else {
78  $ct = 'text/html';
79  $file = 'api-result.html';
80  $status = null;
81 
82  // Strip OutputPage-generated HTML
83  if ( preg_match( '!<pre class="api-pretty-content">.*</pre>!s', $text, $m ) ) {
84  $text = $m[0];
85  }
86  }
87 
88  $response = $printer->getMain()->getRequest()->response();
89  $this->assertSame( "$ct; charset=utf-8", strtolower( $response->getHeader( 'Content-Type' ) ) );
90  $this->assertSame( 'DENY', $response->getHeader( 'X-Frame-Options' ) );
91  $this->assertSame( $file, $printer->getFilename() );
92  $this->assertSame( "inline; filename=$file", $response->getHeader( 'Content-Disposition' ) );
93  $this->assertSame( $status, $response->getStatusCode() );
94 
95  return $text;
96  }
97 
98  public static function provideGeneralEncoding() {
99  return [
100  'normal' => [
101  [],
102  "Format MOCK: <b>ok</b>",
103  [],
104  [ 'name' => 'mock' ]
105  ],
106  'normal ignores wrappedhtml' => [
107  [],
108  "Format MOCK: <b>ok</b>",
109  [ 'wrappedhtml' => 1 ],
110  [ 'name' => 'mock' ]
111  ],
112  'HTML format' => [
113  [],
114  '<pre class="api-pretty-content">Format MOCK: &lt;b>ok&lt;/b></pre>',
115  [],
116  [ 'name' => 'mockfm' ]
117  ],
118  'wrapped HTML format' => [
119  [],
120  // phpcs:ignore Generic.Files.LineLength.TooLong
121  '{"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}',
122  [ 'wrappedhtml' => 1 ],
123  [ 'name' => 'mockfm' ]
124  ],
125  'normal, with set status' => [
126  [],
127  "Format MOCK: <b>ok</b>",
128  [],
129  [ 'name' => 'mock', 'status' => 400 ]
130  ],
131  'HTML format, with set status' => [
132  [],
133  '<pre class="api-pretty-content">Format MOCK: &lt;b>ok&lt;/b></pre>',
134  [],
135  [ 'name' => 'mockfm', 'status' => 400 ]
136  ],
137  'wrapped HTML format, with set status' => [
138  [],
139  // phpcs:ignore Generic.Files.LineLength.TooLong
140  '{"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}',
141  [ 'wrappedhtml' => 1 ],
142  [ 'name' => 'mockfm', 'status' => 400 ]
143  ],
144  'wrapped HTML format, cross-domain-policy' => [
145  [ 'continue' => '< CrOsS-DoMaIn-PoLiCy >' ],
146  // phpcs:ignore Generic.Files.LineLength.TooLong
147  '{"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}',
148  [ 'wrappedhtml' => 1 ],
149  [ 'name' => 'mockfm' ]
150  ],
151  ];
152  }
153 
157  public function testFilenameEncoding( $filename, $expect ) {
158  $ret = parent::encodeData( [], [], [
159  'name' => 'mock',
160  'class' => ApiFormatBase::class,
161  'factory' => function ( ApiMain $main, $format ) use ( $filename ) {
162  $mock = $this->getMockFormatter( $main, $format, [ 'getFilename' ] );
163  $mock->method( 'getFilename' )->willReturn( $filename );
164  return $mock;
165  },
166  'returnPrinter' => true,
167  ] );
168  $response = $ret['printer']->getMain()->getRequest()->response();
169 
170  $this->assertSame( "inline; $expect", $response->getHeader( 'Content-Disposition' ) );
171  }
172 
173  public static function provideFilenameEncoding() {
174  return [
175  'something simple' => [
176  'foo.xyz', 'filename=foo.xyz'
177  ],
178  'more complicated, but still simple' => [
179  'foo.!#$%&\'*+-^_`|~', 'filename=foo.!#$%&\'*+-^_`|~'
180  ],
181  'Needs quoting' => [
182  'foo\\bar.xyz', 'filename="foo\\\\bar.xyz"'
183  ],
184  'Needs quoting (2)' => [
185  'foo (bar).xyz', 'filename="foo (bar).xyz"'
186  ],
187  'Needs quoting (3)' => [
188  "foo\t\"b\x5car\"\0.xyz", "filename=\"foo\x5c\t\x5c\"b\x5c\x5car\x5c\"\x5c\0.xyz\""
189  ],
190  'Non-ASCII characters' => [
191  'fóo bár.🙌!',
192  "filename=\"f\xF3o b\xE1r.?!\"; filename*=UTF-8''f%C3%B3o%20b%C3%A1r.%F0%9F%99%8C!"
193  ]
194  ];
195  }
196 
197  public function testBasics() {
198  $printer = $this->getMockFormatter( null, 'mock' );
199  $this->assertTrue( $printer->canPrintErrors() );
200  $this->assertSame(
201  'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Data_formats',
202  $printer->getHelpUrls()
203  );
204  }
205 
206  public function testDisable() {
207  $this->setMwGlobals( [
208  'wgApiFrameOptions' => 'DENY',
209  ] );
210 
211  $printer = $this->getMockFormatter( null, 'mock' );
212  $printer->method( 'execute' )->willReturnCallback( function () use ( $printer ) {
213  $printer->printText( 'Foo' );
214  } );
215  $this->assertFalse( $printer->isDisabled() );
216  $printer->disable();
217  $this->assertTrue( $printer->isDisabled() );
218 
219  $printer->setHttpStatus( 400 );
220  $printer->initPrinter();
221  $printer->execute();
222  ob_start();
223  $printer->closePrinter();
224  $this->assertSame( '', ob_get_clean() );
225  $response = $printer->getMain()->getRequest()->response();
226  $this->assertNull( $response->getHeader( 'Content-Type' ) );
227  $this->assertNull( $response->getHeader( 'X-Frame-Options' ) );
228  $this->assertNull( $response->getHeader( 'Content-Disposition' ) );
229  $this->assertNull( $response->getStatusCode() );
230  }
231 
232  public function testNullMimeType() {
233  $this->setMwGlobals( [
234  'wgApiFrameOptions' => 'DENY',
235  ] );
236 
237  $printer = $this->getMockFormatter( null, 'mock', [ 'getMimeType' ] );
238  $printer->method( 'execute' )->willReturnCallback( function () use ( $printer ) {
239  $printer->printText( 'Foo' );
240  } );
241  $printer->method( 'getMimeType' )->willReturn( null );
242  $this->assertNull( $printer->getMimeType(), 'sanity check' );
243 
244  $printer->initPrinter();
245  $printer->execute();
246  ob_start();
247  $printer->closePrinter();
248  $this->assertSame( 'Foo', ob_get_clean() );
249  $response = $printer->getMain()->getRequest()->response();
250  $this->assertNull( $response->getHeader( 'Content-Type' ) );
251  $this->assertNull( $response->getHeader( 'X-Frame-Options' ) );
252  $this->assertNull( $response->getHeader( 'Content-Disposition' ) );
253 
254  $printer = $this->getMockFormatter( null, 'mockfm', [ 'getMimeType' ] );
255  $printer->method( 'execute' )->willReturnCallback( function () use ( $printer ) {
256  $printer->printText( 'Foo' );
257  } );
258  $printer->method( 'getMimeType' )->willReturn( null );
259  $this->assertNull( $printer->getMimeType(), 'sanity check' );
260  $this->assertTrue( $printer->getIsHtml(), 'sanity check' );
261 
262  $printer->initPrinter();
263  $printer->execute();
264  ob_start();
265  $printer->closePrinter();
266  $this->assertSame( 'Foo', ob_get_clean() );
267  $response = $printer->getMain()->getRequest()->response();
268  $this->assertSame(
269  'text/html; charset=utf-8', strtolower( $response->getHeader( 'Content-Type' ) )
270  );
271  $this->assertSame( 'DENY', $response->getHeader( 'X-Frame-Options' ) );
272  $this->assertSame(
273  'inline; filename=api-result.html', $response->getHeader( 'Content-Disposition' )
274  );
275  }
276 
277  public function testApiFrameOptions() {
278  $this->setMwGlobals( [ 'wgApiFrameOptions' => 'DENY' ] );
279  $printer = $this->getMockFormatter( null, 'mock' );
280  $printer->initPrinter();
281  $this->assertSame(
282  'DENY',
283  $printer->getMain()->getRequest()->response()->getHeader( 'X-Frame-Options' )
284  );
285 
286  $this->setMwGlobals( [ 'wgApiFrameOptions' => 'SAMEORIGIN' ] );
287  $printer = $this->getMockFormatter( null, 'mock' );
288  $printer->initPrinter();
289  $this->assertSame(
290  'SAMEORIGIN',
291  $printer->getMain()->getRequest()->response()->getHeader( 'X-Frame-Options' )
292  );
293 
294  $this->setMwGlobals( [ 'wgApiFrameOptions' => false ] );
295  $printer = $this->getMockFormatter( null, 'mock' );
296  $printer->initPrinter();
297  $this->assertNull(
298  $printer->getMain()->getRequest()->response()->getHeader( 'X-Frame-Options' )
299  );
300  }
301 
302  public function testForceDefaultParams() {
303  $context = new RequestContext;
304  $context->setRequest( new FauxRequest( [ 'foo' => '1', 'bar' => '2', 'baz' => '3' ], true ) );
305  $main = new ApiMain( $context );
306  $allowedParams = [
307  'foo' => [],
308  'bar' => [ ApiBase::PARAM_DFLT => 'bar?' ],
309  'baz' => 'baz!',
310  ];
311 
312  $printer = $this->getMockFormatter( $main, 'mock', [ 'getAllowedParams' ] );
313  $printer->method( 'getAllowedParams' )->willReturn( $allowedParams );
314  $this->assertEquals(
315  [ 'foo' => '1', 'bar' => '2', 'baz' => '3' ],
316  $printer->extractRequestParams(),
317  'sanity check'
318  );
319 
320  $printer = $this->getMockFormatter( $main, 'mock', [ 'getAllowedParams' ] );
321  $printer->method( 'getAllowedParams' )->willReturn( $allowedParams );
322  $printer->forceDefaultParams();
323  $this->assertEquals(
324  [ 'foo' => null, 'bar' => 'bar?', 'baz' => 'baz!' ],
325  $printer->extractRequestParams()
326  );
327  }
328 
329  public function testGetAllowedParams() {
330  $printer = $this->getMockFormatter( null, 'mock' );
331  $this->assertSame( [], $printer->getAllowedParams() );
332 
333  $printer = $this->getMockFormatter( null, 'mockfm' );
334  $this->assertSame( [
335  'wrappedhtml' => [
336  ApiBase::PARAM_DFLT => false,
337  ApiBase::PARAM_HELP_MSG => 'apihelp-format-param-wrappedhtml',
338  ]
339  ], $printer->getAllowedParams() );
340  }
341 
342  public function testGetExamplesMessages() {
343  $printer = TestingAccessWrapper::newFromObject( $this->getMockFormatter( null, 'mock' ) );
344  $this->assertSame( [
345  'action=query&meta=siteinfo&siprop=namespaces&format=mock'
346  => [ 'apihelp-format-example-generic', 'MOCK' ]
347  ], $printer->getExamplesMessages() );
348 
349  $printer = TestingAccessWrapper::newFromObject( $this->getMockFormatter( null, 'mockfm' ) );
350  $this->assertSame( [
351  'action=query&meta=siteinfo&siprop=namespaces&format=mockfm'
352  => [ 'apihelp-format-example-generic', 'MOCK' ]
353  ], $printer->getExamplesMessages() );
354  }
355 
359  public function testHtmlHeader( $post, $registerNonHtml, $expect ) {
360  $context = new RequestContext;
361  $request = new FauxRequest( [ 'a' => 1, 'b' => 2 ], $post );
362  $request->setRequestURL( '/wx/api.php' );
363  $context->setRequest( $request );
364  $context->setLanguage( 'qqx' );
365  $main = new ApiMain( $context );
366  $printer = $this->getMockFormatter( $main, 'mockfm' );
367  $mm = $printer->getMain()->getModuleManager();
368  $mm->addModule( 'mockfm', 'format', ApiFormatBase::class, function () {
369  return $mock;
370  } );
371  if ( $registerNonHtml ) {
372  $mm->addModule( 'mock', 'format', ApiFormatBase::class, function () {
373  return $mock;
374  } );
375  }
376 
377  $printer->initPrinter();
378  $printer->execute();
379  ob_start();
380  $printer->closePrinter();
381  $text = ob_get_clean();
382  $this->assertContains( $expect, $text );
383  }
384 
385  public static function provideHtmlHeader() {
386  return [
387  [ false, false, '(api-format-prettyprint-header-only-html: MOCK)' ],
388  [ true, false, '(api-format-prettyprint-header-only-html: MOCK)' ],
389  // phpcs:ignore Generic.Files.LineLength.TooLong
390  [ 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>)' ],
391  [ true, true, '(api-format-prettyprint-header: MOCK, mock)' ],
392  ];
393  }
394 
395 }
$status
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. 'ContentSecurityPolicyDefaultSource':Modify the allowed CSP load sources. This affects all directives except for the script directive. If you want to add a script source, see ContentSecurityPolicyScriptSource hook. & $defaultSrc:Array of Content-Security-Policy allowed sources $policyConfig:Current configuration for the Content-Security-Policy header $mode:ContentSecurityPolicy::REPORT_ONLY_MODE or ContentSecurityPolicy::FULL_MODE depending on type of header 'ContentSecurityPolicyDirectives':Modify the content security policy directives. Use this only if ContentSecurityPolicyDefaultSource and ContentSecurityPolicyScriptSource do not meet your needs. & $directives:Array of CSP directives $policyConfig:Current configuration for the CSP header $mode:ContentSecurityPolicy::REPORT_ONLY_MODE or ContentSecurityPolicy::FULL_MODE depending on type of header 'ContentSecurityPolicyScriptSource':Modify the allowed CSP script sources. Note that you also have to use ContentSecurityPolicyDefaultSource if you want non-script sources to be loaded from whatever you add. & $scriptSrc:Array of CSP directives $policyConfig:Current configuration for the CSP header $mode:ContentSecurityPolicy::REPORT_ONLY_MODE or ContentSecurityPolicy::FULL_MODE depending on type of header '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:1266
ApiFormatBaseTest\testHtmlHeader
testHtmlHeader( $post, $registerNonHtml, $expect)
provideHtmlHeader
Definition: ApiFormatBaseTest.php:359
ApiMain
This is the main API class, used for both external and internal processing.
Definition: ApiMain.php:41
ApiFormatBaseTest\testFilenameEncoding
testFilenameEncoding( $filename, $expect)
provideFilenameEncoding
Definition: ApiFormatBaseTest.php:157
FauxRequest
WebRequest clone which takes values from a provided array.
Definition: FauxRequest.php:33
$file
if(PHP_SAPI !='cli-server') if(!isset( $_SERVER['SCRIPT_FILENAME'])) $file
Definition: router.php:42
ApiFormatBaseTest\provideHtmlHeader
static provideHtmlHeader()
Definition: ApiFormatBaseTest.php:385
$context
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:2636
ApiBase\PARAM_HELP_MSG
const PARAM_HELP_MSG
(string|array|Message) Specify an alternative i18n documentation message for this parameter.
Definition: ApiBase.php:124
ApiFormatBaseTest\testForceDefaultParams
testForceDefaultParams()
Definition: ApiFormatBaseTest.php:302
ApiFormatBaseTest\testGetExamplesMessages
testGetExamplesMessages()
Definition: ApiFormatBaseTest.php:342
$params
$params
Definition: styleTest.css.php:44
ApiFormatBaseTest\provideFilenameEncoding
static provideFilenameEncoding()
Definition: ApiFormatBaseTest.php:173
ApiFormatBaseTest\testGetAllowedParams
testGetAllowedParams()
Definition: ApiFormatBaseTest.php:329
php
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
ApiFormatBaseTest\setUp
setUp()
Definition: ApiFormatBaseTest.php:13
ApiFormatTestBase
Definition: ApiFormatTestBase.php:3
$data
$data
Utility to generate mapping file used in mw.Title (phpCharToUpper.json)
Definition: generatePhpCharToUpperMappings.php:13
ApiFormatBaseTest\testBasics
testBasics()
Definition: ApiFormatBaseTest.php:197
MediaWikiTestCase\setMwGlobals
setMwGlobals( $pairs, $value=null)
Sets a global, maintaining a stashed version of the previous global to be restored in tearDown.
Definition: MediaWikiTestCase.php:709
ApiFormatBaseTest\testNullMimeType
testNullMimeType()
Definition: ApiFormatBaseTest.php:232
use
as see the revision history and available at free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to use
Definition: MIT-LICENSE.txt:10
RequestContext
Group all the pieces relevant to the context of a request into one instance.
Definition: RequestContext.php:32
ApiFormatBaseTest\provideGeneralEncoding
static provideGeneralEncoding()
Return general data to be encoded for testing.
Definition: ApiFormatBaseTest.php:98
array
The wiki should then use memcached to cache various data To use multiple just add more items to the array To increase the weight of a make its entry a array("192.168.0.1:11211", 2))
$request
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:2636
ApiFormatBaseTest\encodeData
encodeData(array $params, array $data, $options=[])
Get the formatter output for the given input data.
Definition: ApiFormatBaseTest.php:37
$ret
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:1985
ApiFormatBaseTest\$printerName
$printerName
Definition: ApiFormatBaseTest.php:11
$response
this hook is for auditing only $response
Definition: hooks.txt:780
$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:1985
ApiBase\PARAM_DFLT
const PARAM_DFLT
(null|boolean|integer|string) Default value of the parameter.
Definition: ApiBase.php:48
ApiFormatBaseTest\testApiFrameOptions
testApiFrameOptions()
Definition: ApiFormatBaseTest.php:277
class
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
ApiFormatBaseTest\testDisable
testDisable()
Definition: ApiFormatBaseTest.php:206
ApiFormatBaseTest
API ApiFormatBase.
Definition: ApiFormatBaseTest.php:9
ApiFormatBaseTest\getMockFormatter
getMockFormatter(ApiMain $main=null, $format, $methods=[])
Definition: ApiFormatBaseTest.php:20