summaryrefslogtreecommitdiff
path: root/modules/dblog
diff options
context:
space:
mode:
Diffstat (limited to 'modules/dblog')
-rw-r--r--modules/dblog/dblog.module14
-rw-r--r--modules/dblog/dblog.test11
2 files changed, 18 insertions, 7 deletions
diff --git a/modules/dblog/dblog.module b/modules/dblog/dblog.module
index e272c75bf..1430d20cb 100644
--- a/modules/dblog/dblog.module
+++ b/modules/dblog/dblog.module
@@ -101,10 +101,18 @@ function dblog_cron() {
}
/**
- * Implementation of hook_user_delete().
+ * Implementation of hook_user_cancel().
*/
-function dblog_user_delete(&$edit, &$user) {
- db_query('UPDATE {watchdog} SET uid = 0 WHERE uid = %d', $user->uid);
+function dblog_user_cancel(&$edit, &$account, $method) {
+ switch ($method) {
+ case 'user_cancel_reassign':
+ db_update('watchdog')->fields(array('uid' => 0))->condition('uid', $account->uid)->execute();
+ break;
+
+ case 'user_cancel_delete':
+ db_delete('watchdog')->condition('uid', $account->uid)->execute();
+ break;
+ }
}
function _dblog_get_message_types() {
diff --git a/modules/dblog/dblog.test b/modules/dblog/dblog.test
index 902417387..e7b752b1e 100644
--- a/modules/dblog/dblog.test
+++ b/modules/dblog/dblog.test
@@ -165,7 +165,7 @@ class DBLogTestCase extends DrupalWebTestCase {
$this->doNode('page');
$this->doNode('poll');
- // When a user is deleted, any content they created remains but the
+ // When a user account is canceled, any content they created remains but the
// uid = 0. Their blog entry shows as "'s blog" on the home page. Records
// in the watchdog table related to that user have the uid set to zero.
}
@@ -202,8 +202,13 @@ class DBLogTestCase extends DrupalWebTestCase {
}
$count_before = (isset($ids)) ? count($ids) : 0;
$this->assertTrue($count_before > 0, t('DBLog contains @count records for @name', array('@count' => $count_before, '@name' => $user->name)));
+
+ // Login the admin user.
+ $this->drupalLogin($this->big_user);
// Delete user.
- user_delete(array(), $user->uid);
+ // We need to POST here to invoke batch_process() in the internal browser.
+ $this->drupalPost('user/' . $user->uid . '/cancel', array('user_cancel_method' => 'user_cancel_reassign'), t('Cancel account'));
+
// Count rows that have uids for the user.
$count = db_result(db_query('SELECT COUNT(wid) FROM {watchdog} WHERE uid = %d', $user->uid));
$this->assertTrue($count == 0, t('DBLog contains @count records for @name', array('@count' => $count, '@name' => $user->name)));
@@ -225,8 +230,6 @@ class DBLogTestCase extends DrupalWebTestCase {
}
$this->assertTrue(!isset($ids), t('DBLog contains no records for @name', array('@name' => $user->name)));
- // Login the admin user.
- $this->drupalLogin($this->big_user);
// View the dblog report.
$this->drupalGet('admin/reports/dblog');
$this->assertResponse(200);