mirror of
https://github.com/moodle/moodle.git
synced 2025-08-11 20:06:46 +02:00
MDL-37757 repositories: Deleting a repository deletes files.
If the user decides to remove a repository all of the linked files are now deleted along with file references. This was causing problems such as the course page displaying an error with no recourse to fix the problem.
This commit is contained in:
parent
2af1421e34
commit
6a33a850fc
1 changed files with 13 additions and 0 deletions
|
@ -2004,6 +2004,8 @@ abstract class repository implements cacheable_object {
|
||||||
global $DB;
|
global $DB;
|
||||||
if ($downloadcontents) {
|
if ($downloadcontents) {
|
||||||
$this->convert_references_to_local();
|
$this->convert_references_to_local();
|
||||||
|
} else {
|
||||||
|
$this->remove_files();
|
||||||
}
|
}
|
||||||
cache::make('core', 'repositories')->purge();
|
cache::make('core', 'repositories')->purge();
|
||||||
try {
|
try {
|
||||||
|
@ -2668,6 +2670,17 @@ abstract class repository implements cacheable_object {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Find all external files linked to this repository and delete them.
|
||||||
|
*/
|
||||||
|
public function remove_files() {
|
||||||
|
$fs = get_file_storage();
|
||||||
|
$files = $fs->get_external_files($this->id);
|
||||||
|
foreach ($files as $storedfile) {
|
||||||
|
$storedfile->delete();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function repository::reset_caches() is deprecated, cache is handled by MUC now.
|
* Function repository::reset_caches() is deprecated, cache is handled by MUC now.
|
||||||
* @deprecated since Moodle 2.6 MDL-42016 - please do not use this function any more.
|
* @deprecated since Moodle 2.6 MDL-42016 - please do not use this function any more.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue