Skip to content

Commit

Permalink
MDL-52805 core: Remove legacy log calls
Browse files Browse the repository at this point in the history
  • Loading branch information
Chocolate-lightning committed Mar 7, 2023
1 parent fce2e17 commit e5ca776
Show file tree
Hide file tree
Showing 296 changed files with 2 additions and 4,382 deletions.
4 changes: 0 additions & 4 deletions admin/tool/admin_presets/classes/event/preset_deleted.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,6 @@ public function get_description(): string {
return "User {$this->userid} has deleted the preset with id {$this->objectid}.";
}

public function get_legacy_logdata(): array {
return [$this->courseid, 'tool_admin_presets', 'delete', '', $this->objectid, $this->contextinstanceid];
}

protected function init(): void {
$this->data['crud'] = 'd';
$this->data['edulevel'] = self::LEVEL_OTHER;
Expand Down
4 changes: 0 additions & 4 deletions admin/tool/admin_presets/classes/event/preset_exported.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,6 @@ public function get_url(): \moodle_url {
['action' => 'load', 'mode' => 'preview', 'id' => $this->objectid]);
}

public function get_legacy_logdata(): array {
return [$this->courseid, 'tool_admin_presets', 'export', '', $this->objectid, $this->contextinstanceid];
}

protected function init(): void {
$this->data['crud'] = 'c';
$this->data['edulevel'] = self::LEVEL_OTHER;
Expand Down
4 changes: 0 additions & 4 deletions admin/tool/admin_presets/classes/event/preset_imported.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,6 @@ public function get_url(): \moodle_url {
['action' => 'load', 'mode' => 'preview', 'id' => $this->objectid]);
}

public function get_legacy_logdata(): array {
return [$this->courseid, 'tool_admin_presets', 'import', '', $this->objectid, $this->contextinstanceid];
}

protected function init(): void {
$this->data['crud'] = 'c';
$this->data['edulevel'] = self::LEVEL_OTHER;
Expand Down
4 changes: 0 additions & 4 deletions admin/tool/admin_presets/classes/event/preset_loaded.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,6 @@ public function get_url(): \moodle_url {
['action' => 'load', 'mode' => 'preview', 'id' => $this->objectid]);
}

public function get_legacy_logdata(): array {
return [$this->courseid, 'tool_admin_presets', 'load', '', $this->objectid, $this->contextinstanceid];
}

protected function init(): void {
$this->data['crud'] = 'u';
$this->data['edulevel'] = self::LEVEL_OTHER;
Expand Down
4 changes: 0 additions & 4 deletions admin/tool/admin_presets/classes/event/preset_reverted.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,6 @@ public function get_description(): string {
return "User {$this->userid} has reverted the preset with id {$this->objectid}.";
}

public function get_legacy_logdata(): array {
return [$this->courseid, 'tool_admin_presets', 'rollback', '', $this->objectid, $this->contextinstanceid];
}

protected function init(): void {
$this->data['crud'] = 'u';
$this->data['edulevel'] = self::LEVEL_OTHER;
Expand Down
4 changes: 0 additions & 4 deletions admin/tool/admin_presets/classes/event/presets_listed.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,6 @@ public function get_url(): \moodle_url {
return new \moodle_url('/admin/tool/admin_presets/index.php');
}

public function get_legacy_logdata(): array {
return [$this->courseid, 'tool_admin_presets', 'base', '', $this->objectid, $this->contextinstanceid];
}

protected function init(): void {
$this->data['crud'] = 'r';
$this->data['edulevel'] = self::LEVEL_OTHER;
Expand Down
2 changes: 0 additions & 2 deletions admin/tool/admin_presets/tests/event/preset_deleted_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,5 @@ public function test_preset_deleted_event() {
$this->assertInstanceOf('\tool_admin_presets\event\preset_deleted', $event);
$this->assertEquals(\context_system::instance(), $event->get_context());
$this->assertEquals($presetid, $event->objectid);
$expected = [0, 'tool_admin_presets', 'delete', '', $presetid, 0];
$this->assertEventLegacyLogData($expected, $event);
}
}
2 changes: 0 additions & 2 deletions admin/tool/admin_presets/tests/event/preset_exported_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,5 @@ public function test_preset_exported_event() {
$this->assertInstanceOf('\tool_admin_presets\event\preset_exported', $event);
$this->assertEquals(\context_system::instance(), $event->get_context());
$this->assertEquals($presetid, $event->objectid);
$expected = [0, 'tool_admin_presets', 'export', '', $presetid, 0];
$this->assertEventLegacyLogData($expected, $event);
}
}
2 changes: 0 additions & 2 deletions admin/tool/admin_presets/tests/event/preset_imported_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,5 @@ public function test_preset_imported_event() {
$this->assertInstanceOf('\tool_admin_presets\event\preset_imported', $event);
$this->assertEquals(\context_system::instance(), $event->get_context());
$this->assertEquals($presetid, $event->objectid);
$expected = [0, 'tool_admin_presets', 'import', '', $presetid, 0];
$this->assertEventLegacyLogData($expected, $event);
}
}
2 changes: 0 additions & 2 deletions admin/tool/admin_presets/tests/event/preset_loaded_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,5 @@ public function test_preset_loaded_event() {
$this->assertInstanceOf('\tool_admin_presets\event\preset_loaded', $event);
$this->assertEquals(\context_system::instance(), $event->get_context());
$this->assertEquals($presetid, $event->objectid);
$expected = [0, 'tool_admin_presets', 'load', '', $presetid, 0];
$this->assertEventLegacyLogData($expected, $event);
}
}
2 changes: 0 additions & 2 deletions admin/tool/admin_presets/tests/event/preset_reverted_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,5 @@ public function test_preset_reverted_event() {
$this->assertInstanceOf('\tool_admin_presets\event\preset_reverted', $event);
$this->assertEquals(\context_system::instance(), $event->get_context());
$this->assertEquals($presetid, $event->objectid);
$expected = [0, 'tool_admin_presets', 'rollback', '', $presetid, 0];
$this->assertEventLegacyLogData($expected, $event);
}
}
2 changes: 0 additions & 2 deletions admin/tool/admin_presets/tests/event/presets_listed_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,5 @@ public function test_presets_listed_event() {
$this->assertInstanceOf('\tool_admin_presets\event\presets_listed', $event);
$this->assertEquals(\context_system::instance(), $event->get_context());
$this->assertEquals($presetid, $event->objectid);
$expected = [0, 'tool_admin_presets', 'base', '', $presetid, 0];
$this->assertEventLegacyLogData($expected, $event);
}
}
9 changes: 0 additions & 9 deletions admin/tool/capability/classes/event/report_viewed.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,6 @@ public function get_description() {
return "The user with id '$this->userid' viewed the capability overview report.";
}

/**
* Return the legacy event log data.
*
* @return array
*/
protected function get_legacy_logdata() {
return array(SITEID, 'admin', 'tool capability', 'tool/capability/index.php');
}

/**
* Returns relevant URL.
*
Expand Down
2 changes: 0 additions & 2 deletions admin/tool/capability/tests/event/events_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,6 @@ public function test_report_viewed() {

$this->assertInstanceOf('\tool_capability\event\report_viewed', $event);
$this->assertEquals(\context_system::instance(), $event->get_context());
$expected = array(SITEID, "admin", "tool capability", "tool/capability/index.php");
$this->assertEventLegacyLogData($expected, $event);
$this->assertEventContextNotUsed($event);
$url = new \moodle_url('/admin/tool/capability/index.php');
$this->assertEquals($url, $event->get_url());
Expand Down
17 changes: 0 additions & 17 deletions admin/tool/log/store/legacy/tests/fixtures/event.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,21 +44,4 @@ protected function init() {
public function get_url() {
return new \moodle_url('/somepath/somefile.php', array('id' => $this->data['other']['sample']));
}

public static function get_legacy_eventname() {
return 'test_legacy';
}

protected function get_legacy_eventdata() {
return array($this->data['courseid'], $this->data['other']['sample']);
}

protected function get_legacy_logdata() {
$cmid = 0;
if ($this->contextlevel == CONTEXT_MODULE) {
$cmid = $this->contextinstanceid;
}
return array($this->data['courseid'], 'core_unittest', 'view',
'unittest.php?id=' . $this->data['other']['sample'], 'bbb', $cmid);
}
}
6 changes: 0 additions & 6 deletions auth/ldap/tests/plugin_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -379,9 +379,6 @@ public function test_ldap_user_loggedin_event() {
$this->assertEquals('user', $event->objecttable);
$this->assertEquals('2', $event->objectid);
$this->assertEquals(\context_system::instance()->id, $event->contextid);
$expectedlog = array(SITEID, 'user', 'login', 'view.php?id=' . $USER->id . '&course=' . SITEID, $user->id,
0, $user->id);
$this->assertEventLegacyLogData($expectedlog, $event);
}

/**
Expand Down Expand Up @@ -508,10 +505,7 @@ public function test_ldap_user_signup() {
$event = array_pop($events);
$this->assertInstanceOf('\core\event\user_created', $event);
$this->assertEquals($user['id'], $event->objectid);
$this->assertEquals('user_created', $event->get_legacy_eventname());
$this->assertEquals(\context_user::instance($user['id']), $event->get_context());
$expectedlogdata = array(SITEID, 'user', 'add', '/view.php?id='.$event->objectid, fullname($dbuser));
$this->assertEventLegacyLogData($expectedlogdata, $event);

// First event is user_password_updated.
$event = array_pop($events);
Expand Down
22 changes: 0 additions & 22 deletions blog/tests/event/events_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,6 @@ public function test_blog_entry_created_event() {
$this->assertEquals($USER->id, $event->userid);
$this->assertEquals($this->userid, $event->relateduserid);
$this->assertEquals("post", $event->objecttable);
$arr = array(SITEID, 'blog', 'add', 'index.php?userid=' . $this->userid . '&entryid=' . $blog->id, $blog->subject);
$this->assertEventLegacyLogData($arr, $event);
$this->assertEquals("blog_entry_added", $event->get_legacy_eventname());
$this->assertEventLegacyData($blog, $event);
$this->assertEventContextNotUsed($event);
}

Expand Down Expand Up @@ -172,10 +168,6 @@ public function test_blog_entry_updated_event() {
$this->assertEquals($USER->id, $event->userid);
$this->assertEquals($this->userid, $event->relateduserid);
$this->assertEquals("post", $event->objecttable);
$this->assertEquals("blog_entry_edited", $event->get_legacy_eventname());
$this->assertEventLegacyData($blog, $event);
$arr = array (SITEID, 'blog', 'update', 'index.php?userid=' . $this->userid . '&entryid=' . $blog->id, $blog->subject);
$this->assertEventLegacyLogData($arr, $event);
$this->assertEventContextNotUsed($event);
}

Expand Down Expand Up @@ -207,11 +199,6 @@ public function test_blog_entry_deleted_event() {
$this->assertEquals($this->userid, $event->relateduserid);
$this->assertEquals("post", $event->objecttable);
$this->assertEquals($record, $event->get_record_snapshot("post", $blog->id));
$this->assertSame('blog_entry_deleted', $event->get_legacy_eventname());
$arr = array(SITEID, 'blog', 'delete', 'index.php?userid=' . $blog->userid, 'deleted blog entry with entry id# ' .
$blog->id);
$this->assertEventLegacyLogData($arr, $event);
$this->assertEventLegacyData($blog, $event);
$this->assertEventContextNotUsed($event);
}

Expand Down Expand Up @@ -292,9 +279,6 @@ public function test_blog_association_created_event() {
$this->assertEquals($USER->id, $event->userid);
$this->assertEquals($this->userid, $event->relateduserid);
$this->assertEquals('blog_association', $event->objecttable);
$arr = array(SITEID, 'blog', 'add association', 'index.php?userid=' . $this->userid . '&entryid=' . $blog->id,
$blog->subject, 0, $this->userid);
$this->assertEventLegacyLogData($arr, $event);

// Add blog associations with a module.
$blog = new \blog_entry($this->postid);
Expand All @@ -308,9 +292,6 @@ public function test_blog_association_created_event() {
$this->assertEquals($blog->id, $event->other['blogid']);
$this->assertEquals($this->cmid, $event->other['associateid']);
$this->assertEquals('coursemodule', $event->other['associatetype']);
$arr = array(SITEID, 'blog', 'add association', 'index.php?userid=' . $this->userid . '&entryid=' . $blog->id,
$blog->subject, $this->cmid, $this->userid);
$this->assertEventLegacyLogData($arr, $event);
$this->assertEventContextNotUsed($event);
}

Expand Down Expand Up @@ -393,10 +374,7 @@ public function test_blog_entries_viewed_event() {

// Validate event data.
$url = new \moodle_url('/blog/index.php', $other);
$url2 = new \moodle_url('index.php', $other);
$this->assertEquals($url, $event->get_url());
$arr = array(SITEID, 'blog', 'view', $url2->out(), 'view blog entry');
$this->assertEventLegacyLogData($arr, $event);
$this->assertEventContextNotUsed($event);
}

Expand Down
6 changes: 0 additions & 6 deletions calendar/tests/event/events_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,8 @@ public function test_calendar_event_created() {
$this->assertEquals('event', $event->objecttable);
$this->assertEquals(0, $event->courseid);
$this->assertEquals($calevent->context, $event->get_context());
$expectedlog = array(0, 'calendar', 'add', 'event.php?action=edit&id=' . $calevent->id , $calevent->name);
$other = array('repeatid' => 0, 'timestart' => $time, 'name' => 'event');
$this->assertEquals($other, $event->other);
$this->assertEventLegacyLogData($expectedlog, $event);
$this->assertEventContextNotUsed($event);

// Now we create a repeated course event.
Expand Down Expand Up @@ -194,8 +192,6 @@ public function test_calendar_event_updated() {
$this->assertEquals('event', $event->objecttable);
$this->assertEquals(0, $event->courseid);
$this->assertEquals($calevent->context, $event->get_context());
$expectedlog = array(0, 'calendar', 'edit', 'event.php?action=edit&id=' . $calevent->id , $calevent->name);
$this->assertEventLegacyLogData($expectedlog, $event);
$other = array('repeatid' => 0, 'timestart' => $time, 'name' => 'new event');
$this->assertEquals($other, $event->other);
$this->assertEventContextNotUsed($event);
Expand Down Expand Up @@ -249,8 +245,6 @@ public function test_calendar_event_updated_toggle_visibility() {
$this->assertEquals('event', $event->objecttable);
$this->assertEquals($siteid, $event->courseid);
$this->assertEquals($calevent->context, $event->get_context());
$expectedlog = [$siteid, 'calendar', 'edit', 'event.php?action=edit&id=' . $calevent->id , $calevent->name];
$this->assertEventLegacyLogData($expectedlog, $event);
$other = array('repeatid' => 0, 'timestart' => $time, 'name' => 'Some wickedly awesome event yo!');
$this->assertEquals($other, $event->other);
$this->assertEventContextNotUsed($event);
Expand Down
5 changes: 0 additions & 5 deletions cohort/tests/lib_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ public function test_cohort_add_cohort_event() {
$url = new \moodle_url('/cohort/index.php', array('contextid' => $event->contextid));
$this->assertEquals($url, $event->get_url());
$this->assertEquals($cohort, $event->get_record_snapshot('cohort', $id));
$this->assertEventLegacyData($cohort, $event);
$this->assertEventContextNotUsed($event);
}

Expand Down Expand Up @@ -179,7 +178,6 @@ public function test_cohort_update_cohort_event() {
$url = new \moodle_url('/cohort/edit.php', array('id' => $event->objectid));
$this->assertEquals($url, $event->get_url());
$this->assertEquals($cohort, $event->get_record_snapshot('cohort', $id));
$this->assertEventLegacyData($cohort, $event);
$this->assertEventContextNotUsed($event);
}

Expand Down Expand Up @@ -219,7 +217,6 @@ public function test_cohort_delete_cohort_event() {
$url = new \moodle_url('/cohort/index.php', array('contextid' => $event->contextid));
$this->assertEquals($url, $event->get_url());
$this->assertEquals($cohort, $event->get_record_snapshot('cohort', $cohort->id));
$this->assertEventLegacyData($cohort, $event);
$this->assertEventContextNotUsed($event);
}

Expand Down Expand Up @@ -279,7 +276,6 @@ public function test_cohort_add_member_event() {
$this->assertEquals($USER->id, $event->userid);
$url = new \moodle_url('/cohort/assign.php', array('id' => $event->objectid));
$this->assertEquals($url, $event->get_url());
$this->assertEventLegacyData((object) array('cohortid' => $cohort->id, 'userid' => $user->id), $event);
$this->assertEventContextNotUsed($event);
}

Expand Down Expand Up @@ -325,7 +321,6 @@ public function test_cohort_remove_member_event() {
$this->assertEquals($USER->id, $event->userid);
$url = new \moodle_url('/cohort/assign.php', array('id' => $event->objectid));
$this->assertEquals($url, $event->get_url());
$this->assertEventLegacyData((object) array('cohortid' => $cohort->id, 'userid' => $user->id), $event);
$this->assertEventContextNotUsed($event);
}

Expand Down
7 changes: 0 additions & 7 deletions course/classes/category.php
Original file line number Diff line number Diff line change
Expand Up @@ -2179,8 +2179,6 @@ public function delete_move($newparentid, $showfeedback = false) {
'objectid' => $childcat->id,
'context' => $childcat->get_context()
));
$event->set_legacy_logdata(array(SITEID, 'category', 'move', 'editcategory.php?id=' . $childcat->id,
$childcat->id));
$event->trigger();
}
fix_course_sortorder();
Expand Down Expand Up @@ -2371,7 +2369,6 @@ public function change_parent($newparentcat) {
'objectid' => $this->id,
'context' => $this->get_context()
));
$event->set_legacy_logdata(array(SITEID, 'category', 'move', 'editcategory.php?id=' . $this->id, $this->id));
$event->trigger();
}
}
Expand Down Expand Up @@ -2443,7 +2440,6 @@ public function hide() {
'objectid' => $this->id,
'context' => $this->get_context()
));
$event->set_legacy_logdata(array(SITEID, 'category', 'hide', 'editcategory.php?id=' . $this->id, $this->id));
$event->trigger();
}
}
Expand Down Expand Up @@ -2502,7 +2498,6 @@ public function show() {
'objectid' => $this->id,
'context' => $this->get_context()
));
$event->set_legacy_logdata(array(SITEID, 'category', 'show', 'editcategory.php?id=' . $this->id, $this->id));
$event->trigger();
}
}
Expand Down Expand Up @@ -3066,8 +3061,6 @@ public function change_sortorder_by_one($up) {
'objectid' => $this->id,
'context' => $this->get_context()
));
$event->set_legacy_logdata(array(SITEID, 'category', 'move', 'management.php?categoryid=' . $this->id,
$this->id));
$event->trigger();

// Finally reorder courses.
Expand Down
2 changes: 0 additions & 2 deletions course/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -2024,7 +2024,6 @@ function move_courses($courseids, $categoryid) {
'fullname' => $dbcourse->fullname,
'updatedfields' => array('category' => $category->id))
));
$event->set_legacy_logdata(array($course->id, 'course', 'move', 'edit.php?id=' . $course->id, $course->id));
$event->trigger();
}
fix_course_sortorder();
Expand Down Expand Up @@ -2490,7 +2489,6 @@ function update_course($data, $editoroptions = NULL) {
'updatedfields' => $updatedfields)
));

$event->set_legacy_logdata(array($course->id, 'course', 'update', 'edit.php?id=' . $course->id, $course->id));
$event->trigger();

if ($oldcourse->format !== $course->format) {
Expand Down
1 change: 0 additions & 1 deletion course/resources.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@

// Triger view event.
$event = \core\event\course_resources_list_viewed::create(array('context' => context_course::instance($course->id)));
$event->set_legacy_logdata($availableresources);
$event->add_record_snapshot('course', $course);
$event->trigger();

Expand Down
Loading

0 comments on commit e5ca776

Please sign in to comment.