diff --git a/backup/util/dbops/backup_structure_dbops.class.php b/backup/util/dbops/backup_structure_dbops.class.php index 6202906e90e..4ceb221defc 100644 --- a/backup/util/dbops/backup_structure_dbops.class.php +++ b/backup/util/dbops/backup_structure_dbops.class.php @@ -103,7 +103,18 @@ abstract class backup_structure_dbops extends backup_dbops { } } - public static function annotate_files($backupid, $contextid, $component, $filearea, $itemid) { + /** + * Adds backup id database record for all files in the given file area. + * + * @param string $backupid Backup ID + * @param int $contextid Context id + * @param string $component Component + * @param string $filearea File area + * @param int $itemid Item id + * @param \core\progress\base $progress + */ + public static function annotate_files($backupid, $contextid, $component, $filearea, $itemid, + \core\progress\base $progress = null) { global $DB; $sql = 'SELECT id FROM {files} @@ -120,10 +131,19 @@ abstract class backup_structure_dbops extends backup_dbops { $sql .= ' AND itemid = ?'; $params[] = $itemid; } + if ($progress) { + $progress->start_progress(''); + } $rs = $DB->get_recordset_sql($sql, $params); foreach ($rs as $record) { + if ($progress) { + $progress->progress(); + } self::insert_backup_ids_record($backupid, 'file', $record->id); } + if ($progress) { + $progress->end_progress(); + } $rs->close(); } diff --git a/backup/util/structure/backup_structure_processor.class.php b/backup/util/structure/backup_structure_processor.class.php index 2cc41dca4b2..9085af0b442 100644 --- a/backup/util/structure/backup_structure_processor.class.php +++ b/backup/util/structure/backup_structure_processor.class.php @@ -86,7 +86,7 @@ class backup_structure_processor extends base_processor { foreach ($area as $filearea => $info) { $contextid = !is_null($info->contextid) ? $info->contextid : $this->get_var(backup::VAR_CONTEXTID); $itemid = !is_null($info->element) ? $info->element->get_value() : null; - backup_structure_dbops::annotate_files($backupid, $contextid, $component, $filearea, $itemid); + backup_structure_dbops::annotate_files($backupid, $contextid, $component, $filearea, $itemid, $this->progress); } } }