diff --git a/lib/classes/event/base.php b/lib/classes/event/base.php index 25ab52f5e8f..ff7ecb3d884 100644 --- a/lib/classes/event/base.php +++ b/lib/classes/event/base.php @@ -459,7 +459,7 @@ abstract class base implements \IteratorAggregate { $this->triggered = true; - if (!empty($CFG->loglifetime)) { + if (isset($CFG->loglifetime) and $CFG->loglifetime != -1) { if ($data = $this->get_legacy_logdata()) { call_user_func_array('add_to_log', $data); } diff --git a/lib/tests/event_test.php b/lib/tests/event_test.php index fca042f0010..052ed5e1583 100644 --- a/lib/tests/event_test.php +++ b/lib/tests/event_test.php @@ -29,6 +29,17 @@ require_once(__DIR__.'/fixtures/event_fixtures.php'); class core_event_testcase extends advanced_testcase { + protected function setUp() { + global $CFG; + // No need to always modify log table here. + $CFG->loglifetime = '-1'; + } + + protected function tearDown() { + global $CFG; + $CFG->loglifetime = '0'; + } + public function test_event_properties() { global $USER;