diff --git a/include/class.attachment.php b/include/class.attachment.php index 6a904015421c5d1b899927cf9b21b5a4cc79baad..c0e9761ebba32cc69306562b790b20797f1d3b20 100644 --- a/include/class.attachment.php +++ b/include/class.attachment.php @@ -109,8 +109,7 @@ extends InstrumentedList { function keepOnlyFileIds($ids, $inline=false, $lang=false) { $new = array_fill_keys($ids, 1); foreach ($this as $A) { - $idx = array_search($A->file_id, $ids); - if ($idx === false && (!$A->lang || $A->lang == $lang)) + if (!isset($new[$A->file_id]) && $A->lang == $lang) // Not in the $ids list, delete $this->remove($A); unset($new[$A->file_id]); @@ -184,8 +183,6 @@ extends InstrumentedList { if ($lang) $base = $base->filter(array('lang' => $lang)); - else - $base = $base->filter(array('lang__isnull' => true)); return $base; } diff --git a/include/class.faq.php b/include/class.faq.php index 9f0b83ccd5161f08700fbfb03cfec1fea7a47d1a..a551beefaba06f1a653745cf63f1f4de4899c474 100644 --- a/include/class.faq.php +++ b/include/class.faq.php @@ -312,12 +312,8 @@ class FAQ extends VerySimpleModel { return true; } - function getAttachments($lang=false) { - $att = $this->attachments; - if ($lang) - $att = $att->window(array('lang'=>$lang)); - - return $att; + function getAttachments($lang=null) { + return $this->attachments->window(array('lang'=>$lang)); } function getAttachmentsLinks($separator=' ',$target='') { diff --git a/include/class.forms.php b/include/class.forms.php index f5f3ce86f0df34a6f6e3a0609d6ca64c81bb1e0a..55f62a66b90da822ddec04e831f92488b951c6a2 100644 --- a/include/class.forms.php +++ b/include/class.forms.php @@ -2323,7 +2323,7 @@ class FileUploadField extends FormField { sprintf('%u', crc32('E'.$this->get('id').$e->get('id'))), 'E'); } - return $this->attachments ? $this->attachments->getAll() : array(); + return $this->attachments ?: array(); } function setAttachments(GenericAttachments $att) { diff --git a/include/class.orm.php b/include/class.orm.php index 8c0315811e98ab0e1da6a18cfcbcf27be11025f6..516d714da548fe9e5d502b444bfd56454b09a401 100644 --- a/include/class.orm.php +++ b/include/class.orm.php @@ -304,6 +304,10 @@ class VerySimpleModel { if ($this->__new__) return null; + // Check to see if the column referenced is actually valid + if (in_array($field, static::getMeta('fields'))) + return null; + // TODO: Inspect fields from database before throwing this error throw new OrmException(sprintf(__('%s: %s: Field not defined'), get_class($this), $field));