Add new hook WatchlistEditorBeforeFormRender
authorMatthias Mullie <git@mullie.eu>
Mon, 25 Aug 2014 14:44:52 +0000 (16:44 +0200)
committerMatthias Mullie <git@mullie.eu>
Mon, 25 Aug 2014 14:44:52 +0000 (16:44 +0200)
This will allow subscribers to batch-load everything they
need beforehand, instead of loading everything piecemeal
on a per-line basis when WatchlistEditorBuildRemoveLine
is called.

Change-Id: I362e25b585921d755d6564955ac685971386f29b

RELEASE-NOTES-1.24
docs/hooks.txt
includes/specials/SpecialEditWatchlist.php

index 09133f7..c77e306 100644 (file)
@@ -67,6 +67,8 @@ production.
   instead.
 
 === New features in 1.24 ===
+* Added new hook WatchlistEditorBeforeFormRender, allowing subscribers to
+  manipulate the list of pages and/or preload lots of data at once.
 * Added new argument &$link in hook WatchlistEditorBuildRemoveLine, allowing the
   link to the title to be changed.
 * Added a new hook, "WhatLinksHereProps", to allow extensions to annotate
index 106884b..9af3460 100644 (file)
@@ -2938,6 +2938,11 @@ $page: WikiPage object to be watched
 $user: user that watched
 $page: WikiPage object watched
 
+'WatchlistEditorBeforeFormRender': Before building the Special:EditWatchlist
+form, used to manipulate the list of pages or preload data based on that list.
+&$watchlistInfo: array of watchlisted pages in
+  [namespaceId => ['title1' => 1, 'title2' => 1]] format
+
 'WatchlistEditorBuildRemoveLine': when building remove lines in
 Special:Watchlist/edit.
 &$tools: array of extra links
index 73438d9..2f82da2 100644 (file)
@@ -553,7 +553,15 @@ class SpecialEditWatchlist extends UnlistedSpecialPage {
                $fields = array();
                $count = 0;
 
-               foreach ( $this->getWatchlistInfo() as $namespace => $pages ) {
+               // Allow subscribers to manipulate the list of watched pages (or use it
+               // to preload lots of details at once)
+               $watchlistInfo = $this->getWatchlistInfo();
+               wfRunHooks(
+                       'WatchlistEditorBeforeFormRender',
+                       array( &$watchlistInfo )
+               );
+
+               foreach ( $watchlistInfo as $namespace => $pages ) {
                        $options = array();
 
                        foreach ( array_keys( $pages ) as $dbkey ) {