Skip to content
Snippets Groups Projects
Unverified Commit cca97eda authored by Peter Rotich's avatar Peter Rotich Committed by GitHub
Browse files

Merge pull request #5149 from JediKev/issue/db-error-1062

issue: DB Error #1062
parents 88f97b55 27c925cc
No related branches found
Tags v1.9.0
No related merge requests found
......@@ -148,7 +148,15 @@ extends InstrumentedList {
$_inline = isset($file['inline']) ? $file['inline'] : $inline;
$att = $this->add(new Attachment(array(
// Check if Attachment exists
if ($F && $this->key)
$existing = Attachment::objects()->filter(array(
'file__key' => $F->key,
'object_id' => $this->key['object_id'],
'type' => $this->key['type']
))->first();
$att = $this->add(isset($existing) ? $existing : new Attachment(array(
'file_id' => $fileId,
'inline' => $_inline ? 1 : 0,
)));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment