mirror of
https://github.com/getgrav/grav.git
synced 2026-05-07 17:56:22 +02:00
Fixed a bug in FormFlashFile::moveTo() not deleting the old file
This commit is contained in:
@@ -3,6 +3,8 @@
|
|||||||
|
|
||||||
1. [](#improved)
|
1. [](#improved)
|
||||||
* Improved `$page->forms()` call, added `$page->addForms()`
|
* Improved `$page->forms()` call, added `$page->addForms()`
|
||||||
|
1. [](#bugfix)
|
||||||
|
* Fixed a bug in `FormFlashFile::moveTo()` not deleting the old file
|
||||||
|
|
||||||
# v1.6.0-beta.8
|
# v1.6.0-beta.8
|
||||||
## 01/25/2019
|
## 01/25/2019
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ class FormFlashFile implements UploadedFileInterface, \JsonSerializable
|
|||||||
throw new \RuntimeException(\sprintf('Uploaded file could not be moved to %s', $targetPath));
|
throw new \RuntimeException(\sprintf('Uploaded file could not be moved to %s', $targetPath));
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->flash->removeFile($this->field, $this->upload['tmp_name']);
|
$this->flash->removeFile($this->getClientFilename(), $this->field);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getSize()
|
public function getSize()
|
||||||
@@ -100,7 +100,7 @@ class FormFlashFile implements UploadedFileInterface, \JsonSerializable
|
|||||||
|
|
||||||
public function getDestination()
|
public function getDestination()
|
||||||
{
|
{
|
||||||
return $this->upload['path'];
|
return $this->upload['path'] ?? '';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function jsonSerialize()
|
public function jsonSerialize()
|
||||||
@@ -108,9 +108,15 @@ class FormFlashFile implements UploadedFileInterface, \JsonSerializable
|
|||||||
return $this->upload;
|
return $this->upload;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getTmpFile() : string
|
public function getTmpFile() : ?string
|
||||||
{
|
{
|
||||||
return $this->flash->getTmpDir() . '/' . $this->upload['tmp_name'];
|
$tmpName = $this->upload['tmp_name'] ?? null;
|
||||||
|
|
||||||
|
if (!$tmpName) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->flash->getTmpDir() . '/' . $tmpName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function __debugInfo()
|
public function __debugInfo()
|
||||||
@@ -134,6 +140,10 @@ class FormFlashFile implements UploadedFileInterface, \JsonSerializable
|
|||||||
if ($this->moved) {
|
if ($this->moved) {
|
||||||
throw new \RuntimeException('Cannot retrieve stream after it has already been moved');
|
throw new \RuntimeException('Cannot retrieve stream after it has already been moved');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!$this->getTmpFile()) {
|
||||||
|
throw new \RuntimeException('Cannot retrieve stream as the file was not uploaded');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user