Go to the documentation of this file.
55 public static function register(
$name, $callback ) {
56 if ( !isset( self::$handlers[
$name] ) ) {
60 self::$handlers[
$name][] = $callback;
73 if ( !defined(
'MW_PHPUNIT_TEST' ) ) {
74 throw new MWException(
'Cannot reset hooks in operation.' );
77 unset( self::$handlers[
$name] );
106 if ( !self::isRegistered(
$name ) ) {
108 } elseif ( !isset( self::$handlers[
$name] ) ) {
111 return self::$handlers[
$name];
138 foreach ( self::getHandlers( $event )
as $hook ) {
140 if ( !is_array( $hook ) ) {
141 $hook =
array( $hook );
144 if ( !array_filter( $hook ) ) {
147 } elseif ( is_array( $hook[0] ) ) {
151 $hook = array_merge( $hook[0], array_slice( $hook, 1 ) );
159 if ( $hook[0] instanceof Closure ) {
160 $func =
"hook-$event-closure";
161 $callback = array_shift( $hook );
162 } elseif ( is_object( $hook[0] ) ) {
163 $object = array_shift( $hook );
164 $method = array_shift( $hook );
167 if ( $method ===
null ) {
168 $method =
"on$event";
171 $func = get_class( $object ) .
'::' . $method;
172 $callback =
array( $object, $method );
173 } elseif ( is_string( $hook[0] ) ) {
174 $func = $callback = array_shift( $hook );
176 throw new MWException(
'Unknown datatype in hooks for ' . $event .
"\n" );
181 if ( !is_callable( $callback ) ) {
182 throw new MWException(
'Invalid callback in hooks for ' . $event .
"\n" );
194 $hook_args = array_merge( $hook,
$args );
198 set_error_handler(
'Hooks::hookErrorHandler' );
201 if ( $deprecatedVersion !==
null ) {
202 wfDeprecated(
"$event hook (used in $func)", $deprecatedVersion );
206 $retval = call_user_func_array( $callback, $hook_args );
208 $badhookmsg =
$e->getMessage();
209 }
catch ( Exception
$e ) {
210 restore_error_handler();
213 restore_error_handler();
220 } elseif ( $badhookmsg !==
null ) {
223 'Detected bug in an extension! ' .
224 "Hook $func has invalid call signature; " . $badhookmsg
226 } elseif (
$retval ===
false ) {
251 if ( strpos( $errstr,
'expected to be a reference, value given' ) !==
false ) {
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
static getHandlers( $name)
Returns an array of all the event functions attached to a hook This combines functions registered via...
wfProfileIn( $functionname)
Begin profiling of a function.
static clear( $name)
Clears hooks registered via Hooks::register().
$wgHooks['ArticleShow'][]
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Throws a warning that $function is deprecated.
wfProfileOut( $functionname='missing')
Stop profiling of a function.
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
when a variable name is used in a it is silently declared as a new masking the global
Allows to change the fields on the form that will be generated $name
static run( $event, array $args=array(), $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.
static isRegistered( $name)
Returns true if a hook has a function registered to it.
Exception class which takes an HTML error message, and does not produce a backtrace.
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
please add to it if you re going to add events to the MediaWiki code where normally authentication against an external auth plugin would be creating a account incomplete not yet checked for validity & $retval
static hookErrorHandler( $errno, $errstr)
Handle PHP errors issued inside a hook.
static $handlers
Array of events mapped to an array of callbacks to be run when that event is triggered.