We are moving our forum in GitHub Discussions. For questions about Phalcon v3/v4 you can visit here and for Phalcon v5 here.

Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

The record doesn't have a valid data snapshot in 3.2.2

I have the "The record doesn't have a valid data snapshot" message when I try to access hasChanged method when I update a model.

here is my controller (somme line are deleted)

In the code below, the hasChanged works only because I added $serie->setSnapshotData($originalData); but it should not be mandatory to add this manually.

        $serie = $seriesService->getSeriesBySlug($slug);
        $originalData = $serie->toArray();
        $form = new SeriesForm();
        try {
            if ($this->request->isPost()) {
                } else {
                    $form->bind($this->request->getPost(), $serie);
                    $seriesService = $this->di->get('SeriesService');
                    //redirect to addChapter page for this series.
            } else {


Am I doing something wrong ?

Phalcon verison : 3.2.2

edited Nov '17

Are you sure you have keepSnapshots in initialize method? After finding it should correctly set snapshot data already.

Also snapshot in phalcon had many bugs and it was inconsistent. Right now phalcon updates snapshot after saving a model. If you want to check what fields where updated you can use hasUpdated or set phalcon.orm.update_snapshot_on_save in php.ini to 0


Hmm Itried that in the initialize methof on, my Series model but didn't work. I'll try again, but I don't think it will works.


Ok, just tried again It seems to be working with keepSnapshots(true) ... I had to dod something wrong earlier. however, the hasUpdated return false for a field that was changed and hasChanged reutn true in that case. Dunno how hasUpdated have to be used (maybe AFTER an update).

Anyways, thanks, If I have another problem I'll comme back on this thread.

edited Nov '17

Yes. After an update. Simpy snapshot right now is always updated after save. So to check if something was updated use hasUpdated, if you want something to change if it was changed but before update use hasChanged. I think it's kind of logicial.