partkeepr

fork of partkeepr
git clone https://git.e1e0.net/partkeepr.git
Log | Files | Refs | Submodules | README | LICENSE

commit 4e94be10f312c80cda7a4cf4513e683c257261af
parent 3a6c57a3d1c6fd0b770b4e3211db83b20e4d1904
Author: Felicitus <felicitus@felicitus.org>
Date:   Sat, 30 Mar 2013 12:50:38 +0100

Only replace the attachment if the part has been copied; bugfix for issue #291

Diffstat:
Msrc/backend/PartKeepr/Part/PartAttachment.php | 10++++++----
1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/backend/PartKeepr/Part/PartAttachment.php b/src/backend/PartKeepr/Part/PartAttachment.php @@ -98,10 +98,12 @@ class PartAttachment extends UploadedFile implements Serializable, Deserializabl if (substr($parameters["id"], 0, 4) === "TMP:") { $this->replaceFromTemporaryFile($parameters["id"]); } else { - /* Attachment already exists, but seems to belong to another part. Copy the data. */ - $otherAttachment = PartAttachment::loadById($parameters["id"]); - $this->replace($otherAttachment->getFilename()); - $this->setOriginalFilename($otherAttachment->getOriginalFilename()); + // In case the part has been copied, the ID doesn't match. In that case we copy the attachment + if ($this->getId() !== $parameters["id"]) { + $otherAttachment = PartAttachment::loadById($parameters["id"]); + $this->replace($otherAttachment->getFilename()); + $this->setOriginalFilename($otherAttachment->getOriginalFilename()); + } } }