From 6cddec72137cd59c197a2b5eed9c42ee82a98813 Mon Sep 17 00:00:00 2001 From: Jack Phoenix Date: Tue, 8 Jul 2014 16:14:27 +0300 Subject: [PATCH] New 'UserResetAllOptions' hook from the wikiHow codebase. Location is a tad bit different now than on the wikiHow codebase and some arguments have been added, as per code review. Because sometimes you have things that are stored in the user_properties database table that should *not* be reset even when the user has requested to reset all prefs back to the site defaults. Live example of a thing using this hook (well, its previous iteration) is wikiHow's WikihowPreferences extension. Change-Id: I1da936c786adb21e2c1802ef405bb904c9cf4918 --- docs/hooks.txt | 9 +++++++++ includes/User.php | 2 ++ 2 files changed, 11 insertions(+) diff --git a/docs/hooks.txt b/docs/hooks.txt index b1ef47ca0d..17f8c1c66f 100644 --- a/docs/hooks.txt +++ b/docs/hooks.txt @@ -2896,6 +2896,15 @@ to be switched to HTTPS. $user: User in question. &$https: Boolean whether $user should be switched to HTTPS. +'UserResetAllOptions': Called in User::resetOptions() when user preferences +have been requested to be reset. This hook can be used to exclude certain +options from being reset even when the user has requested all prefs to be reset, +because certain options might be stored in the user_properties database table +despite not being visible and editable via Special:Preferences. +$user: the User (object) whose preferences are being reset +&$newOptions: array of new (site default) preferences +$options: array of the user's old preferences +$resetKinds: array containing the kinds of preferences to reset 'UserRetrieveNewTalks': Called when retrieving "You have new messages!" message(s). diff --git a/includes/User.php b/includes/User.php index 5a117bdde1..c4ea1de395 100644 --- a/includes/User.php +++ b/includes/User.php @@ -2778,6 +2778,8 @@ class User implements IDBAccessObject { } } + wfRunHooks( 'UserResetAllOptions', array( $this, &$newOptions, $this->mOptions, $resetKinds ) ); + $this->mOptions = $newOptions; $this->mOptionsLoaded = true; } -- 2.20.1