Skip to content
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

unserialize($str) must be compatible with Mvc\Model::unserialize($str): void #16695

Open
pandian1989 opened this issue Feb 6, 2025 · 1 comment
Labels
bug A bug report status: unverified Unverified

Comments

@pandian1989
Copy link

pandian1989 commented Feb 6, 2025

I recently upgrade phalcon 4 to 5.4 under PHP 7.4. When run our existing test cases, we are facing incompatibility issues with respect to unserialize.

Exception:

Fatal error: Declaration of Mockery_11_User::unserialize($string) must be compatible with Phalcon\Mvc\Model::unserialize($serialized): void

Phalcon - 5.4
PHP - 7.4

I tried following code snippet in model

public function serialize(): string
    {
        $data = array(
            'parent' => parent::serialize(),
        );

        return serialize($data);
    }

    public function unserialize($str) : void
    {
        $data = unserialize($str);
        parent::unserialize($data['parent']);
        unset($data['parent']);
        foreach ($data as $key => $value) {
            $this->$key = $value;
        }
    }

Anybody kindly help on this. Thank you

@pandian1989 pandian1989 added bug A bug report status: unverified Unverified labels Feb 6, 2025
@nadorator
Copy link

the new version add the dirtyState in the returned json so if you want your test to be compatible with your model you have to upgrade your test as well to mock the dirtyState too.

You can compare both zep source code on both branchs on Mvc/Model.zep

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A bug report status: unverified Unverified
Projects
None yet
Development

No branches or pull requests

2 participants