Fix condition where if an asynchronous backup
completes via the UI and the user refreshes the
page a new backup was created with a mismatched
backup id.
This caused a permanently failing ad-hoc task
and blocked further backups for that course.
This lets plugins other than activity modules backup and restore
question attempt data.
The old backup_questions_activity_structure_step and
restore_questions_activity_structure_step base classes still exist
and work exactly the same way they did before (because they use the
trait) so this change is completely backwards compatible.
To make this work fully, a few other things in the code had to be tweaked:
* Adding restore path elements had to consider the possibility of grouped
parents in more places.
* I needed to add protected get_task() to the restore_plugin class.
I don't think that is a problem.
* In the restore trait, the process_question_... methods needed to be
changed to public for some reasons to do with PHP traits that I don't
fully understand. However, I don't think this change is a problem.
* The way question_usage restore got the new contextid had to be changed
(or it did not work in activity contexts), but the new code looks like
a better way to do it anyway so that is good.
Allow both UI and automated backups to be created without
including files. Instead include only file references.
This is essentially implementing "SAMESITE" to backup files
instead of only for import and export functionality.
A new backup setting to include files (defaults to yes)
has been included.
The restore process will also look for and attempt to
restore files from the trashdir as part of restoring
backups. Additionally to support this process the
ammount of time files are kept in trashdir before they
are cleaned up via cron is also adjustable via admin
setting.
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.
This patch adds sort ordering to the way courses are
automatically backed up. It sets the following preference:
Backup courses that do not have an entry in backup_courses first,
as they are likely new and never been backed up.
Backup courses that have the oldest next start time in backup_courses.
Give preference to most recently modified courses over other courses.
Specially noticeable under Windows, where some resources/files
are kept open/busy/locked, causing all sort of problems, easily
detectable in phpunit resets.
The only different between each setting dependency type is the evaluation of the condition,
and the mform js validation arguments - so that should be the only thing that is extended
by each subclass.
With PHP 7.3, the hash (#) is being escaped by preg_quote().
While normally that doesnt have much impact and normal operations
continue working perfectly... when the results of the function are
used to match against the same string... they don't match anymore.
Have found a couple of there double-uses in core and this
commit fixes them. Covered with tests.