Adds the SidebarBeforeOutput hook
authorTpt <thomaspt@hotmail.fr>
Fri, 9 May 2014 11:57:16 +0000 (13:57 +0200)
committerTpt <thomaspt@hotmail.fr>
Sat, 10 May 2014 15:38:23 +0000 (17:38 +0200)
Allows to modify sidebar abstract representation just before its output

Required by change Ib4014253016db1c3d6b624be9ebbdaf452115145

Change-Id: I170e7253825c8dab5cad38e6b0ba59f28572efbf

RELEASE-NOTES-1.24
docs/hooks.txt
includes/Skin.php

index 189c5f1..3b7583b 100644 (file)
@@ -19,6 +19,8 @@ production.
 * HTMLForm now supports multiple copies of an input field or set of input
   fields, e.g. the form may request "one or more usernames" without having to
   have the user enter delimited list of names into a text field.
+* Added a new hook, "SidebarBeforeOutput", to allow to edit the structure of
+  the sidebar just before its display.
 
 === Bug fixes in 1.24 ===
 * (bug 62258) A bug was fixed in File::getUnscaledThumb when a height
index 688e0cd..333f878 100644 (file)
@@ -2226,6 +2226,12 @@ $skin: Skin object
 &$bar: Sidebar contents
 Modify $bar to add or modify sidebar portlets.
 
+'SidebarBeforeOutput': Allows to edit sidebar just before its output by skins.
+$skin Skin object
+&$bar: Sidebar content
+Modify $bar to add or modify sidebar portlets.
+Warning: This hook is run on each display. You should consider to use 'SkinBuildSidebar' that is aggressively cached.
+
 'SkinCopyrightFooter': Allow for site and per-namespace customization of
 copyright notice.
 $title: displayed page title
index 8300da7..cfa059e 100644 (file)
@@ -1244,6 +1244,8 @@ abstract class Skin extends ContextSource {
                if ( $wgEnableSidebarCache ) {
                        $cachedsidebar = $wgMemc->get( $key );
                        if ( $cachedsidebar ) {
+                               wfRunHooks( 'SidebarBeforeOutput', array( $this, &$cachedsidebar ) );
+
                                wfProfileOut( __METHOD__ );
                                return $cachedsidebar;
                        }
@@ -1257,6 +1259,8 @@ abstract class Skin extends ContextSource {
                        $wgMemc->set( $key, $bar, $wgSidebarCacheExpiry );
                }
 
+               wfRunHooks( 'SidebarBeforeOutput', array( $this, &$bar ) );
+
                wfProfileOut( __METHOD__ );
                return $bar;
        }