[BUG] Setters/Getters in model, after i fetch an item from model gives errors
@niden a question i have... hope u understand my bad English- so... is it normal, when i have setters/getters in model, after i fetch an item from model - data now is going though? Lets show u example:
My model:
class Users ... {
protected ?string $data = null;
...
public function setData(?array $data = []): void
{
$this->data = implode('-', $data);
}
}
Before:
$test = Models\Users::findFirst():
Now with this release this gives me error... say $data must be array, not string. This is because in DB this field is string.
Anyway... i fixed the function public function setData(null|string|array $data = []): void ... etc, but, just want to know which one is the right behavior.
Originally posted by @borisdelev in https://github.com/phalcon/cphalcon/discussions/16938#discussioncomment-16766565
Resolved in https://github.com/phalcon/cphalcon/pull/16957
Thank you @borisdelev
Amm a question i have- sorry- did this is fixed in 5.13 - i am with that version and issue still persist. Thanku!
Amm a question i have- sorry- did this is fixed in 5.13 - i am with that version and issue still persist. Thanku!
@borisdelev this should have been addressed in 9b1e7541,
Can you confirm version and perhaps show the full stack trace of the error? I have been using your example as a test.
Yes, i confirm i have that in 5.13. In my case... i have something like that:
<?php
// in model
protected ?string $password = null;
public function setPassword(?string $password = null): void
{
var_dump('HEHHEHE');exit;
}
When i retrieve this model, with findFirst for example- will print "hhehehe".
If this should be the right behavior... so, i need to fix my code :)
@borisdelev I checked this and what you are seeing is the intended behavior after the bug fix.
You could use the orm.disable_assign_setters = true if you want to remove that. Right now hydration matches what assign() does
Cool. Good to know. Will fix my logick then... Thank u ❤️