MDL-48702 logs: switched retrieval to get_recordset_select()
This commit is contained in:
@@ -91,19 +91,24 @@ class store implements \tool_log\log\store, \core\log\sql_select_reader {
|
||||
// Replace the query with hardcoded mappings required for core.
|
||||
list($selectwhere, $params, $sort) = self::replace_sql_legacy($selectwhere, $params, $sort);
|
||||
|
||||
$events = array();
|
||||
$records = array();
|
||||
|
||||
try {
|
||||
$records = $DB->get_records_select('log', $selectwhere, $params, $sort, '*', $limitfrom, $limitnum);
|
||||
// A custom report + on the fly SQL rewriting = a possible exception.
|
||||
$records = $DB->get_recordset_select('log', $selectwhere, $params, $sort, '*', $limitfrom, $limitnum);
|
||||
} catch (\moodle_exception $ex) {
|
||||
debugging("error converting legacy event data " . $ex->getMessage() . $ex->debuginfo, DEBUG_DEVELOPER);
|
||||
return array();
|
||||
}
|
||||
|
||||
$events = array();
|
||||
|
||||
foreach ($records as $data) {
|
||||
$events[$data->id] = \logstore_legacy\event\legacy_logged::restore_legacy($data);
|
||||
}
|
||||
|
||||
$records->close();
|
||||
|
||||
return $events;
|
||||
}
|
||||
|
||||
|
||||
@@ -72,7 +72,7 @@ class store implements \tool_log\log\writer, \core\log\sql_internal_reader {
|
||||
$sort = self::tweak_sort_by_id($sort);
|
||||
|
||||
$events = array();
|
||||
$records = $DB->get_records_select('logstore_standard_log', $selectwhere, $params, $sort, '*', $limitfrom, $limitnum);
|
||||
$records = $DB->get_recordset_select('logstore_standard_log', $selectwhere, $params, $sort, '*', $limitfrom, $limitnum);
|
||||
|
||||
foreach ($records as $data) {
|
||||
$extra = array('origin' => $data->origin, 'ip' => $data->ip, 'realuserid' => $data->realuserid);
|
||||
@@ -94,6 +94,8 @@ class store implements \tool_log\log\writer, \core\log\sql_internal_reader {
|
||||
}
|
||||
}
|
||||
|
||||
$records->close();
|
||||
|
||||
return $events;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user