MDL-72050 filelib: Add function for deleting draftarea

This commit is contained in:
Stefan Hanauska
2025-03-13 08:17:43 +01:00
parent 4df87b3130
commit 7d00d01b66
2 changed files with 16 additions and 0 deletions
+13
View File
@@ -1313,6 +1313,19 @@ function file_save_draft_area_files($draftitemid, $contextid, $component, $filea
}
}
/**
* Clear a draft area.
*
* @param int $draftitemid Id of the draft area to clear.
* @return boolean success
*/
function file_clear_draft_area(int $draftitemid): bool {
global $USER;
$fs = get_file_storage();
$usercontext = context_user::instance($USER->id);
return $fs->delete_area_files($usercontext->id, 'user', 'draft', $draftitemid);
}
/**
* Convert the draft file area URLs in some content to @@PLUGINFILE@@ tokens
* ready to be saved in the database. Normally, this is done automatically by
+3
View File
@@ -25,6 +25,9 @@ completed modules to the DBMS improving the performance of the method.
user has been redirected to the expected location.
e.g. `And the url should match "/mod/forum/view\.php\?id=[0-9]+"`
* A new function `file_clear_draft_area()` has been added to delete the files in a draft area.
For more information see [MDL-72050](https://tracker.moodle.org/browse/MDL-72050)
=== 4.4.5 ===
* All uses of the following PHPUnit methods have been removed as these methods are deprecated upstream without direct replacement: