Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

MDL-25454: using the faster way to check if record exists in db

  • Loading branch information...
commit 5c6377900adcd6b8b0de640084528e55b8fed7a0 1 parent 0623443
@marinaglancy marinaglancy authored
Showing with 3 additions and 4 deletions.
  1. +3 −4 backup/util/helper/backup_cron_helper.class.php
View
7 backup/util/helper/backup_cron_helper.class.php
@@ -128,11 +128,10 @@ public static function run_automated_backup($rundirective = self::RUN_ON_SCHEDUL
// Skip backup of unavailable courses that have remained unmodified in a month
if (!$skipped && empty($course->visible) && ($now - $course->timemodified) > 31*24*60*60) { //Hidden + settings were unmodified last month
//Check log if there were any modifications to the course content
- $sql = "SELECT l.id FROM {log} l WHERE ".
- "l.course=:courseid AND l.time>:time AND ". $DB->sql_like('l.action', ':action', false, true, true);
+ $sqlwhere = "course=:courseid AND time>:time AND ". $DB->sql_like('action', ':action', false, true, true);
$params = array('courseid' => $course->id, 'time' => $now-31*24*60*60, 'action' => '%view%');
- $logs = $DB->get_records_sql($sql, $params, 0, 1);
- if (empty($logs)) {
+ $logexists = $DB->record_exists_select('log', $sqlwhere, $params);
+ if (!$logexists) {
$backupcourse->laststatus = backup_cron_automated_helper::BACKUP_STATUS_SKIPPED;
$backupcourse->nextstarttime = $nextstarttime;
$DB->update_record('backup_courses', $backupcourse);
Please sign in to comment.
Something went wrong with that request. Please try again.