From: daniel Date: Tue, 9 Oct 2012 12:20:03 +0000 (+0200) Subject: Report legacy hook handlers. X-Git-Tag: 1.31.0-rc.0~22091^2 X-Git-Url: http://git.cyclocoop.org/%40spipnet%40?a=commitdiff_plain;h=25304cd1e1c47ac3122e9a5a764a7ad98c565c89;p=lhc%2Fweb%2Fwiklou.git Report legacy hook handlers. ContentHandler::runLegacyHooks() now includes the list of handlers registered for a legacy hook in the warning it produces. Change-Id: I48032b62d4be791f1dc71889051dd6211541ac50 --- diff --git a/includes/content/ContentHandler.php b/includes/content/ContentHandler.php index 6845255743..00761cfe1e 100644 --- a/includes/content/ContentHandler.php +++ b/includes/content/ContentHandler.php @@ -973,7 +973,40 @@ abstract class ContentHandler { } if ( $warn ) { - wfWarn( "Using obsolete hook $event via ContentHandler::runLegacyHooks()", 2 ); + // Log information about which handlers are registered for the legacy hook, + // so we can find and fix them. + + $handlers = Hooks::getHandlers( $event ); + $handlerInfo = array(); + + wfSuppressWarnings(); + + foreach ( $handlers as $handler ) { + $info = ''; + + if ( is_array( $handler ) ) { + if ( is_object( $handler[0] ) ) { + $info = get_class( $handler[0] ); + } else { + $info = $handler[0]; + } + + if ( isset( $handler[1] ) ) { + $info .= '::' . $handler[1]; + } + } else if ( is_object( $handler ) ) { + $info = get_class( $handler[0] ); + $info .= '::on' . $event; + } else { + $info = $handler; + } + + $handlerInfo[] = $info; + } + + wfRestoreWarnings(); + + wfWarn( "Using obsolete hook $event via ContentHandler::runLegacyHooks()! Handlers: " . implode(', ', $handlerInfo), 2 ); } // convert Content objects to text