From 12d0bf448f7bb862c2d9e8e3c4a05d99ef44a97e Mon Sep 17 00:00:00 2001 From: Mark Nelson Date: Fri, 28 Mar 2014 16:38:29 -0700 Subject: [PATCH 1/2] MDL-44746 core_events: removed incorrect use of snapshot --- lib/classes/event/user_deleted.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/classes/event/user_deleted.php b/lib/classes/event/user_deleted.php index e04ee16975f..ef540fa11a1 100644 --- a/lib/classes/event/user_deleted.php +++ b/lib/classes/event/user_deleted.php @@ -58,8 +58,7 @@ class user_deleted extends base { * @return string */ public function get_description() { - $user = $this->get_record_snapshot('user', $this->data['objectid']); - return 'User profile deleted for userid ' . $user->id; + return 'User profile deleted for userid ' . $this->objectid; } /** From d27dadca87dc341191aa09c8d9a8bfcdac8fdc64 Mon Sep 17 00:00:00 2001 From: Mark Nelson Date: Fri, 28 Mar 2014 17:00:33 -0700 Subject: [PATCH 2/2] MDL-44746 core_events: minor changes to the user_deleted event --- lib/classes/event/user_deleted.php | 50 ++++++++++++++---------------- 1 file changed, 24 insertions(+), 26 deletions(-) diff --git a/lib/classes/event/user_deleted.php b/lib/classes/event/user_deleted.php index ef540fa11a1..609008414cb 100644 --- a/lib/classes/event/user_deleted.php +++ b/lib/classes/event/user_deleted.php @@ -58,7 +58,7 @@ class user_deleted extends base { * @return string */ public function get_description() { - return 'User profile deleted for userid ' . $this->objectid; + return 'User profile deleted for the user with the id ' . $this->objectid; } /** @@ -76,12 +76,13 @@ class user_deleted extends base { * @return \stdClass user data. */ protected function get_legacy_eventdata() { - $user = $this->get_record_snapshot('user', $this->data['objectid']); + $user = $this->get_record_snapshot('user', $this->objectid); $user->deleted = 0; - $user->username = $this->data['other']['username']; - $user->email = $this->data['other']['email']; - $user->idnumber = $this->data['other']['idnumber']; - $user->picture = $this->data['other']['picture']; + $user->username = $this->other['username']; + $user->email = $this->other['email']; + $user->idnumber = $this->other['idnumber']; + $user->picture = $this->other['picture']; + return $user; } @@ -91,8 +92,8 @@ class user_deleted extends base { * @return array */ protected function get_legacy_logdata() { - $user = $this->get_record_snapshot('user', $this->data['objectid']); - return array(SITEID, 'user', 'delete', "view.php?id=".$user->id, $user->firstname.' '.$user->lastname); + $user = $this->get_record_snapshot('user', $this->objectid); + return array(SITEID, 'user', 'delete', 'view.php?id=' . $user->id, $user->firstname . ' ' . $user->lastname); } /** @@ -102,29 +103,26 @@ class user_deleted extends base { * @return void */ protected function validate_data() { - global $CFG; + parent::validate_data(); - if ($CFG->debugdeveloper) { - parent::validate_data(); - if (!isset($this->other['username'])) { - throw new \coding_exception('username must be set in $other.'); - } + if (!isset($this->other['username'])) { + throw new \coding_exception('username must be set in $other.'); + } - if (!isset($this->other['email'])) { - throw new \coding_exception('email must be set in $other.'); - } + if (!isset($this->other['email'])) { + throw new \coding_exception('email must be set in $other.'); + } - if (!isset($this->other['idnumber'])) { - throw new \coding_exception('idnumber must be set in $other.'); - } + if (!isset($this->other['idnumber'])) { + throw new \coding_exception('idnumber must be set in $other.'); + } - if (!isset($this->other['picture'])) { - throw new \coding_exception('picture must be set in $other.'); - } + if (!isset($this->other['picture'])) { + throw new \coding_exception('picture must be set in $other.'); + } - if (!isset($this->other['mnethostid'])) { - throw new \coding_exception('mnethostid must be set in $other.'); - } + if (!isset($this->other['mnethostid'])) { + throw new \coding_exception('mnethostid must be set in $other.'); } } }