<p>I have made a plugin where I save a status of a related entry. I have enabled revisions in the section. But when I update the status entry, a new version is made with the newest content, but all the content of the previous versions are overwritten and are the same as the latest version. </p>

<p>Did I forgot something?</p>

<p>My code:</p>

<pre><code>$saveStatus = craft()-&gt;elements-&gt;getElementById($statusEntry-&gt;id);
$saveStatus-&gt;getContent()-&gt;setAttributes(array(
                            'eigenaarId'  =&gt; array($user-&gt;id),
                            'advertentieId' =&gt; array($entryID),
                            'doorkoppelaarId' =&gt; array($doorkoppelaar-&gt;id),
                            'statusCode' =&gt; $status['status_code'],
                            'statusMessage' =&gt; $return[$i]['message'],
                            'statusErrors' =&gt; json_encode($errors),
                            'statusWarnings' =&gt; json_encode($warnings),
                        ));

$newStatusEntry = craft()-&gt;entries-&gt;saveEntry($saveStatus);
</code></pre>

<p><a href="https://i.sstatic.net/sCPqy.jpg" rel="nofollow noreferrer"><img src="https://i.sstatic.net/sCPqy.jpg" alt="enter image description here"></a></p>

CC BY-SA 3.0
2017-11-03T19:14:54.880Z
You're saying a new row isn't being created in the `craft_entryrevisions` table for that entryId, but is's overwriting an existing row?
Brad Bell
CC BY-SA 3.0
2017-11-04T18:48:35.700Z
No, the new entry is created. But all the other revisions are overwrited with the latest data.
Caroline van der Vegt
CC BY-SA 3.0
2017-11-06T01:15:14.873Z
Hrm... can you take a before/after screenshot of the `craft_entryrevisions` table filtered by the entryId you're editing?
Brad Bell
CC BY-SA 3.0
2017-11-07T09:18:35.193Z
I have uploaded the image in the start post.
Caroline van der Vegt
<plugin-development><entries>
revision entry is the same with saveEntry in plugin
# revision entry is the same with saveEntry in plugin

(Asked by: username_0 on 2017-11-03)

I have made a plugin where I save a status of a related entry. I have enabled revisions in the section. But when I update the status entry, a new version is made with the newest content, but all the content of the previous versions are overwritten and are the same as the latest version. 
Did I forgot something?
My code:
$saveStatus = craft()->elements->getElementById($statusEntry->id);
$saveStatus->getContent()->setAttributes(array(
                            'eigenaarId'  => array($user->id),
                            'advertentieId' => array($entryID),
                            'doorkoppelaarId' => array($doorkoppelaar->id),
                            'statusCode' => $status['status_code'],
                            'statusMessage' => $return[$i]['message'],
                            'statusErrors' => json_encode($errors),
                            'statusWarnings' => json_encode($warnings),
                        ));

$newStatusEntry = craft()->entries->saveEntry($saveStatus);

**Tags:** plugin-development, entries
> **Comments:**
> **username_1**: You're saying a new row isn't being created in the `craft_entryrevisions` table for that entryId, but is's overwriting an existing row?  
> **username_0**: No, the new entry is created. But all the other revisions are overwrited with the latest data.  
> **username_1**: Hrm... can you take a before/after screenshot of the `craft_entryrevisions` table filtered by the entryId you're editing?  
> **username_0**: I have uploaded the image in the start post.  

---

## 0 answers

