-
Bug
-
Resolution: Unresolved
-
Minor
-
None
-
4.1.5
-
MOODLE_401_STABLE
In \file_storage\create_file_from_storedfile(), there is a clean_param() operation on the file's referencefileid and referencelastsync fields. This can be seen here:
The problem is that, if the value of either referencefileid or referencelastsync before this operation is null, the operation converts the null value to zero.
So the new file record in the database will be incorrect, which can cause problems such as outlined in a ticket raised on the format_tiles plugin at https://bitbucket.org/dw8/moodle-format_tiles/issues/165/bug-report-issue-with-referencefileid
A proposed fix to preserve the null value would be to change the problem line as follows:
Before:
if ($key == 'referencefileid' or $key == 'referencelastsync') { |
$value = clean_param($value, PARAM_INT);
|
}
|
After:
if (($key == 'referencefileid' or $key == 'referencelastsync') && $value !== null) { |
$value = clean_param($value, PARAM_INT);
|
}
|
(This original code was added in 2012 under commit 67233725 (MDL-28666)