MDL-67062 core_h5p: delete cache assets when removing libraries

The cache assets linked to a library have to be removed also when a
library is deleted, in order to rebuild them again next time they are
required.
This commit is contained in:
Sara Arjona 2020-02-01 14:51:27 +01:00
parent 37b2ee3f64
commit 2b8d97326d

View File

@ -1138,6 +1138,8 @@ class framework implements \H5PFrameworkInterface {
$fs = new \core_h5p\file_storage();
// Delete the library from the file system.
$fs->delete_library(array('libraryId' => $library->id));
// Delete also the cache assets to rebuild them next time.
$this->deleteCachedAssets($library->id);
// Remove library data from database.
$DB->delete_records('h5p_library_dependencies', array('libraryid' => $library->id));
@ -1451,6 +1453,10 @@ class framework implements \H5PFrameworkInterface {
list($sql, $params) = $DB->get_in_or_equal($hashes, SQL_PARAMS_NAMED);
// Remove all invalid keys.
$DB->delete_records_select('h5p_libraries_cachedassets', 'hash ' . $sql, $params);
// Remove also the cachedassets files.
$fs = new file_storage();
$fs->deleteCachedAssets($hashes);
}
return $hashes;