mirror of
https://github.com/moodle/moodle.git
synced 2025-01-31 12:45:04 +01:00
MDL-12037 Backup Log - add new field to backup_log table to allow other backup related functions to save log data
This commit is contained in:
parent
3b348bbf4d
commit
bc7ec91a0d
@ -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 "</tr>";
|
||||
$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 "<tr>";
|
||||
|
@ -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');
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
|
@ -2101,7 +2101,8 @@
|
||||
<FIELD NAME="courseid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="id" NEXT="time"/>
|
||||
<FIELD NAME="time" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="courseid" NEXT="laststarttime"/>
|
||||
<FIELD NAME="laststarttime" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="time" NEXT="info"/>
|
||||
<FIELD NAME="info" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="laststarttime"/>
|
||||
<FIELD NAME="info" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="laststarttime" NEXT="backuptype"/>
|
||||
<FIELD NAME="backuptype" TYPE="char" LENGTH="50" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="info"/>
|
||||
</FIELDS>
|
||||
<KEYS>
|
||||
<KEY NAME="primary" TYPE="primary" FIELDS="id" NEXT="courseid"/>
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user