All the setup/teardown/pre/post/conditions template methods
now are required to return void. This was warned with phpunit 7
and now is enforced.
At the same time, fix a few wrong function names,
provider data and param types, return statements...
Every backup and restore controller always need to call
to their ->destroy() method in charge of finalizing loggers,
closing file handlers and destroy some circular references.
This is specially important within unit tests, because
open resources cannot be reset between tests, causing problems,
specially within Windows that locks all those files.
This patch adds better core support for copying courses.
There is now a simplified and dedicated UI for copying
courses. This can be accessed from the course context
menu or course management screens.
All backups are done asynchronously and there can be multiple
copies of a course in flight at once.
* refactor run automated backup
* new backup status of Queued
* adhoc task for backing up a course
* course locking for course backup adhoc task
* use Moodle locking instead of custom locking for run automated backup task
* add unit tests to extracted methods
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.
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.
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.
This patch adds asynchronous backup and restore functionality
to Moodle. This is an optional feature and is not enabled by
default. It can be enabled by site administrators.
Asynchronous backup and restores are actioned by the Moodle
adhoc task API. The progress of backup and restores is
displayedin the Moodle UI. Users can also be sent a message
when a backup or restore operation completes via the
Moodle messaging API.
The new setting will allow to host the temporary backup files
into a specific target directory. Defaults to '$CFG->tempdir/backup'.
Calling make_backup_temp_directory() checks that the required sub-directory
will be properly created under the new target directory.
Any backup & restore operation may be leaving opened files
if a file logger is being used. This implementes the close()
method, so every logger can close any resource.
Also, the recommended backup_controlled::destroy() method
now calls to new logger::destroy() method in charge of
deleting all the references and closing any resource.
Finally, some internally used controllers, were missing
their destroy call, leading to associated loggers to
remain open. Now all them are explicitly deltroyed.
This patch replaces all homegrown timezone
stuff with standard PHP date/time code.
The main change is the introduction of core_date
class that returns normalised user and server
timezones. From now on nobody should be using
$CFG->timezone or $user->timezone directly!
Other new features and fixes:
* admins are prompted for timezone during install
* editing of other users is finally fixed
* timezones are displayed in user profile
* new $this->setTimezone() in phpunit
* time locale is now automatically reset in phpunit
* timezone is now automatically reset in phpunit
* phpunit has Australia/Perth as default timezone
Basically if the destination dir is empty then the storage
type should be set to the course backup area. This does
not affect the behaviour of the backups that lived with
misconfigured settings.