| 1 |
<?php |
| 2 |
|
| 3 |
namespace MediaWiki\Api; |
| 4 |
|
| 5 |
use Article; |
| 6 |
use MediaWiki\HookContainer\HookContainer; |
| 7 |
use MediaWiki\Parser\ParserOptions; |
| 8 |
use MediaWiki\Session\Session; |
| 9 |
use MediaWiki\User\UserIdentity; |
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
class 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\APIQueryGeneratorAfterExecuteHook, |
| 41 |
Hook\APIQuerySiteInfoGeneralInfoHook, |
| 42 |
Hook\APIQuerySiteInfoStatisticsInfoHook, |
| 43 |
Hook\ApiQueryTokensRegisterTypesHook, |
| 44 |
Hook\ApiQueryWatchlistExtractOutputDataHook, |
| 45 |
Hook\ApiQueryWatchlistPrepareWatchedItemQueryServiceOptionsHook, |
| 46 |
Hook\ApiQuery__moduleManagerHook, |
| 47 |
Hook\ApiRsdServiceApisHook, |
| 48 |
Hook\ApiValidatePasswordHook, |
| 49 |
Hook\RequestHasSameOriginSecurityHook, |
| 50 |
\MediaWiki\Hook\EditFormPreloadTextHook, |
| 51 |
\MediaWiki\Hook\FileUndeleteCompleteHook, |
| 52 |
\MediaWiki\Hook\GetLinkColoursHook, |
| 53 |
\MediaWiki\Hook\ImportSourcesHook, |
| 54 |
\MediaWiki\Output\Hook\LanguageLinksHook, |
| 55 |
\MediaWiki\Output\Hook\OutputPageBeforeHTMLHook, |
| 56 |
\MediaWiki\Output\Hook\OutputPageCheckLastModifiedHook, |
| 57 |
\MediaWiki\Page\Hook\ArticleParserOptionsHook, |
| 58 |
\MediaWiki\Hook\TempUserCreatedRedirectHook, |
| 59 |
\MediaWiki\Hook\UserLoginCompleteHook, |
| 60 |
\MediaWiki\Hook\UserLogoutCompleteHook, |
| 61 |
\MediaWiki\SpecialPage\Hook\ChangeAuthenticationDataAuditHook |
| 62 |
{ |
| 63 |
private HookContainer $container; |
| 64 |
|
| 65 |
public function __construct( HookContainer $container ) { |
| 66 |
$this->container = $container; |
| 67 |
} |
| 68 |
|
| 69 |
public function onAPIAfterExecute( $module ) { |
| 70 |
return $this->container->run( |
| 71 |
'APIAfterExecute', |
| 72 |
[ $module ] |
| 73 |
); |
| 74 |
} |
| 75 |
|
| 76 |
public function onApiCheckCanExecute( $module, $user, &$message ) { |
| 77 |
return $this->container->run( |
| 78 |
'ApiCheckCanExecute', |
| 79 |
[ $module, $user, &$message ] |
| 80 |
); |
| 81 |
} |
| 82 |
|
| 83 |
public function onApiDeprecationHelp( &$msgs ) { |
| 84 |
return $this->container->run( |
| 85 |
'ApiDeprecationHelp', |
| 86 |
[ &$msgs ] |
| 87 |
); |
| 88 |
} |
| 89 |
|
| 90 |
public function onApiFeedContributions__feedItem( $row, $context, &$feedItem ) { |
| 91 |
return $this->container->run( |
| 92 |
'ApiFeedContributions::feedItem', |
| 93 |
[ $row, $context, &$feedItem ] |
| 94 |
); |
| 95 |
} |
| 96 |
|
| 97 |
public function onApiFormatHighlight( $context, $text, $mime, $format ) { |
| 98 |
return $this->container->run( |
| 99 |
'ApiFormatHighlight', |
| 100 |
[ $context, $text, $mime, $format ] |
| 101 |
); |
| 102 |
} |
| 103 |
|
| 104 |
public function onAPIGetAllowedParams( $module, &$params, $flags ) { |
| 105 |
return $this->container->run( |
| 106 |
'APIGetAllowedParams', |
| 107 |
[ $module, &$params, $flags ] |
| 108 |
); |
| 109 |
} |
| 110 |
|
| 111 |
public function onAPIGetDescriptionMessages( $module, &$msg ) { |
| 112 |
return $this->container->run( |
| 113 |
'APIGetDescriptionMessages', |
| 114 |
[ $module, &$msg ] |
| 115 |
); |
| 116 |
} |
| 117 |
|
| 118 |
public function onAPIGetParamDescriptionMessages( $module, &$msg ) { |
| 119 |
return $this->container->run( |
| 120 |
'APIGetParamDescriptionMessages', |
| 121 |
[ $module, &$msg ] |
| 122 |
); |
| 123 |
} |
| 124 |
|
| 125 |
public function onAPIHelpModifyOutput( $module, &$help, $options, &$tocData ) { |
| 126 |
return $this->container->run( |
| 127 |
'APIHelpModifyOutput', |
| 128 |
[ $module, &$help, $options, &$tocData ] |
| 129 |
); |
| 130 |
} |
| 131 |
|
| 132 |
public function onApiLogFeatureUsage( $feature, array $clientInfo ): void { |
| 133 |
$this->container->run( |
| 134 |
'ApiLogFeatureUsage', |
| 135 |
[ $feature, $clientInfo ] |
| 136 |
); |
| 137 |
} |
| 138 |
|
| 139 |
public function onApiMain__moduleManager( $moduleManager ) { |
| 140 |
return $this->container->run( |
| 141 |
'ApiMain::moduleManager', |
| 142 |
[ $moduleManager ] |
| 143 |
); |
| 144 |
} |
| 145 |
|
| 146 |
public function onApiMain__onException( $apiMain, $e ) { |
| 147 |
return $this->container->run( |
| 148 |
'ApiMain::onException', |
| 149 |
[ $apiMain, $e ] |
| 150 |
); |
| 151 |
} |
| 152 |
|
| 153 |
public function onApiMakeParserOptions( $options, $title, $params, $module, |
| 154 |
&$reset, &$suppressCache |
| 155 |
) { |
| 156 |
return $this->container->run( |
| 157 |
'ApiMakeParserOptions', |
| 158 |
[ $options, $title, $params, $module, &$reset, &$suppressCache ] |
| 159 |
); |
| 160 |
} |
| 161 |
|
| 162 |
public function onApiMaxLagInfo( &$lagInfo ): void { |
| 163 |
$this->container->run( |
| 164 |
'ApiMaxLagInfo', |
| 165 |
[ &$lagInfo ], |
| 166 |
[ 'abortable' => false ] |
| 167 |
); |
| 168 |
} |
| 169 |
|
| 170 |
public function onApiOpenSearchSuggest( &$results ) { |
| 171 |
return $this->container->run( |
| 172 |
'ApiOpenSearchSuggest', |
| 173 |
[ &$results ] |
| 174 |
); |
| 175 |
} |
| 176 |
|
| 177 |
public function onApiOptions( $apiModule, $user, $changes, $resetKinds ) { |
| 178 |
return $this->container->run( |
| 179 |
'ApiOptions', |
| 180 |
[ $apiModule, $user, $changes, $resetKinds ] |
| 181 |
); |
| 182 |
} |
| 183 |
|
| 184 |
public function onApiParseMakeOutputPage( $module, $output ) { |
| 185 |
return $this->container->run( |
| 186 |
'ApiParseMakeOutputPage', |
| 187 |
[ $module, $output ] |
| 188 |
); |
| 189 |
} |
| 190 |
|
| 191 |
public function onAPIQueryAfterExecute( $module ) { |
| 192 |
return $this->container->run( |
| 193 |
'APIQueryAfterExecute', |
| 194 |
[ $module ] |
| 195 |
); |
| 196 |
} |
| 197 |
|
| 198 |
public function onApiQueryBaseAfterQuery( $module, $result, &$hookData ) { |
| 199 |
return $this->container->run( |
| 200 |
'ApiQueryBaseAfterQuery', |
| 201 |
[ $module, $result, &$hookData ] |
| 202 |
); |
| 203 |
} |
| 204 |
|
| 205 |
public function onApiQueryBaseBeforeQuery( $module, &$tables, &$fields, |
| 206 |
&$conds, &$query_options, &$join_conds, &$hookData |
| 207 |
) { |
| 208 |
return $this->container->run( |
| 209 |
'ApiQueryBaseBeforeQuery', |
| 210 |
[ $module, &$tables, &$fields, &$conds, &$query_options, |
| 211 |
&$join_conds, &$hookData ] |
| 212 |
); |
| 213 |
} |
| 214 |
|
| 215 |
public function onApiQueryBaseProcessRow( $module, $row, &$data, &$hookData ) { |
| 216 |
return $this->container->run( |
| 217 |
'ApiQueryBaseProcessRow', |
| 218 |
[ $module, $row, &$data, &$hookData ] |
| 219 |
); |
| 220 |
} |
| 221 |
|
| 222 |
public function onAPIQueryGeneratorAfterExecute( $module, $resultPageSet ) { |
| 223 |
return $this->container->run( |
| 224 |
'APIQueryGeneratorAfterExecute', |
| 225 |
[ $module, $resultPageSet ] |
| 226 |
); |
| 227 |
} |
| 228 |
|
| 229 |
public function onAPIQuerySiteInfoGeneralInfo( $module, &$results ) { |
| 230 |
return $this->container->run( |
| 231 |
'APIQuerySiteInfoGeneralInfo', |
| 232 |
[ $module, &$results ] |
| 233 |
); |
| 234 |
} |
| 235 |
|
| 236 |
public function onAPIQuerySiteInfoStatisticsInfo( &$results ) { |
| 237 |
return $this->container->run( |
| 238 |
'APIQuerySiteInfoStatisticsInfo', |
| 239 |
[ &$results ] |
| 240 |
); |
| 241 |
} |
| 242 |
|
| 243 |
public function onApiQueryTokensRegisterTypes( &$salts ) { |
| 244 |
return $this->container->run( |
| 245 |
'ApiQueryTokensRegisterTypes', |
| 246 |
[ &$salts ] |
| 247 |
); |
| 248 |
} |
| 249 |
|
| 250 |
public function onApiQueryWatchlistExtractOutputData( $module, $watchedItem, |
| 251 |
$recentChangeInfo, &$vals |
| 252 |
) { |
| 253 |
return $this->container->run( |
| 254 |
'ApiQueryWatchlistExtractOutputData', |
| 255 |
[ $module, $watchedItem, $recentChangeInfo, &$vals ] |
| 256 |
); |
| 257 |
} |
| 258 |
|
| 259 |
public function onApiQueryWatchlistPrepareWatchedItemQueryServiceOptions( |
| 260 |
$module, $params, &$options |
| 261 |
) { |
| 262 |
return $this->container->run( |
| 263 |
'ApiQueryWatchlistPrepareWatchedItemQueryServiceOptions', |
| 264 |
[ $module, $params, &$options ] |
| 265 |
); |
| 266 |
} |
| 267 |
|
| 268 |
public function onApiQuery__moduleManager( $moduleManager ) { |
| 269 |
return $this->container->run( |
| 270 |
'ApiQuery::moduleManager', |
| 271 |
[ $moduleManager ] |
| 272 |
); |
| 273 |
} |
| 274 |
|
| 275 |
public function onApiRsdServiceApis( &$apis ) { |
| 276 |
return $this->container->run( |
| 277 |
'ApiRsdServiceApis', |
| 278 |
[ &$apis ] |
| 279 |
); |
| 280 |
} |
| 281 |
|
| 282 |
public function onApiValidatePassword( $module, &$r ) { |
| 283 |
return $this->container->run( |
| 284 |
'ApiValidatePassword', |
| 285 |
[ $module, &$r ] |
| 286 |
); |
| 287 |
} |
| 288 |
|
| 289 |
public function onArticleParserOptions( Article $article, ParserOptions $popts ) { |
| 290 |
return $this->container->run( |
| 291 |
'ArticleParserOptions', |
| 292 |
[ $article, $popts ] |
| 293 |
); |
| 294 |
} |
| 295 |
|
| 296 |
public function onChangeAuthenticationDataAudit( $req, $status ) { |
| 297 |
return $this->container->run( |
| 298 |
'ChangeAuthenticationDataAudit', |
| 299 |
[ $req, $status ] |
| 300 |
); |
| 301 |
} |
| 302 |
|
| 303 |
public function onEditFormPreloadText( &$text, $title ) { |
| 304 |
return $this->container->run( |
| 305 |
'EditFormPreloadText', |
| 306 |
[ &$text, $title ] |
| 307 |
); |
| 308 |
} |
| 309 |
|
| 310 |
public function onFileUndeleteComplete( $title, $fileVersions, $user, $reason ) { |
| 311 |
return $this->container->run( |
| 312 |
'FileUndeleteComplete', |
| 313 |
[ $title, $fileVersions, $user, $reason ] |
| 314 |
); |
| 315 |
} |
| 316 |
|
| 317 |
public function onGetLinkColours( $pagemap, &$classes, $title ) { |
| 318 |
return $this->container->run( |
| 319 |
'GetLinkColours', |
| 320 |
[ $pagemap, &$classes, $title ] |
| 321 |
); |
| 322 |
} |
| 323 |
|
| 324 |
public function onImportSources( &$importSources ) { |
| 325 |
return $this->container->run( |
| 326 |
'ImportSources', |
| 327 |
[ &$importSources ] |
| 328 |
); |
| 329 |
} |
| 330 |
|
| 331 |
public function onLanguageLinks( $title, &$links, &$linkFlags ) { |
| 332 |
return $this->container->run( |
| 333 |
'LanguageLinks', |
| 334 |
[ $title, &$links, &$linkFlags ] |
| 335 |
); |
| 336 |
} |
| 337 |
|
| 338 |
public function onOutputPageBeforeHTML( $out, &$text ) { |
| 339 |
return $this->container->run( |
| 340 |
'OutputPageBeforeHTML', |
| 341 |
[ $out, &$text ] |
| 342 |
); |
| 343 |
} |
| 344 |
|
| 345 |
public function onOutputPageCheckLastModified( &$modifiedTimes, $out ) { |
| 346 |
return $this->container->run( |
| 347 |
'OutputPageCheckLastModified', |
| 348 |
[ &$modifiedTimes, $out ] |
| 349 |
); |
| 350 |
} |
| 351 |
|
| 352 |
public function onRequestHasSameOriginSecurity( $request ) { |
| 353 |
return $this->container->run( |
| 354 |
'RequestHasSameOriginSecurity', |
| 355 |
[ $request ] |
| 356 |
); |
| 357 |
} |
| 358 |
|
| 359 |
public function onTempUserCreatedRedirect( |
| 360 |
Session $session, |
| 361 |
UserIdentity $user, |
| 362 |
string $returnTo, |
| 363 |
string $returnToQuery, |
| 364 |
string $returnToAnchor, |
| 365 |
&$redirectUrl |
| 366 |
) { |
| 367 |
return $this->container->run( |
| 368 |
'TempUserCreatedRedirect', |
| 369 |
[ $session, $user, $returnTo, $returnToQuery, $returnToAnchor, &$redirectUrl ] |
| 370 |
); |
| 371 |
} |
| 372 |
|
| 373 |
public function onUserLoginComplete( $user, &$inject_html, $direct ) { |
| 374 |
return $this->container->run( |
| 375 |
'UserLoginComplete', |
| 376 |
[ $user, &$inject_html, $direct ] |
| 377 |
); |
| 378 |
} |
| 379 |
|
| 380 |
public function onUserLogoutComplete( $user, &$inject_html, $oldName ) { |
| 381 |
return $this->container->run( |
| 382 |
'UserLogoutComplete', |
| 383 |
[ $user, &$inject_html, $oldName ] |
| 384 |
); |
| 385 |
} |
| 386 |
} |