Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
179 / 179
100.00% covered (success)
100.00%
45 / 45
CRAP
100.00% covered (success)
100.00%
1 / 1
ApiHookRunner
100.00% covered (success)
100.00%
179 / 179
100.00% covered (success)
100.00%
45 / 45
45
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 onAPIAfterExecute
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
1
 onApiCheckCanExecute
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
1
 onApiDeprecationHelp
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
1
 onApiFeedContributions__feedItem
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
1
 onApiFormatHighlight
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
1
 onAPIGetAllowedParams
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
1
 onAPIGetDescriptionMessages
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
1
 onAPIGetParamDescriptionMessages
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
1
 onAPIHelpModifyOutput
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
1
 onApiLogFeatureUsage
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
1
 onApiMain__moduleManager
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
1
 onApiMain__onException
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
1
 onApiMakeParserOptions
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
1
 onApiMaxLagInfo
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
1 / 1
1
 onApiOpenSearchSuggest
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
1
 onApiOptions
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
1
 onApiParseMakeOutputPage
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
1
 onAPIQueryAfterExecute
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
1
 onApiQueryBaseAfterQuery
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
1
 onApiQueryBaseBeforeQuery
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
1 / 1
1
 onApiQueryBaseProcessRow
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
1
 onApiQueryCheckCanExecute
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
1
 onAPIQueryGeneratorAfterExecute
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
1
 onAPIQuerySiteInfoGeneralInfo
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
1
 onAPIQuerySiteInfoStatisticsInfo
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
1
 onApiQueryTokensRegisterTypes
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
1
 onApiQueryWatchlistExtractOutputData
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
1
 onApiQueryWatchlistPrepareWatchedItemQueryServiceOptions
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
1
 onApiQuery__moduleManager
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
1
 onApiRsdServiceApis
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
1
 onApiValidatePassword
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
1
 onArticleParserOptions
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
1
 onChangeAuthenticationDataAudit
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
1
 onEditFormPreloadText
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
1
 onFileUndeleteComplete
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
1
 onGetLinkColours
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
1
 onImportSources
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
1
 onLanguageLinks
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
1
 onOutputPageBeforeHTML
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
1
 onOutputPageCheckLastModified
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
1
 onRequestHasSameOriginSecurity
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
1
 onTempUserCreatedRedirect
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
1
 onUserLoginComplete
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
1
 onUserLogoutComplete
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3namespace MediaWiki\Api;
4
5use MediaWiki\HookContainer\HookContainer;
6use MediaWiki\Page\Article;
7use MediaWiki\Parser\ParserOptions;
8use MediaWiki\Session\Session;
9use MediaWiki\User\UserIdentity;
10
11/**
12 * This class provides an implementation of the hook interfaces used
13 * by the core Action API, forwarding hook calls to HookContainer for
14 * dispatch to extensions.
15 *
16 * To get an instance, use ApiBase::getHookRunner().
17 */
18class ApiHookRunner implements
19    Hook\APIAfterExecuteHook,
20    Hook\ApiCheckCanExecuteHook,
21    Hook\ApiDeprecationHelpHook,
22    Hook\ApiLogFeatureUsageHook,
23    Hook\ApiFeedContributions__feedItemHook,
24    Hook\ApiFormatHighlightHook,
25    Hook\APIGetAllowedParamsHook,
26    Hook\APIGetDescriptionMessagesHook,
27    Hook\APIGetParamDescriptionMessagesHook,
28    Hook\APIHelpModifyOutputHook,
29    Hook\ApiMain__moduleManagerHook,
30    Hook\ApiMain__onExceptionHook,
31    Hook\ApiMakeParserOptionsHook,
32    Hook\ApiMaxLagInfoHook,
33    Hook\ApiOpenSearchSuggestHook,
34    Hook\ApiOptionsHook,
35    Hook\ApiParseMakeOutputPageHook,
36    Hook\APIQueryAfterExecuteHook,
37    Hook\ApiQueryBaseAfterQueryHook,
38    Hook\ApiQueryBaseBeforeQueryHook,
39    Hook\ApiQueryBaseProcessRowHook,
40    Hook\ApiQueryCheckCanExecuteHook,
41    Hook\APIQueryGeneratorAfterExecuteHook,
42    Hook\APIQuerySiteInfoGeneralInfoHook,
43    Hook\APIQuerySiteInfoStatisticsInfoHook,
44    Hook\ApiQueryTokensRegisterTypesHook,
45    Hook\ApiQueryWatchlistExtractOutputDataHook,
46    Hook\ApiQueryWatchlistPrepareWatchedItemQueryServiceOptionsHook,
47    Hook\ApiQuery__moduleManagerHook,
48    Hook\ApiRsdServiceApisHook,
49    Hook\ApiValidatePasswordHook,
50    Hook\RequestHasSameOriginSecurityHook,
51    \MediaWiki\Hook\EditFormPreloadTextHook,
52    \MediaWiki\Hook\FileUndeleteCompleteHook,
53    \MediaWiki\Hook\GetLinkColoursHook,
54    \MediaWiki\Hook\ImportSourcesHook,
55    \MediaWiki\Output\Hook\LanguageLinksHook,
56    \MediaWiki\Output\Hook\OutputPageBeforeHTMLHook,
57    \MediaWiki\Output\Hook\OutputPageCheckLastModifiedHook,
58    \MediaWiki\Page\Hook\ArticleParserOptionsHook,
59    \MediaWiki\Hook\TempUserCreatedRedirectHook,
60    \MediaWiki\Hook\UserLoginCompleteHook,
61    \MediaWiki\Hook\UserLogoutCompleteHook,
62    \MediaWiki\SpecialPage\Hook\ChangeAuthenticationDataAuditHook
63{
64    private HookContainer $container;
65
66    public function __construct( HookContainer $container ) {
67        $this->container = $container;
68    }
69
70    /** @inheritDoc */
71    public function onAPIAfterExecute( $module ) {
72        return $this->container->run(
73            'APIAfterExecute',
74            [ $module ]
75        );
76    }
77
78    /** @inheritDoc */
79    public function onApiCheckCanExecute( $module, $user, &$message ) {
80        return $this->container->run(
81            'ApiCheckCanExecute',
82            [ $module, $user, &$message ]
83        );
84    }
85
86    /** @inheritDoc */
87    public function onApiDeprecationHelp( &$msgs ) {
88        return $this->container->run(
89            'ApiDeprecationHelp',
90            [ &$msgs ]
91        );
92    }
93
94    /** @inheritDoc */
95    public function onApiFeedContributions__feedItem( $row, $context, &$feedItem ) {
96        return $this->container->run(
97            'ApiFeedContributions::feedItem',
98            [ $row, $context, &$feedItem ]
99        );
100    }
101
102    /** @inheritDoc */
103    public function onApiFormatHighlight( $context, $text, $mime, $format ) {
104        return $this->container->run(
105            'ApiFormatHighlight',
106            [ $context, $text, $mime, $format ]
107        );
108    }
109
110    /** @inheritDoc */
111    public function onAPIGetAllowedParams( $module, &$params, $flags ) {
112        return $this->container->run(
113            'APIGetAllowedParams',
114            [ $module, &$params, $flags ]
115        );
116    }
117
118    /** @inheritDoc */
119    public function onAPIGetDescriptionMessages( $module, &$msg ) {
120        return $this->container->run(
121            'APIGetDescriptionMessages',
122            [ $module, &$msg ]
123        );
124    }
125
126    /** @inheritDoc */
127    public function onAPIGetParamDescriptionMessages( $module, &$msg ) {
128        return $this->container->run(
129            'APIGetParamDescriptionMessages',
130            [ $module, &$msg ]
131        );
132    }
133
134    /** @inheritDoc */
135    public function onAPIHelpModifyOutput( $module, &$help, $options, &$tocData ) {
136        return $this->container->run(
137            'APIHelpModifyOutput',
138            [ $module, &$help, $options, &$tocData ]
139        );
140    }
141
142    /** @inheritDoc */
143    public function onApiLogFeatureUsage( $feature, array $clientInfo ): void {
144        $this->container->run(
145            'ApiLogFeatureUsage',
146            [ $feature, $clientInfo ]
147        );
148    }
149
150    /** @inheritDoc */
151    public function onApiMain__moduleManager( $moduleManager ) {
152        return $this->container->run(
153            'ApiMain::moduleManager',
154            [ $moduleManager ]
155        );
156    }
157
158    /** @inheritDoc */
159    public function onApiMain__onException( $apiMain, $e ) {
160        return $this->container->run(
161            'ApiMain::onException',
162            [ $apiMain, $e ]
163        );
164    }
165
166    /** @inheritDoc */
167    public function onApiMakeParserOptions( $options, $title, $params, $module,
168        &$reset, &$suppressCache
169    ) {
170        return $this->container->run(
171            'ApiMakeParserOptions',
172            [ $options, $title, $params, $module, &$reset, &$suppressCache ]
173        );
174    }
175
176    /** @inheritDoc */
177    public function onApiMaxLagInfo( &$lagInfo ): void {
178        $this->container->run(
179            'ApiMaxLagInfo',
180            [ &$lagInfo ],
181            [ 'abortable' => false ]
182        );
183    }
184
185    /** @inheritDoc */
186    public function onApiOpenSearchSuggest( &$results ) {
187        return $this->container->run(
188            'ApiOpenSearchSuggest',
189            [ &$results ]
190        );
191    }
192
193    /** @inheritDoc */
194    public function onApiOptions( $apiModule, $user, $changes, $resetKinds ) {
195        return $this->container->run(
196            'ApiOptions',
197            [ $apiModule, $user, $changes, $resetKinds ]
198        );
199    }
200
201    /** @inheritDoc */
202    public function onApiParseMakeOutputPage( $module, $output ) {
203        return $this->container->run(
204            'ApiParseMakeOutputPage',
205            [ $module, $output ]
206        );
207    }
208
209    /** @inheritDoc */
210    public function onAPIQueryAfterExecute( $module ) {
211        return $this->container->run(
212            'APIQueryAfterExecute',
213            [ $module ]
214        );
215    }
216
217    /** @inheritDoc */
218    public function onApiQueryBaseAfterQuery( $module, $result, &$hookData ) {
219        return $this->container->run(
220            'ApiQueryBaseAfterQuery',
221            [ $module, $result, &$hookData ]
222        );
223    }
224
225    /** @inheritDoc */
226    public function onApiQueryBaseBeforeQuery( $module, &$tables, &$fields,
227        &$conds, &$query_options, &$join_conds, &$hookData
228    ) {
229        return $this->container->run(
230            'ApiQueryBaseBeforeQuery',
231            [ $module, &$tables, &$fields, &$conds, &$query_options,
232                &$join_conds, &$hookData ]
233        );
234    }
235
236    /** @inheritDoc */
237    public function onApiQueryBaseProcessRow( $module, $row, &$data, &$hookData ) {
238        return $this->container->run(
239            'ApiQueryBaseProcessRow',
240            [ $module, $row, &$data, &$hookData ]
241        );
242    }
243
244    /** @inheritDoc */
245    public function onApiQueryCheckCanExecute( $modules, $authority, &$message ) {
246        return $this->container->run(
247            'ApiQueryCheckCanExecute',
248            [ $modules, $authority, &$message ]
249        );
250    }
251
252    /** @inheritDoc */
253    public function onAPIQueryGeneratorAfterExecute( $module, $resultPageSet ) {
254        return $this->container->run(
255            'APIQueryGeneratorAfterExecute',
256            [ $module, $resultPageSet ]
257        );
258    }
259
260    /** @inheritDoc */
261    public function onAPIQuerySiteInfoGeneralInfo( $module, &$results ) {
262        return $this->container->run(
263            'APIQuerySiteInfoGeneralInfo',
264            [ $module, &$results ]
265        );
266    }
267
268    /** @inheritDoc */
269    public function onAPIQuerySiteInfoStatisticsInfo( &$results ) {
270        return $this->container->run(
271            'APIQuerySiteInfoStatisticsInfo',
272            [ &$results ]
273        );
274    }
275
276    /** @inheritDoc */
277    public function onApiQueryTokensRegisterTypes( &$salts ) {
278        return $this->container->run(
279            'ApiQueryTokensRegisterTypes',
280            [ &$salts ]
281        );
282    }
283
284    /** @inheritDoc */
285    public function onApiQueryWatchlistExtractOutputData( $module, $watchedItem,
286        $recentChangeInfo, &$vals
287    ) {
288        return $this->container->run(
289            'ApiQueryWatchlistExtractOutputData',
290            [ $module, $watchedItem, $recentChangeInfo, &$vals ]
291        );
292    }
293
294    /** @inheritDoc */
295    public function onApiQueryWatchlistPrepareWatchedItemQueryServiceOptions(
296        $module, $params, &$options
297    ) {
298        return $this->container->run(
299            'ApiQueryWatchlistPrepareWatchedItemQueryServiceOptions',
300            [ $module, $params, &$options ]
301        );
302    }
303
304    /** @inheritDoc */
305    public function onApiQuery__moduleManager( $moduleManager ) {
306        return $this->container->run(
307            'ApiQuery::moduleManager',
308            [ $moduleManager ]
309        );
310    }
311
312    /** @inheritDoc */
313    public function onApiRsdServiceApis( &$apis ) {
314        return $this->container->run(
315            'ApiRsdServiceApis',
316            [ &$apis ]
317        );
318    }
319
320    /** @inheritDoc */
321    public function onApiValidatePassword( $module, &$r ) {
322        return $this->container->run(
323            'ApiValidatePassword',
324            [ $module, &$r ]
325        );
326    }
327
328    /** @inheritDoc */
329    public function onArticleParserOptions( Article $article, ParserOptions $popts ) {
330        return $this->container->run(
331            'ArticleParserOptions',
332            [ $article, $popts ]
333        );
334    }
335
336    /** @inheritDoc */
337    public function onChangeAuthenticationDataAudit( $req, $status ) {
338        return $this->container->run(
339            'ChangeAuthenticationDataAudit',
340            [ $req, $status ]
341        );
342    }
343
344    /** @inheritDoc */
345    public function onEditFormPreloadText( &$text, $title ) {
346        return $this->container->run(
347            'EditFormPreloadText',
348            [ &$text, $title ]
349        );
350    }
351
352    /** @inheritDoc */
353    public function onFileUndeleteComplete( $title, $fileVersions, $user, $reason ) {
354        return $this->container->run(
355            'FileUndeleteComplete',
356            [ $title, $fileVersions, $user, $reason ]
357        );
358    }
359
360    /** @inheritDoc */
361    public function onGetLinkColours( $pagemap, &$classes, $title ) {
362        return $this->container->run(
363            'GetLinkColours',
364            [ $pagemap, &$classes, $title ]
365        );
366    }
367
368    /** @inheritDoc */
369    public function onImportSources( &$importSources ) {
370        return $this->container->run(
371            'ImportSources',
372            [ &$importSources ]
373        );
374    }
375
376    /** @inheritDoc */
377    public function onLanguageLinks( $title, &$links, &$linkFlags ) {
378        return $this->container->run(
379            'LanguageLinks',
380            [ $title, &$links, &$linkFlags ]
381        );
382    }
383
384    /** @inheritDoc */
385    public function onOutputPageBeforeHTML( $out, &$text ) {
386        return $this->container->run(
387            'OutputPageBeforeHTML',
388            [ $out, &$text ]
389        );
390    }
391
392    /** @inheritDoc */
393    public function onOutputPageCheckLastModified( &$modifiedTimes, $out ) {
394        return $this->container->run(
395            'OutputPageCheckLastModified',
396            [ &$modifiedTimes, $out ]
397        );
398    }
399
400    /** @inheritDoc */
401    public function onRequestHasSameOriginSecurity( $request ) {
402        return $this->container->run(
403            'RequestHasSameOriginSecurity',
404            [ $request ]
405        );
406    }
407
408    /** @inheritDoc */
409    public function onTempUserCreatedRedirect(
410        Session $session,
411        UserIdentity $user,
412        string $returnTo,
413        string $returnToQuery,
414        string $returnToAnchor,
415        &$redirectUrl
416    ) {
417        return $this->container->run(
418            'TempUserCreatedRedirect',
419            [ $session, $user, $returnTo, $returnToQuery, $returnToAnchor, &$redirectUrl ]
420        );
421    }
422
423    /** @inheritDoc */
424    public function onUserLoginComplete( $user, &$inject_html, $direct ) {
425        return $this->container->run(
426            'UserLoginComplete',
427            [ $user, &$inject_html, $direct ]
428        );
429    }
430
431    /** @inheritDoc */
432    public function onUserLogoutComplete( $user, &$inject_html, $oldName ) {
433        return $this->container->run(
434            'UserLogoutComplete',
435            [ $user, &$inject_html, $oldName ]
436        );
437    }
438}