Skip to content

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

Open
@pandian1989

Description

@pandian1989

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions