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