{"action":"created","issue":{"url":"https://api.github.com/repos/doctrine/doctrine2/issues/3897","repository_url":"https://api.github.com/repos/doctrine/doctrine2","labels_url":"https://api.github.com/repos/doctrine/doctrine2/issues/3897/labels{/name}","comments_url":"https://api.github.com/repos/doctrine/doctrine2/issues/3897/comments","events_url":"https://api.github.com/repos/doctrine/doctrine2/issues/3897/events","html_url":"https://github.com/doctrine/doctrine2/issues/3897","id":120669912,"number":3897,"title":"DDC-3120: Warning: Erroneous data format for unserializing PHP5.6+","user":{"login":"doctrinebot","id":2414358,"avatar_url":"https://avatars.githubusercontent.com/u/2414358?v=3","gravatar_id":"","url":"https://api.github.com/users/doctrinebot","html_url":"https://github.com/doctrinebot","followers_url":"https://api.github.com/users/doctrinebot/followers","following_url":"https://api.github.com/users/doctrinebot/following{/other_user}","gists_url":"https://api.github.com/users/doctrinebot/gists{/gist_id}","starred_url":"https://api.github.com/users/doctrinebot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/doctrinebot/subscriptions","organizations_url":"https://api.github.com/users/doctrinebot/orgs","repos_url":"https://api.github.com/users/doctrinebot/repos","events_url":"https://api.github.com/users/doctrinebot/events{/privacy}","received_events_url":"https://api.github.com/users/doctrinebot/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/doctrine/doctrine2/labels/Bug","name":"Bug","color":"e11d21"}],"state":"closed","locked":false,"assignee":{"login":"Ocramius","id":154256,"avatar_url":"https://avatars.githubusercontent.com/u/154256?v=3","gravatar_id":"","url":"https://api.github.com/users/Ocramius","html_url":"https://github.com/Ocramius","followers_url":"https://api.github.com/users/Ocramius/followers","following_url":"https://api.github.com/users/Ocramius/following{/other_user}","gists_url":"https://api.github.com/users/Ocramius/gists{/gist_id}","starred_url":"https://api.github.com/users/Ocramius/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Ocramius/subscriptions","organizations_url":"https://api.github.com/users/Ocramius/orgs","repos_url":"https://api.github.com/users/Ocramius/repos","events_url":"https://api.github.com/users/Ocramius/events{/privacy}","received_events_url":"https://api.github.com/users/Ocramius/received_events","type":"User","site_admin":false},"assignees":[{"login":"Ocramius","id":154256,"avatar_url":"https://avatars.githubusercontent.com/u/154256?v=3","gravatar_id":"","url":"https://api.github.com/users/Ocramius","html_url":"https://github.com/Ocramius","followers_url":"https://api.github.com/users/Ocramius/followers","following_url":"https://api.github.com/users/Ocramius/following{/other_user}","gists_url":"https://api.github.com/users/Ocramius/gists{/gist_id}","starred_url":"https://api.github.com/users/Ocramius/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Ocramius/subscriptions","organizations_url":"https://api.github.com/users/Ocramius/orgs","repos_url":"https://api.github.com/users/Ocramius/repos","events_url":"https://api.github.com/users/Ocramius/events{/privacy}","received_events_url":"https://api.github.com/users/Ocramius/received_events","type":"User","site_admin":false}],"milestone":{"url":"https://api.github.com/repos/doctrine/doctrine2/milestones/9","html_url":"https://github.com/doctrine/doctrine2/milestones/2.4.6","labels_url":"https://api.github.com/repos/doctrine/doctrine2/milestones/9/labels","id":1446280,"number":9,"title":"2.4.6","description":null,"creator":{"login":"beberlei","id":26936,"avatar_url":"https://avatars.githubusercontent.com/u/26936?v=3","gravatar_id":"","url":"https://api.github.com/users/beberlei","html_url":"https://github.com/beberlei","followers_url":"https://api.github.com/users/beberlei/followers","following_url":"https://api.github.com/users/beberlei/following{/other_user}","gists_url":"https://api.github.com/users/beberlei/gists{/gist_id}","starred_url":"https://api.github.com/users/beberlei/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/beberlei/subscriptions","organizations_url":"https://api.github.com/users/beberlei/orgs","repos_url":"https://api.github.com/users/beberlei/repos","events_url":"https://api.github.com/users/beberlei/events{/privacy}","received_events_url":"https://api.github.com/users/beberlei/received_events","type":"User","site_admin":false},"open_issues":0,"closed_issues":2,"state":"closed","created_at":"2015-12-06T13:20:35Z","updated_at":"2015-12-06T23:21:48Z","due_on":"2014-10-06T23:59:59Z","closed_at":"2015-12-06T13:20:35Z"},"comments":39,"created_at":"2014-05-11T15:46:43Z","updated_at":"2016-07-15T14:29:01Z","closed_at":"2015-12-06T23:18:00Z","body":"Jira issue originally created by user techkey:\n\nHi all,\n\nThere seems to be something strange going on in the method `newInstance()` of the class `\\Doctrine\\ORM\\Mapping\\ClassMetadataInfo`.\n\nThe original class method looks like this:\n\n\n{quote}\\Doctrine\\ORM\\Mapping\\ClassMetadataInfo#newInstance(){quote}\n```\n    {\n        if ($this->_prototype === null) {\n            $this->_prototype = unserialize(sprintf('O:%d:\"%s\":0:{}', strlen($this->name), $this->name));\n        }\n\n        return clone $this->_prototype;\n    }\n```\n\nWhat happens now when a class that implements \\Serializable is that a \"Warning: Erroneous data format for unserializing\" shows up and the function unserialize() returns false.\n\nThat is because a class that implements \\Serializable is expected to have the letter 'C' in the serialize string instead of the letter 'O'.\n\nI've made a quick work-around like this:\n\n{quote}\\Doctrine\\ORM\\Mapping\\ClassMetadataInfo#newInstance(){quote}\n```\n    {\n        if ($this->_prototype === null) {\n            $this->_prototype = @unserialize(sprintf('O:%d:\"%s\":0:{}', strlen($this->name), $this->name));\n            if ($this->_prototype === false) {\n                $this->_prototype = unserialize(sprintf('C:%d:\"%s\":0:{}', strlen($this->name), $this->name));\n            }\n        }\n\n        return clone $this->_prototype;\n    }\n```\n\nThat seems to work in my isolated tests and with Symfony2 and Doctrine2 and FOSUserBundle together.\n\nI've noticed this because the `Model\\User` class from FOSUserBundle implements `\\Serializable`.\n\nI had to implement a check in Model\\User class because when using {{'C:%d:\"%s\":0:{}'}} the $serialized parameter of the `unserialize` method in the `Model\\User` class is a empty string then.\n\nThat warning seems only to happen with PHP5.6+. PHP5.5.12 and below doesn't show that warning.\n\nI hope someone can shine some light on this, thank you,\n\nCornelis.\n"},"comment":{"url":"https://api.github.com/repos/doctrine/doctrine2/issues/comments/232966298","html_url":"https://github.com/doctrine/doctrine2/issues/3897#issuecomment-232966298","issue_url":"https://api.github.com/repos/doctrine/doctrine2/issues/3897","id":232966298,"user":{"login":"abel406","id":3779394,"avatar_url":"https://avatars.githubusercontent.com/u/3779394?v=3","gravatar_id":"","url":"https://api.github.com/users/abel406","html_url":"https://github.com/abel406","followers_url":"https://api.github.com/users/abel406/followers","following_url":"https://api.github.com/users/abel406/following{/other_user}","gists_url":"https://api.github.com/users/abel406/gists{/gist_id}","starred_url":"https://api.github.com/users/abel406/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/abel406/subscriptions","organizations_url":"https://api.github.com/users/abel406/orgs","repos_url":"https://api.github.com/users/abel406/repos","events_url":"https://api.github.com/users/abel406/events{/privacy}","received_events_url":"https://api.github.com/users/abel406/received_events","type":"User","site_admin":false},"created_at":"2016-07-15T14:29:01Z","updated_at":"2016-07-15T14:29:01Z","body":"Hi every one,\r\n\r\nI had the same issue with PHP 5.6.16 on a Windows 10 Pro 64 bit install with wamp3 for 64 bits and after making changes to doctrine line in composer.jsonthis way:\r\n\r\n```yaml\r\n\"doctrine/orm\": \"~2.4.6,>=2.2.3,<2.5\",\r\n```\r\nand changing the _C:\\wamp64\\www\\doctors\\vendor\\doctrine\\orm\\lib\\Doctrine\\ORM\\Mapping\\ClassMetadataInfo.php_  at line 869 like this:\r\n\r\n```php\r\n    public function newInstance()\r\n        {\r\n            if ($this->_prototype === null) {\r\n869            if (PHP_VERSION_ID >= 50513 || PHP_VERSION_ID === 50429 || PHP_VERSION_ID === 50513) {\r\n                    $this->_prototype = $this->reflClass->newInstanceWithoutConstructor();\r\n                } else {\r\n                    $this->_prototype = unserialize(sprintf('O:%d:\"%s\":0:{}', strlen($this->name), $this->name));\r\n                }\r\n            }\r\n            return clone $this->_prototype;\r\n        }\r\n```\r\nit just worked. \r\nI was using this repository [Doctors](https://github.com/benaich/Doctors) from @benaich for tutorial purposes when i got into this issue.\r\n\r\nI hope this might help.\r\nRegards from Cuba.\r\n"}}
{"actor":{"display_login":"abel406"}}