Skip to content
This repository has been archived by the owner on Dec 15, 2019. It is now read-only.

erreur : Warning: Erroneous data format for unserializing 'Ben\UserBundle\Entity\User' #2

Open
abel406 opened this issue Jul 15, 2016 · 0 comments

Comments

@abel406
Copy link

abel406 commented Jul 15, 2016

Hi benaich,
Congratulations for this app. It's been very helpful for me on my early beginnings with symfony.
After having downloaded the master and having done all the read me file recommendations i had the following issue on doctrine:

erreur : Warning: Erroneous data format for unserializing 'Ben\UserBundle\Entity\User' in C:\wamp64\www\doctors\vendor\doctrine\orm\lib\Doctrine\ORM\Mapping\ClassMetadataInfo.php line 872

I read this post DDC-3120: Warning: from @doctrinebot and chancging doctrine line to this:

"doctrine/orm": "~2.4.6,>=2.2.3,<2.5",

I went to the ClassMetadataInfo.php and changed the following lines starting at 866 line:

public function newInstance()
    {
        if ($this->_prototype === null) {
            if (PHP_VERSION_ID === 50429 || PHP_VERSION_ID === 50513) {
                $this->_prototype = $this->reflClass->newInstanceWithoutConstructor();
            } else {
                $this->_prototype = unserialize(sprintf('O:%d:"%s":0:{}', strlen($this->name), $this->name));
            }
        }
        return clone $this->_prototype;
    }

to this

public function newInstance()
    {
        if ($this->_prototype === null) {
           if (PHP_VERSION_ID >= 50513 || PHP_VERSION_ID === 50429 || PHP_VERSION_ID === 50513) {
                $this->_prototype = $this->reflClass->newInstanceWithoutConstructor();
            } else {
                $this->_prototype = unserialize(sprintf('O:%d:"%s":0:{}', strlen($this->name), $this->name));
            }
        }
        return clone $this->_prototype;
    }

and it worked. So i think it is a good addition to this repo.

I hope this helps other.

Regards from Cuba.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant