-
Bug
-
Resolution: Fixed
-
Minor
-
2.1.4, 2.2.1
-
Any
-
MOODLE_21_STABLE, MOODLE_22_STABLE
-
MOODLE_21_STABLE, MOODLE_22_STABLE
-
MDL-31515-master-1 -
Moderate
-
With a database activity offering a 'file' field, you can update the field only once. If you add subsequent files, they are ignored by the interface and are never attached.
It seems that when the filepicker was introduced, the loop over the updated records counts:
$count = 0;
|
foreach ($files as $draftfile) {
|
// do some stuff
|
$DB->update_record(...);
|
|
if ($count > 0) {
|
break;
|
} else {
|
$count++;
|
}
|
}
|
This has the result that the first non-directory gets a count of 0, which is then increased to 1
On the second file, the db is updated, but the count is now > 0, so we break.
If a user has uploaded several files recently (or draft deletion is disabled), and then uploads a new file for the context, it will be at the end of the list, and so is ignored.
I'm not sure as to the intention of this, so it's difficult to determine the best way of patching. My current thought is to change the $fs->get_area_files() to sort by timecreated DESC and break after the first update. I've uploaded a patch to this affect, and also adjusted some of the logic to make it only deal with files it's actually doing work with.
If there's an alternative/preferred approach, I'm all ears!
- is a regression caused by
-
MDL-16493 File storage conversion Database
-
- Closed
-