I am seeing some strange behavior regarding a wiki user's email address. When I set it to the empty string, either via PHP or MySQL, MediaWiki still seems to believe the old email address is still present. Any advice?
Background: We have a wiki extension that sets a user's email address if it's blank, attached to the hook UserLoginComplete. (It's intended for new users on their first login.) Basically:
// On login, make sure the user has a company email address: function setUserEmailAddressIfBlank($user) { if (!$user->getEmail()) { $user->setEmail($user->getName() . '@mycompany.com'); $user->confirmEmail(); $user->saveSettings(); } }
To test this function, I blanked the email address programmatically:
$user->setEmail(''); $user->confirmEmail(); $user->saveSettings();
Then I logged out and logged back in. My UserLoginComplete callback function ran, but... it failed the test of $user->getEmail() being empty. In fact, the value was still the old email address I just blanked.
Then I logged out and logged back in a second time. This time, $user->getEmail() was indeed empty and the rest of the function ran fine, setting the user's email address to username@company.com.
Can someone please explain:
1. Why the old email address was still present during the first logout & login? 2. What's the "right" way to set an email address programmatically, so this caching problem doesn't happen?
Thanks very much. DanB
I am seeing some strange behavior regarding a wiki user's email address.
I should also mention that this behavior is new in 1.18. In prior versions of MediaWiki, if I blanked the email address in the database via SQL Update statement, the first logout/login operation would restore it.
DanB
wikitech-l@lists.wikimedia.org