diff --git a/lib/filelib.php b/lib/filelib.php
index 6512933e3ef..c541731829f 100644
--- a/lib/filelib.php
+++ b/lib/filelib.php
@@ -1044,7 +1044,8 @@ function file_save_draft_area_files($draftitemid, $contextid, $component, $filea
// Do not merge files, leave it as it was.
if ($draftitemid === IGNORE_FILE_MERGE) {
- return null;
+ // Safely return $text, no need to rewrite pluginfile because this is mostly comming from an external client like the app.
+ return $text;
}
$usercontext = context_user::instance($USER->id);
diff --git a/lib/tests/filelib_test.php b/lib/tests/filelib_test.php
index a1b428a8d3c..f6e0c1b5dd3 100644
--- a/lib/tests/filelib_test.php
+++ b/lib/tests/filelib_test.php
@@ -869,6 +869,11 @@ class core_filelib_testcase extends advanced_testcase {
// Save without merge.
file_save_draft_area_files(IGNORE_FILE_MERGE, $usercontext->id, 'user', 'private', 0);
$this->assertCount(2, $fs->get_area_files($usercontext->id, 'user', 'private'));
+ // Save again, this time including some inline text.
+ $inlinetext = 'Some text
';
+ $text = file_save_draft_area_files(IGNORE_FILE_MERGE, $usercontext->id, 'user', 'private', 0, null, $inlinetext);
+ $this->assertCount(2, $fs->get_area_files($usercontext->id, 'user', 'private'));
+ $this->assertEquals($inlinetext, $text);
}
/**
diff --git a/lib/upgrade.txt b/lib/upgrade.txt
index 30dbd057adb..99189a11cc3 100644
--- a/lib/upgrade.txt
+++ b/lib/upgrade.txt
@@ -23,6 +23,7 @@ attribute on forms to avoid collisions in forms loaded in AJAX requests.
and get_reduced_timeout(). These allow for timeouts to be increased by a setting in config.php.
* The $draftitemid parameter of file_save_draft_area_files() function now supports the constant IGNORE_FILE_MERGE:
When the parameter is set to that constant, the function won't process file merging, keeping the original state of the file area.
+ Notice also than when $text is set, pluginfile rewrite won't be processed so the text will not be modified.
* Introduced new callback for plugin developers '_pre_processor_message_send($procname, $proceventdata)':
This will allow any plugin to manipulate messages or notifications before they are sent by a processor (email, mobile...)
* New capability 'moodle/category:viewcourselist' in category context that controls whether user is able to browse list of courses