Report legacy hook handlers.
authordaniel <daniel.kinzler@wikimedia.de>
Tue, 9 Oct 2012 12:20:03 +0000 (14:20 +0200)
committerdaniel <daniel.kinzler@wikimedia.de>
Tue, 9 Oct 2012 12:20:03 +0000 (14:20 +0200)
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

index 6845255..00761cf 100644 (file)
@@ -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