Commit e1f7510e authored by Marc Egger's avatar Marc Egger
Browse files

Save.php: Fixed exception (file size, mime type) for non-existing uploads

parent 75e02951
Pipeline #1116 passed with stage
in 1 minute and 34 seconds
...@@ -327,6 +327,14 @@ class Save { ...@@ -327,6 +327,14 @@ class Save {
/** /**
* Process all Upload Formelements for the given $recordId. After processing &$formValues will be updated with the * Process all Upload Formelements for the given $recordId. After processing &$formValues will be updated with the
* final filenames. * final filenames.
*
* Constellation: # FILE OLD FILE NEW FILESIZE
* 1 none none
* 2 none new
* 3 exist no change
* 4 delete none
* 5 delete new
*
* @param $recordId * @param $recordId
* @throws CodeException * @throws CodeException
* @throws DbException * @throws DbException
...@@ -339,6 +347,7 @@ class Save { ...@@ -339,6 +347,7 @@ class Save {
$sip = new Sip(false); $sip = new Sip(false);
$newValues = array(); $newValues = array();
$vars=array();
$formValues = $this->store->getStore(STORE_FORM); $formValues = $this->store->getStore(STORE_FORM);
$primaryRecord = $this->store->getStore(STORE_RECORD); // necessary to check if the current formElement exist as a column of the primary table. $primaryRecord = $this->store->getStore(STORE_RECORD); // necessary to check if the current formElement exist as a column of the primary table.
...@@ -362,10 +371,27 @@ class Save { ...@@ -362,10 +371,27 @@ class Save {
$column = $formElement[FE_NAME]; $column = $formElement[FE_NAME];
$pathFileName = $this->doUpload($formElement, $formValues[$column], $sip, $modeUpload); $pathFileName = $this->doUpload($formElement, $formValues[$column], $sip, $modeUpload);
$pathFileNameTmp = empty($pathFileName) ? $primaryRecord[$column] : $pathFileName; if($modeUpload==UPLOAD_MODE_DELETEOLD && $pathFileName==''){
$pathFileNameTmp=''; // see '4'
} else {
if (empty($pathFileName)) {
$pathFileNameTmp = $primaryRecord[$column]; // see '3'
} else {
$pathFileNameTmp = $pathFileName; // see '1,2,5'
}
}
// Get latest file information // Get latest file information
$vars = HelperFile::getFileStat($pathFileNameTmp);
$this->store->appendToStore($vars, STORE_VAR); if($pathFileNameTmp=='') {
// No new upload and no existing: take care to remove previous upload file statistics.
$this->store->unsetVar(VAR_FILE_MIME_TYPE, STORE_VAR);
$this->store->unsetVar(VAR_FILE_SIZE, STORE_VAR);
} else {
$vars = HelperFile::getFileStat($pathFileNameTmp);
$this->store->appendToStore($vars, STORE_VAR);
}
// If given: fire a sqlBefore query // If given: fire a sqlBefore query
$this->evaluate->parse($formElement[FE_SQL_BEFORE]); $this->evaluate->parse($formElement[FE_SQL_BEFORE]);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment