diff --git a/include/class.forms.php b/include/class.forms.php index 6618220058e7be217ee3526e1359651d8dd7de80..627cd5a72c1cbfc99a826abd0a89503bbc61fd6f 100644 --- a/include/class.forms.php +++ b/include/class.forms.php @@ -3668,17 +3668,19 @@ class FileUploadWidget extends Widget { $maxfilesize = ($config['size'] ?: 1048576) / 1048576; $files = $F = array(); $new = array_fill_keys($this->field->getClean(), 1); - foreach ($attachments as $f) { - $F[] = $f->file; - unset($new[$f->id]); + foreach ($attachments as $a) { + $F[] = $a->file; + unset($new[$a->file_id]); } // Add in newly added files not yet saved (if redisplaying after an // error) if ($new) { $F = array_merge($F, AttachmentFile::objects() ->filter(array('id__in' => array_keys($new))) - ->all()); + ->all() + ); } + foreach ($F as $file) { $files[] = array( 'id' => $file->getId(), diff --git a/include/class.orm.php b/include/class.orm.php index 162b61f46a1f1620e4dbaef1d39f75c71ebc04a8..b784b6341e71df002a2f8bc136f12da32d7f5f0d 100644 --- a/include/class.orm.php +++ b/include/class.orm.php @@ -1904,14 +1904,13 @@ extends ModelResultSet { } /** - * Slight edit to the standard ::next() iteration method which will skip - * deleted items. + * Slight edit to the standard iteration method which will skip deleted + * items. */ - function next() { - do { - parent::next(); - } - while ($this->valid() && $this->current()->__deleted__); + function getIterator() { + return new CallbackFilterIterator(parent::getIterator(), + function($i) { return !$i->__deleted__; } + ); } /**