Skip to content

Commit 1c97c77

Browse files
Matt Porrittmdjnelson
authored andcommitted
MDL-65858 backup: Improve behaviour of ajax calls
When a backup (or restore) is in progress and the user has another tab open that is taking time to generate and holding the session lock, a condition arises where multiple ajax calls are "queued" because the long page is holding the session lock. When this lock is released, the queued ajax requests complete. However, as the ajax requests also lock this can block other requests until they complete. This patch decreases the frequency of ajax calls and stops them from holding the session lock.
1 parent 39ef515 commit 1c97c77

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

backup/externallib.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ public static function get_async_backup_progress($backupids, $contextid) {
7171
require_once($CFG->dirroot . '/backup/util/includes/backup_includes.php');
7272
require_once($CFG->dirroot . '/backup/util/includes/restore_includes.php');
7373

74+
// Release session lock.
75+
\core\session\manager::write_close();
76+
7477
// Parameter validation.
7578
self::validate_parameters(
7679
self::get_async_backup_progress_parameters(),
@@ -142,6 +145,9 @@ public static function get_async_backup_links_backup_parameters() {
142145
* @since Moodle 3.7
143146
*/
144147
public static function get_async_backup_links_backup($filename, $contextid) {
148+
// Release session lock.
149+
\core\session\manager::write_close();
150+
145151
// Parameter validation.
146152
self::validate_parameters(
147153
self::get_async_backup_links_backup_parameters(),
@@ -206,6 +212,9 @@ public static function get_async_backup_links_restore_parameters() {
206212
* @since Moodle 3.7
207213
*/
208214
public static function get_async_backup_links_restore($backupid, $contextid) {
215+
// Release session lock.
216+
\core\session\manager::write_close();
217+
209218
// Parameter validation.
210219
self::validate_parameters(
211220
self::get_async_backup_links_restore_parameters(),

backup/util/ui/amd/build/async_backup.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

backup/util/ui/amd/src/async_backup.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ define(['jquery', 'core/ajax', 'core/str', 'core/notification', 'core/templates'
3939
* Module level variables.
4040
*/
4141
var Asyncbackup = {};
42-
var checkdelay = 5000; // How often we check for progress updates.
42+
var checkdelay = 15000; // How often we check for progress updates.
4343
var backupid; // The backup id to get the progress for.
4444
var contextid; // The course this backup progress is for.
4545
var restoreurl; // The URL to view course restores.

0 commit comments

Comments
 (0)