Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
ivoba committed May 28, 2019
1 parent 578ff19 commit e0eb63a
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/FileAttachmentField.php
Original file line number Diff line number Diff line change
Expand Up @@ -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}();
Expand All @@ -561,7 +561,7 @@ public function setValue($val, $data = array())
if (!$file->exists()) {
continue;
}
$ids[] = $file->ID;
$ids[] = $file->ID;
}
}
}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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();
Expand All @@ -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) {
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit e0eb63a

Please sign in to comment.