Fix bug 1962: deleteuser.php regression when OpenID plugin not enabled
The User_openid data object was explicitly listed as a related field to delete from in User::delete(); this class doesn't exist anymore by default since OpenID was broken out to a plugin. Added UserDeleteRelated event for plugins to add related tables to delete from at user delete time.
This commit is contained in:
parent
5c428f8adf
commit
8d44b6a5a2
|
@ -489,3 +489,6 @@ ChangePassword: Handle a password change request
|
||||||
- $newpassword: the desired new password
|
- $newpassword: the desired new password
|
||||||
- &$errormsg: set this to an error message if the password could not be changed. If the password was changed, leave this as false
|
- &$errormsg: set this to an error message if the password could not be changed. If the password was changed, leave this as false
|
||||||
|
|
||||||
|
UserDeleteRelated: Specify additional tables to delete entries from when deleting users
|
||||||
|
- $user: User object
|
||||||
|
- &$related: array of DB_DataObject class names to delete entries on matching user_id.
|
||||||
|
|
|
@ -719,16 +719,18 @@ class User extends Memcached_DataObject
|
||||||
function delete()
|
function delete()
|
||||||
{
|
{
|
||||||
$profile = $this->getProfile();
|
$profile = $this->getProfile();
|
||||||
$profile->delete();
|
if ($profile) {
|
||||||
|
$profile->delete();
|
||||||
|
}
|
||||||
|
|
||||||
$related = array('Fave',
|
$related = array('Fave',
|
||||||
'User_openid',
|
|
||||||
'Confirm_address',
|
'Confirm_address',
|
||||||
'Remember_me',
|
'Remember_me',
|
||||||
'Foreign_link',
|
'Foreign_link',
|
||||||
'Invitation',
|
'Invitation',
|
||||||
'Notice_inbox',
|
'Notice_inbox',
|
||||||
);
|
);
|
||||||
|
Event::handle('UserDeleteRelated', array($this, &$related));
|
||||||
|
|
||||||
foreach ($related as $cls) {
|
foreach ($related as $cls) {
|
||||||
$inst = new $cls();
|
$inst = new $cls();
|
||||||
|
|
|
@ -298,4 +298,10 @@ class OpenIDPlugin extends Plugin
|
||||||
new ColumnDef('modified', 'timestamp')));
|
new ColumnDef('modified', 'timestamp')));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function onUserDeleteRelated($user, &$tables)
|
||||||
|
{
|
||||||
|
$tables[] = 'User_openid';
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user