diff --git a/include/class.attachment.php b/include/class.attachment.php index 15f3fd9b1dec6de619247e1158771a73434ba797..bcda6d08af5d757c01b691b78a29b28f03def623 100644 --- a/include/class.attachment.php +++ b/include/class.attachment.php @@ -108,15 +108,23 @@ extends InstrumentedList { */ function keepOnlyFileIds($ids, $inline=false, $lang=false) { if (!$ids) $ids = array(); - $new = array_fill_keys($ids, 1); + $new = array_flip($ids); foreach ($this as $A) { if (!isset($new[$A->file_id]) && $A->lang == $lang && $A->inline == $inline) // Not in the $ids list, delete $this->remove($A); unset($new[$A->file_id]); } - // Everything remaining in $new is truly new - $this->upload(array_keys($new), $inline, $lang); + $attachments = array(); + // 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) {