From 25304cd1e1c47ac3122e9a5a764a7ad98c565c89 Mon Sep 17 00:00:00 2001 From: daniel Date: Tue, 9 Oct 2012 14:20:03 +0200 Subject: [PATCH] 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 --- includes/content/ContentHandler.php | 35 ++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) 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 -- 2.20.1