Skip to content
Snippets Groups Projects
Commit f179cf15 authored by JediKev's avatar JediKev
Browse files

issue: Old Attachment Names

This addresses an issue where uploading a file you’ve uploaded before but
renamed is not saving the new name in the Attachment table.
parent e5024184
Branches
Tags
No related merge requests found
...@@ -108,15 +108,23 @@ extends InstrumentedList { ...@@ -108,15 +108,23 @@ extends InstrumentedList {
*/ */
function keepOnlyFileIds($ids, $inline=false, $lang=false) { function keepOnlyFileIds($ids, $inline=false, $lang=false) {
if (!$ids) $ids = array(); if (!$ids) $ids = array();
$new = array_fill_keys($ids, 1); $new = array_flip($ids);
foreach ($this as $A) { foreach ($this as $A) {
if (!isset($new[$A->file_id]) && $A->lang == $lang && $A->inline == $inline) if (!isset($new[$A->file_id]) && $A->lang == $lang && $A->inline == $inline)
// Not in the $ids list, delete // Not in the $ids list, delete
$this->remove($A); $this->remove($A);
unset($new[$A->file_id]); unset($new[$A->file_id]);
} }
// Everything remaining in $new is truly new $attachments = array();
$this->upload(array_keys($new), $inline, $lang); // Format $new for upload() with new name
foreach ($new as $id=>$name) {
$attachments[] = array(
'id' => $id,
'name' => $name
);
}
// Everything remaining in $attachments is truly new
$this->upload($attachments, $inline, $lang);
} }
function upload($files, $inline=false, $lang=false) { function upload($files, $inline=false, $lang=false) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment