From: danmarsden Date: Tue, 3 Mar 2009 00:06:08 +0000 (+0000) Subject: MDL-12037 Backup Log - add new field to backup_log table to allow other backup relate... X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=bc7ec91a0da9c05b7b0fcdf9112f3599e7fb3927;p=moodle.git MDL-12037 Backup Log - add new field to backup_log table to allow other backup related functions to save log data --- diff --git a/admin/report/backups/index.php b/admin/report/backups/index.php index d380cbb6d7..ef93e70f0d 100644 --- a/admin/report/backups/index.php +++ b/admin/report/backups/index.php @@ -95,8 +95,8 @@ /// First, me get all the distinct backups for that course in backup_log $executions = $DB->get_records_sql("SELECT DISTINCT laststarttime,laststarttime FROM {backup_log} - WHERE courseid = ? - ORDER BY laststarttime DESC", array($courseid)); + WHERE courseid = ? AND backuptype = ? + ORDER BY laststarttime DESC", array($courseid,'scheduledbackup')); /// Iterate over backup executions if (!$executions) { @@ -111,8 +111,8 @@ echo ""; $logs = $DB->get_records_sql("SELECT * FROM {backup_log} - WHERE courseid = ? AND laststarttime = ? - ORDER BY id", array($courseid, $execution->laststarttime)); + WHERE courseid = ? AND laststarttime = ? AND backuptype = ? + ORDER BY id", array($courseid, $execution->laststarttime,'scheduledbackup')); if ($logs) { foreach ($logs as $log) { echo ""; diff --git a/backup/backup_scheduled.php b/backup/backup_scheduled.php index caa9f3436c..28d6e451e1 100644 --- a/backup/backup_scheduled.php +++ b/backup/backup_scheduled.php @@ -34,7 +34,7 @@ function schedule_backup_cron() { //for info in backup_logs to unlock status as necessary $timetosee = 1800; //Half an hour looking for activity $timeafter = time() - $timetosee; - $numofrec = $DB->count_records_select ("backup_log","time > ?", array($timeafter)); + $numofrec = $DB->count_records_select ("backup_log","time > ? AND backuptype = ?", array($timeafter, 'scheduledbackup')); if (!$numofrec) { $timetoseemin = $timetosee/60; mtrace(" No activity in last ".$timetoseemin." minutes. Unlocking status"); @@ -257,13 +257,7 @@ function schedule_backup_log($starttime,$courseid,$message) { global $DB; if ($starttime) { - $log = new object(); - $log->courseid = $courseid; - $log->time = time(); - $log->laststarttime = $starttime; - $log->info = $message; - - $DB->insert_record("backup_log", $log); + add_to_backup_log($starttime,$courseid,$message, 'scheduledbackup'); } } diff --git a/backup/lib.php b/backup/lib.php index 49ef5fe537..964f69cb6b 100644 --- a/backup/lib.php +++ b/backup/lib.php @@ -719,6 +719,16 @@ backup_add_static_preferences($preferences); return $preferences; } + function add_to_backup_log($starttime,$courseid,$message, $backuptype) { + global $DB; + $log = new object(); + $log->courseid = $courseid; + $log->time = time(); + $log->laststarttime = $starttime; + $log->info = $message; + $log->backuptype = $backuptype; + $DB->insert_record('backup_log', $log); + } ?> diff --git a/lib/db/install.xml b/lib/db/install.xml index ab65869d9e..803f59c072 100644 --- a/lib/db/install.xml +++ b/lib/db/install.xml @@ -2101,7 +2101,8 @@ - + + diff --git a/lib/db/upgrade.php b/lib/db/upgrade.php index f8ef3ecd5c..98bcd51973 100644 --- a/lib/db/upgrade.php +++ b/lib/db/upgrade.php @@ -1458,7 +1458,20 @@ WHERE gradeitemid IS NOT NULL AND grademax IS NOT NULL"); /// Main savepoint reached upgrade_main_savepoint($result, 2009021800); } + if ($result && $oldversion < 2009021801) { + /// Define field backuptype to be added to backup_log + $table = new XMLDBTable('backup_log'); + $field = new XMLDBField('backuptype'); + $field = new xmldb_field('backuptype', XMLDB_TYPE_CHAR, '50', null, XMLDB_NOTNULL, null, null, null, null, 'info'); + /// Conditionally Launch add field backuptype and set all old records as 'scheduledbackup' records. + if (!$dbman->field_exists($table, $field)) { + $dbman->add_field($table, $field); + $DB->execute("UPDATE {backup_log} SET backuptype='scheduledbackup'"); + } + /// Main savepoint reached + upgrade_main_savepoint($result, 2009021801); + } return $result; } diff --git a/version.php b/version.php index 396aac89bc..a8f59f2a76 100644 --- a/version.php +++ b/version.php @@ -6,7 +6,7 @@ // This is compared against the values stored in the database to determine // whether upgrades should be performed (see lib/db/*.php) - $version = 2009021800; // YYYYMMDD = date of the last version bump + $version = 2009021801; // YYYYMMDD = date of the last version bump // XX = daily increments $release = '2.0 dev (Build: 20090303)'; // Human-friendly version name