From 7012f6f5a97f14ce3aa1215761a8ddca07c75154 Mon Sep 17 00:00:00 2001 From: Matthias Mullie Date: Mon, 25 Aug 2014 16:44:52 +0200 Subject: [PATCH] Add new hook WatchlistEditorBeforeFormRender 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 | 2 ++ docs/hooks.txt | 5 +++++ includes/specials/SpecialEditWatchlist.php | 10 +++++++++- 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/RELEASE-NOTES-1.24 b/RELEASE-NOTES-1.24 index 09133f7460..c77e3066bd 100644 --- a/RELEASE-NOTES-1.24 +++ b/RELEASE-NOTES-1.24 @@ -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 diff --git a/docs/hooks.txt b/docs/hooks.txt index 106884b325..9af3460e9e 100644 --- a/docs/hooks.txt +++ b/docs/hooks.txt @@ -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 diff --git a/includes/specials/SpecialEditWatchlist.php b/includes/specials/SpecialEditWatchlist.php index 73438d9b85..2f82da218b 100644 --- a/includes/specials/SpecialEditWatchlist.php +++ b/includes/specials/SpecialEditWatchlist.php @@ -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 ) { -- 2.20.1