Skip to content

Commit

Permalink
Merge branch 'w05_MDL-43905_m26_loginevents' of git://github.com/skod…
Browse files Browse the repository at this point in the history
…ak/moodle into MOODLE_26_STABLE
  • Loading branch information
marinaglancy committed Feb 3, 2014
2 parents 18a28dd + 4d7f209 commit 79efe4f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 13 deletions.
6 changes: 2 additions & 4 deletions auth/ldap/tests/plugin_test.php
Expand Up @@ -268,10 +268,8 @@ public function test_ldap_user_loggedin_event() {
$sink->close();

// Check that the event is valid.
$this->assertCount(2, $events);
$event = $events[0];
$this->assertInstanceOf('\core\event\user_updated', $event);
$event = $events[1];
$this->assertCount(1, $events);
$event = reset($events);
$this->assertInstanceOf('\core\event\user_loggedin', $event);
$this->assertEquals('user', $event->objecttable);
$this->assertEquals('2', $event->objectid);
Expand Down
8 changes: 4 additions & 4 deletions lib/moodlelib.php
Expand Up @@ -3397,9 +3397,7 @@ function get_user_key($script, $userid, $instance=null, $iprestriction=null, $va
* @return bool Always returns true
*/
function update_user_login_times() {
global $USER, $DB, $CFG;

require_once($CFG->dirroot.'/user/lib.php');
global $USER, $DB;

if (isguestuser()) {
// Do not update guest access times/ips for performance.
Expand All @@ -3425,7 +3423,9 @@ function update_user_login_times() {
$USER->lastaccess = $user->lastaccess = $now;
$USER->lastip = $user->lastip = getremoteaddr();

user_update_user($user, false);
// Note: do not call user_update_user() here because this is part of the login process,
// the login event means that these fields were updated.
$DB->update_record('user', $user);
return true;
}

Expand Down
7 changes: 2 additions & 5 deletions lib/tests/moodlelib_test.php
Expand Up @@ -2474,10 +2474,8 @@ public function test_complete_user_login() {
$events = $sink->get_events();
$sink->close();

$this->assertCount(2, $events);
$event = $events[0];
$this->assertInstanceOf('\core\event\user_updated', $event);
$event = $events[1];
$this->assertCount(1, $events);
$event = reset($events);
$this->assertInstanceOf('\core\event\user_loggedin', $event);
$this->assertEquals('user', $event->objecttable);
$this->assertEquals($user->id, $event->objectid);
Expand All @@ -2491,7 +2489,6 @@ public function test_complete_user_login() {

$this->assertTimeCurrent($USER->firstaccess);
$this->assertTimeCurrent($USER->lastaccess);
$this->assertTimeCurrent($USER->timemodified);
$this->assertTimeCurrent($USER->currentlogin);
$this->assertSame(sesskey(), $USER->sesskey);
$this->assertTimeCurrent($USER->preference['_lastloaded']);
Expand Down

0 comments on commit 79efe4f

Please sign in to comment.