Skip to content

Upgrade from 4.2 to 5.1.3 get error The 'keepSnapshots' option must be enabled to track changes #16261

Answered by Drummi42
Drummi42 asked this question in Q&A
Discussion options

You must be logged in to vote

__serialization sets snapshot = null in the cache model if attributes are not changed.
https://github.com/phalcon/cphalcon/blob/5.0.x/phalcon/Mvc/Model.zep#L384
If the snapshot is cached, then __unserialize set snapshot = cachedSnapshot. And this condition does not work
https://github.com/phalcon/cphalcon/blob/5.0.x/phalcon/Mvc/Model.zep#L603
temporary fix in the model (im use useDynamicUpdate(true), snapshot enable for all models):

public function __serialize(): array
{
  $arr = parent::__serialize();
  if ($arr['snapshot'] === null) {
      unset($arr['snapshot']);
  }
  return $arr;
}

Replies: 3 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by Drummi42
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants