Hooks: Map dash character to underscore when generating hook names
Additionally, use strtr which is more performant (suggestion by Tim Starling). Bug: T270852 Change-Id: Ie8c8fb603b33ff95c8f8d52f392227f147c528d8
This commit is contained in:
parent
4dffcdd720
commit
8cde6fae2f
2 changed files with 2 additions and 2 deletions
|
|
@ -157,7 +157,7 @@ class HookContainer implements SalvageableService {
|
|||
}
|
||||
|
||||
$handlers = $this->getHandlers( $hook, $options );
|
||||
$funcName = 'on' . str_replace( ':', '_', ucfirst( $hook ) );
|
||||
$funcName = 'on' . strtr( ucfirst( $hook ), ':-', '__' );
|
||||
|
||||
foreach ( $handlers as $handler ) {
|
||||
$return = $handler->$funcName( ...$args );
|
||||
|
|
|
|||
|
|
@ -102,7 +102,7 @@ class Hooks {
|
|||
public static function getHandlers( $name ) {
|
||||
$hookContainer = MediaWikiServices::getInstance()->getHookContainer();
|
||||
$handlers = $hookContainer->getLegacyHandlers( $name );
|
||||
$funcName = 'on' . str_replace( ':', '_', ucfirst( $name ) );
|
||||
$funcName = 'on' . strtr( ucfirst( $name ), ':-', '__' );
|
||||
foreach ( $hookContainer->getHandlers( $name ) as $obj ) {
|
||||
$handlers[] = [ $obj, $funcName ];
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue