New 'UserResetAllOptions' hook from the wikiHow codebase.
authorJack Phoenix <jack@countervandalism.net>
Tue, 8 Jul 2014 13:14:27 +0000 (16:14 +0300)
committerJack Phoenix <jack@countervandalism.net>
Thu, 10 Jul 2014 21:39:16 +0000 (00:39 +0300)
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
includes/User.php

index b1ef47c..17f8c1c 100644 (file)
@@ -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).
index 5a117bd..c4ea1de 100644 (file)
@@ -2778,6 +2778,8 @@ class User implements IDBAccessObject {
                        }
                }
 
+               wfRunHooks( 'UserResetAllOptions', array( $this, &$newOptions, $this->mOptions, $resetKinds ) );
+
                $this->mOptions = $newOptions;
                $this->mOptionsLoaded = true;
        }