From dcff1a81b221e1710b739aea3cb0f612f43d0768 Mon Sep 17 00:00:00 2001 From: Henrik Hautakoski Date: Wed, 22 Aug 2018 06:06:56 +0200 Subject: [PATCH] app/models/Data/Base.php: override hasChanged() Phalcon throws an exception if no valid snapshot data is present. We override this behaviour by treating no snapshot data (new row) as changed. --- app/models/Data/Base.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/app/models/Data/Base.php b/app/models/Data/Base.php index 2223d4b..59a92be 100644 --- a/app/models/Data/Base.php +++ b/app/models/Data/Base.php @@ -6,4 +6,21 @@ use Phalcon\Mvc\Model; class Base extends Model { + /** + * {@inheritdoc} + * + * Phalcon throws an exception if no valid snapshot data is present. + * + * We override this behaviour by treating no + * snapshot data (new row) as changed. + * + * @param string|array $fieldName + * @param boolean $allFields + * @return bool + */ + public function hasChanged($fieldName = null, $allFields = false) + { + return $this->hasSnapshotData() === false + || parent::hasChanged($fieldName, $allFields); + } }