diff options
author | Umherirrender <umherirrender_de.wp@web.de> | 2023-04-27 21:38:57 +0200 |
---|---|---|
committer | Umherirrender <umherirrender_de.wp@web.de> | 2023-05-06 19:59:33 +0000 |
commit | 2f59f3265e40c2b63c4a50fff25e816b0c17e81a (patch) | |
tree | 41fc0739154334df728879955f328a18c46aaffc /includes/WebRequest.php | |
parent | 7532a620d7a67f68226a4d3df903f3ebc9f79bff (diff) | |
download | mediawikicore-2f59f3265e40c2b63c4a50fff25e816b0c17e81a.tar.gz mediawikicore-2f59f3265e40c2b63c4a50fff25e816b0c17e81a.zip |
Use HookContainer in WebRequest
Replace deprecated Hooks::isRegistered and Hooks::run
Bug: T335536
Change-Id: I3509d2a044843eec437b9a916c4030783bbf6639
Diffstat (limited to 'includes/WebRequest.php')
-rw-r--r-- | includes/WebRequest.php | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/includes/WebRequest.php b/includes/WebRequest.php index f7d60db97d5a..b3ce0abcda82 100644 --- a/includes/WebRequest.php +++ b/includes/WebRequest.php @@ -23,6 +23,7 @@ * @file */ +use MediaWiki\HookContainer\HookRunner; use MediaWiki\MainConfigNames; use MediaWiki\MediaWikiServices; use MediaWiki\Request\FauxRequest; @@ -194,9 +195,9 @@ class WebRequest { $router->add( $articlePaths, [ 'action' => '$key' ] ); } + $services = MediaWikiServices::getInstance(); global $wgVariantArticlePath; if ( $wgVariantArticlePath ) { - $services = MediaWikiServices::getInstance(); $router->validateRoute( $wgVariantArticlePath, 'wgVariantArticlePath' ); $router->add( $wgVariantArticlePath, [ 'variant' => '$2' ], @@ -206,7 +207,7 @@ class WebRequest { ); } - Hooks::runner()->onWebRequestPathInfoRouter( $router ); + ( new HookRunner( $services->getHookContainer() ) )->onWebRequestPathInfoRouter( $router ); $matches = $router->parse( $path ); } else { @@ -1272,10 +1273,11 @@ class WebRequest { throw new MWException( 'Unable to determine IP.' ); } + $services = MediaWikiServices::getInstance(); # Append XFF $forwardedFor = $this->getHeader( 'X-Forwarded-For' ); if ( $forwardedFor !== false ) { - $proxyLookup = MediaWikiServices::getInstance()->getProxyLookup(); + $proxyLookup = $services->getProxyLookup(); $isConfigured = $proxyLookup->isConfiguredProxy( $ip ); $ipchain = array_map( 'trim', explode( ',', $forwardedFor ) ); $ipchain = array_reverse( $ipchain ); @@ -1324,10 +1326,11 @@ class WebRequest { } // Allow extensions to modify the result + $hookContainer = $services->getHookContainer(); // Optimisation: Hot code called on most requests (T85805). - if ( Hooks::isRegistered( 'GetIP' ) ) { + if ( $hookContainer->isRegistered( 'GetIP' ) ) { // @phan-suppress-next-line PhanTypeMismatchArgument Type mismatch on pass-by-ref args - Hooks::runner()->onGetIP( $ip ); + ( new HookRunner( $hookContainer ) )->onGetIP( $ip ); } if ( !$ip ) { |