MDL-76577 block_html: fix incorrect use of draft files
This commit is contained in:
@@ -151,11 +151,11 @@ class block_html extends block_base {
|
||||
public function instance_copy($fromid) {
|
||||
$fromcontext = context_block::instance($fromid);
|
||||
$fs = get_file_storage();
|
||||
// This extra check if file area is empty adds one query if it is not empty but saves several if it is.
|
||||
if (!$fs->is_area_empty($fromcontext->id, 'block_html', 'content', 0, false)) {
|
||||
$draftitemid = 0;
|
||||
file_prepare_draft_area($draftitemid, $fromcontext->id, 'block_html', 'content', 0, array('subdirs' => true));
|
||||
file_save_draft_area_files($draftitemid, $this->context->id, 'block_html', 'content', 0, array('subdirs' => true));
|
||||
// Do not use draft files hacks outside of forms.
|
||||
$files = $fs->get_area_files($fromcontext->id, 'block_html', 'content', 0, 'id ASC', false);
|
||||
foreach ($files as $file) {
|
||||
$filerecord = ['contextid' => $this->context->id];
|
||||
$fs->create_file_from_storedfile($filerecord, $file);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user