MDL-39846 rename cached record to snapshot

This commit is contained in:
Petr Škoda 2013-07-13 11:00:30 +02:00
parent b0cdc969f7
commit 5fef139cd9
5 changed files with 11 additions and 11 deletions

View File

@ -1688,7 +1688,7 @@ function role_assign($roleid, $userid, $contextid, $component = '', $itemid = 0,
$event = \core\event\role_assigned::create(
array('context'=>$context, 'objectid'=>$ra->roleid, 'relateduserid'=>$ra->userid,
'other'=>array('id'=>$ra->id, 'component'=>$ra->component, 'itemid'=>$ra->itemid)));
$event->add_cached_record('role_assignments', $ra);
$event->add_record_snapshot('role_assignments', $ra);
$event->trigger();
return $ra->id;
@ -1776,7 +1776,7 @@ function role_unassign_all(array $params, $subcontexts = false, $includemanual =
$event = \core\event\role_unassigned::create(
array('context'=>$context, 'objectid'=>$ra->roleid, 'relateduserid'=>$ra->userid,
'other'=>array('id'=>$ra->id, 'component'=>$ra->component, 'itemid'=>$ra->itemid)));
$event->add_cached_record('role_assignments', $ra);
$event->add_record_snapshot('role_assignments', $ra);
$event->trigger();
}
}
@ -1807,7 +1807,7 @@ function role_unassign_all(array $params, $subcontexts = false, $includemanual =
$event = \core\event\role_unassigned::create(
array('context'=>$context, 'objectid'=>$ra->roleid, 'relateduserid'=>$ra->userid,
'other'=>array('id'=>$ra->id, 'component'=>$ra->component, 'itemid'=>$ra->itemid)));
$event->add_cached_record('role_assignments', $ra);
$event->add_record_snapshot('role_assignments', $ra);
$event->trigger();
}
}

View File

@ -484,7 +484,7 @@ abstract class base {
* @param string $tablename
* @param \stdClass $record
*/
public function add_cached_record($tablename, $record) {
public function add_record_snapshot($tablename, $record) {
global $DB;
// NOTE: this might use some kind of MUC cache,
@ -504,7 +504,7 @@ abstract class base {
* @param int $id
* @return \stdClass
*/
public function get_cached_record($tablename, $id) {
public function get_record_snapshot($tablename, $id) {
global $DB;
if (isset($this->cachedrecords[$tablename][$id])) {

View File

@ -74,6 +74,6 @@ class role_assigned extends base {
* @return mixed
*/
public function get_legacy_eventdata() {
return $this->get_cached_record('role_assignments', $this->data['other']['id']);
return $this->get_record_snapshot('role_assignments', $this->data['other']['id']);
}
}

View File

@ -74,6 +74,6 @@ class role_unassigned extends base {
* @return mixed
*/
public function get_legacy_eventdata() {
return $this->get_cached_record('role_assignments', $this->data['other']['id']);
return $this->get_record_snapshot('role_assignments', $this->data['other']['id']);
}
}

View File

@ -566,19 +566,19 @@ class core_event_testcase extends advanced_testcase {
$this->assertDebuggingCalled();
}
public function test_record_cache() {
public function test_record_snapshots() {
global $DB;
$event = \core_tests\event\unittest_executed::create(array('courseid'=>1, 'context'=>\context_system::instance(), 'other'=>array('sample'=>1, 'xx'=>10)));
$course1 = $DB->get_record('course', array('id'=>1));
$this->assertNotEmpty($course1);
$event->add_cached_record('course', $course1);
$event->add_record_snapshot('course', $course1);
$result = $event->get_cached_record('course', 1, $course1);
$result = $event->get_record_snapshot('course', 1, $course1);
$this->assertSame($course1, $result);
$user = $event->get_cached_record('user', 1);
$user = $event->get_record_snapshot('user', 1);
$this->assertEquals(1, $user->id);
$this->assertSame('guest', $user->username);
}