diff --git a/src/FileAttachmentField.php b/src/FileAttachmentField.php index 3120b23..25182c8 100644 --- a/src/FileAttachmentField.php +++ b/src/FileAttachmentField.php @@ -552,7 +552,7 @@ public function setValue($val, $data = array()) if ($data->hasOneComponent($fieldName)) { $id = $data->{$fieldName.'ID'}; if ($id) { - $ids[] = $id; + $ids[] = $id; } } else if ($data->hasManyComponent($fieldName) || $data->manyManyComponent($fieldName)) { $files = $data->{$fieldName}(); @@ -561,7 +561,7 @@ public function setValue($val, $data = array()) if (!$file->exists()) { continue; } - $ids[] = $file->ID; + $ids[] = $file->ID; } } } @@ -862,7 +862,7 @@ public function isCMS() { return Controller::curr() instanceof LeftAndMain; } - + /** * @note these are user-friendlier versions of internal PHP errors reported back in the ['error'] value of an upload * @return string @@ -914,7 +914,7 @@ private function getUploadUserError($code) */ public function upload(HTTPRequest $request) { - + $name = $this->getSetting('paramName'); $files = (!empty($_FILES[$name]) ? $_FILES[$name] : array()); $tmpFiles = array(); @@ -924,14 +924,14 @@ public function upload(HTTPRequest $request) $error_message = _t('FileAttachmentField.UPLOADFORBIDDEN', 'Files cannot be uploaded via this form at the current time.'); return $this->httpError(403, $error_message); } - + // No files detected in the upload, this can occur if post_max_size is < the upload size $value = $request->postVar($name); if(empty($files) || empty($value)) { $error_message = _t('FileAttachmentField.NOFILESUPLOADED', 'No files were detected in your upload. Please try again later.'); return $this->httpError(400, $error_message); } - + // Security token check, must go after above check as a low post_max_size can scrub the Security Token name from the request $form = $this->getForm(); if($form) { @@ -1312,8 +1312,8 @@ public function getFileClass($filename = null) } if($filename) { - if($defaultClass == "Image" - && $this->config()->upgrade_images + if($defaultClass == Image::class + && $this->config()->upgrade_images && !Injector::inst()->get($class) instanceof Image ) { $class = Image::class;