-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Phalcon 2.0.* - creating object does not set model snapshots. #11007
Comments
+1, but I think it's not a bug, but a very annoying feature. Would be very cool if someone will fix it |
Snapshot should also be refreshed when Model is saved/updated. |
Old issue. From 1.3.x |
Refreshing the object doesn't help.
I solved this by completely reloading the object :(
|
I'm sorry @sergeyklay I don't understand your feedback. |
I mean that this is a known issue and I too just had to use this trick |
Ah sorry! Now I see. Completely clear. Hope to get some time soon to contribute to Phalcon. Love this project. |
Any update on this? Do you plan to implement it in 2.1? Thanks! |
Up. @andresgutierrez, can you give us a feedback about this? |
@sergeyklay Is this on your radar? :) |
No because 2.0.x is no longer supported. I guess in phalcon 3.0.x we can fix this :D |
Sorry, I wasn't expecting this to be fixed in 2.0.x :-) Any hope for this go to on 3.x branch? |
My work around for now is using a base mode class, with the 'afterCreate' method <?php
class BaseModel {
//...
public function afterCreate()
{
// I'm using parent because the child classes overload toArray(). For most, $this->toArray() would suffice
$this->setSnapshotData(parent::toArray());
}
}
class SomeModel extends BaseModel {
}
$hello = new SomeModel();
if ($hello->create()) {
var_dump($hello->hasSnapshotData()); //Returns true
} |
I made PR with fix for this, let me know what you think. |
Fixed in the |
Hi,
My model:
Immediately after creating a new instance of model, its snapshot is blank.
That prevents me from checking whether a field has been updated if I decide to update it later during the same request.
Snapshots only get set when loading a model. But they should also be set after a new model is created.
Thanks!
The text was updated successfully, but these errors were encountered: