mirror of
https://github.com/doctrine/orm.git
synced 2026-03-24 06:52:09 +01:00
DDC-3120: Warning: Erroneous data format for unserializing PHP5.6+ #3873
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @doctrinebot on GitHub (May 11, 2014).
Originally assigned to: @Ocramius on GitHub.
Jira issue originally created by user techkey:
Hi all,
There seems to be something strange going on in the method
newInstance()of the class\Doctrine\ORM\Mapping\ClassMetadataInfo.The original class method looks like this:
{quote}\Doctrine\ORM\Mapping\ClassMetadataInfo#newInstance(){quote}
What 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.
That is because a class that implements \Serializable is expected to have the letter 'C' in the serialize string instead of the letter 'O'.
I've made a quick work-around like this:
{quote}\Doctrine\ORM\Mapping\ClassMetadataInfo#newInstance(){quote}
That seems to work in my isolated tests and with Symfony2 and Doctrine2 and FOSUserBundle together.
I've noticed this because the
Model\Userclass from FOSUserBundle implements\Serializable.I had to implement a check in Model\User class because when using {{'C:%d:"%s":0:{}'}} the $serialized parameter of the
unserializemethod in theModel\Userclass is a empty string then.That warning seems only to happen with PHP5.6+. PHP5.5.12 and below doesn't show that warning.
I hope someone can shine some light on this, thank you,
Cornelis.
@doctrinebot commented on GitHub (May 11, 2014):
@doctrinebot commented on GitHub (May 11, 2014):
Comment created by @ocramius:
Indeed, for PHP 5.4+ we should use
ReflectionClass#newInstanceWithoutConstructor()@doctrinebot commented on GitHub (May 11, 2014):
Comment created by techkey:
Just tested it. That works as expected, far more better then the dirty hacks I did, thanks a lot!
Any idea when this would be implemented into the code?
@doctrinebot commented on GitHub (May 11, 2014):
Comment created by @ocramius:
Send a pull request and I'll merge it later today (we could also need a failing test with an entity implementing the
Serializableinterface)@doctrinebot commented on GitHub (May 30, 2014):
Comment created by evertharmeling:
Seems to be a problem in the latest PHP 5.4 version too.
https://github.com/doctrine/doctrine2/pull/1045/
@doctrinebot commented on GitHub (May 30, 2014):
Comment created by @doctrinebot:
A related Github Pull-Request [GH-1045] was closed:
https://github.com/doctrine/doctrine2/pull/1045
@doctrinebot commented on GitHub (Jun 2, 2014):
Comment created by rkmax:
I am facing this same error i have PHP 5.5.13, I'm using Symfony, Doctrine ORM and FOSUserBUndle
@doctrinebot commented on GitHub (Jun 2, 2014):
Comment created by @ocramius:
[~rkmax] the patch landed in master (2.5.x) for now.
@doctrinebot commented on GitHub (Jun 2, 2014):
Comment created by @ocramius:
Merged via DDC-3147
@doctrinebot commented on GitHub (Jun 4, 2014):
Comment created by tbuhk:
When can we expect the version with this bugfix?
@doctrinebot commented on GitHub (Jun 8, 2014):
Comment created by gnuk:
Why don't you tag 2.4.3 version with this fix ? Because the error is already present in PHP 5.5.13 which is a stable version and it's a blocking issue when you're using FOSUserBundle for example. There is also no opened issue refering this version and the due date is in april.
@doctrinebot commented on GitHub (Jun 19, 2014):
Comment created by j.perovic:
I'm still seeing this bug, although my PHP_VERSION_ID is 50600 :(
So, version based condition is no good...
@doctrinebot commented on GitHub (Jun 19, 2014):
Comment created by @ocramius:
The approach to be taken for 50600 is still under discussion in php-internals.
@doctrinebot commented on GitHub (Jun 20, 2014):
Comment created by techkey:
Hi all,
I've just downloaded
PHP5.6RC1and updated doctrine and the error is back indeed.A little peek at the code starting on line 866 of file
Doctrine\ORM\Mapping\ClassMetadataInfo.phpshows this:As can be seen,
PHP5.6is out of the picture, it only checks for the exact versions5.4.29and5.5.13.So for the code to work correctly on
PHP5.6one can addPHP5.6to the test condition, or just skip the test all together if you don't mind the oldPHP5.3. According to PHP,ReflectionClass::newInstanceWithoutConstructoris available sincePHP >= 5.4.0.Greetings, Cornelis.
@doctrinebot commented on GitHub (Jun 21, 2014):
Comment created by @ocramius:
As I already pointed out, this is still being discussed in php internals. See http://news.php.net/php.internals/75009
This won't be dealt with in 5.6 until there's either a stable release or internals decides what has to be done.
@doctrinebot commented on GitHub (Jun 21, 2014):
Comment created by @ocramius:
Also,
ReflectionClass#newInstanceWithoutConstructor()still doesn't cover the pre-existing "hack" usingunserialize, so we're still waiting for a reliable API from PHP core.@doctrinebot commented on GitHub (Jul 23, 2014):
Comment created by chasen:
Using PHP 5.6RC2 and ORM 2.4.4 I am still experiencing this issue. I have also tested with PHP 5.5.15 and I am still getting the issue. Do i need to be using a different build of ORM to have the fix applied?
@doctrinebot commented on GitHub (Jul 23, 2014):
Comment created by pascall:
Hi,
I'm using 5.6.0beta3 and ORM 2.4.4 and i have the same probleme
Warning: Erroneous data format for unserializing .. in orm/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php line 872
and in current code in ClassMetadataInfo.php line 872 is :
@doctrinebot commented on GitHub (Jul 23, 2014):
Comment created by evertharmeling:
As stated by Marco Pivetta; "This won't be dealt with in 5.6 until there's either a stable release or internals decides what has to be done.". And besides that 5.6 still is in development, not stable.
If you still want to use 5.6 you can fork the code and extend the 5.4 / 5.5 check to support 5.6.
@doctrinebot commented on GitHub (Jul 23, 2014):
Comment created by chasen:
5.6 has an RC which should mean a stable API, and that only bugs will be fixed before an official stable release?
@doctrinebot commented on GitHub (Jul 23, 2014):
Comment created by evertharmeling:
Looking at http://news.php.net/php.internals/75966 it's still being discussed, and they are planning to have it fixed in RC3.
@doctrinebot commented on GitHub (Jul 23, 2014):
Comment created by @ocramius:
Internals still didn't get to a clear decision. Until then, we won't support 5.6 officially.
@doctrinebot commented on GitHub (Jul 24, 2014):
Comment created by Ronan:
Same error encountered with PHP 5.5.13 (cli) (built: May 30 2014 10:43:29)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies
with Zend OPcache v7.0.4-dev, Copyright (c) 1999-2014, by Zend Technologies
with Xdebug v2.2.3, Copyright (c) 2002-2013, by Derick Rethans
(PHP 5.5 installed via http://php-osx.liip.ch/)
@doctrinebot commented on GitHub (Jul 24, 2014):
Comment created by @ocramius:
[~Ronan] what D2 version? We fixed it for 2.4.x (temporarily)
@doctrinebot commented on GitHub (Jul 24, 2014):
Comment created by Ronan:
My bad: reading my composer.lock: doctrine/orm, v2.4.2, ref
0363a5548d, "time": "2014-02-08 16:35:09"... Well.. this is was an old one !composer updatefixed it. Sorry for disturbing.@doctrinebot commented on GitHub (Aug 12, 2014):
Comment created by chasen:
Im still getting this error running php 5.6RC2 and the dev-master(
6ac19b04bf) build of D2/orm. Am i missing something?@doctrinebot commented on GitHub (Aug 12, 2014):
Comment created by @ocramius:
This was semi-fixed in PHP5.6-RC3, and it will be patched into ORM once doctrine/instantiator is out
@doctrinebot commented on GitHub (Aug 12, 2014):
Comment created by chasen:
Ok good to know. Thanks
@doctrinebot commented on GitHub (Aug 13, 2014):
Comment created by @ocramius:
Not yet fixed for PHP 5.6
@doctrinebot commented on GitHub (Aug 14, 2014):
Comment created by @ocramius:
Provided a hotfix proposal at https://github.com/doctrine/doctrine2/pull/1109 - please check it out with PHP 5.6.0-RC3 or later
@doctrinebot commented on GitHub (Aug 27, 2014):
Comment created by @doctrinebot:
A related Github Pull-Request [GH-1109] was closed:
https://github.com/doctrine/doctrine2/pull/1109
@doctrinebot commented on GitHub (Aug 27, 2014):
Issue was closed with resolution "Fixed"
@doctrinebot commented on GitHub (Aug 27, 2014):
Comment created by @ocramius:
Due to a new introduced dependency, this issue will only be solved for PHP 5.6 in 2.5.0 and later.
@doctrinebot commented on GitHub (Aug 28, 2014):
Comment created by @doctrinebot:
A related Github Pull-Request [GH-1109] was assigned:
https://github.com/doctrine/doctrine2/pull/1109
@doctrinebot commented on GitHub (Sep 10, 2014):
Comment created by dominik.zogg@gmail.com:
@ocramius would be great if there where backports for 2.4 and 2.3
@doctrinebot commented on GitHub (Sep 28, 2014):
Comment created by r1pp3rj4ck:
I agree with Dominik, we'd like to use the latest stable version and would need this patch.
@doctrinebot commented on GitHub (Oct 6, 2014):
Comment created by @ocramius:
This has been backported in DDC-3339
@doctrinebot commented on GitHub (May 13, 2015):
Comment created by sysko:
I still have this error even 2.5.0 and PHP5.6
https://travis-ci.org/allan-simon/oauth2-symfony2-vagrant-fosuserbundle/jobs/62429219
@abel406 commented on GitHub (Jul 15, 2016):
Hi every one,
I 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:
and changing the C:\wamp64\www\doctors\vendor\doctrine\orm\lib\Doctrine\ORM\Mapping\ClassMetadataInfo.php at line 869 like this:
it just worked.
I was using this repository Doctors from @benaich for tutorial purposes when i got into this issue.
I hope this might help.
Regards from Cuba.
@Ocramius commented on GitHub (Jul 15, 2016):
This is handled by doctrine/instantiator in 2.5
@abel406 commented on GitHub (Jul 15, 2016):
So would you recommend me to upgrade to doctrine 2.5 ?
@abel406 commented on GitHub (Jul 15, 2016):
Definitely no possible for me. Look the results:
@Ocramius commented on GitHub (Jul 15, 2016):
That is for you to solve, not a bug in ORM :-)
@abel406 commented on GitHub (Jul 15, 2016):
Thanks, i already solved it.That was my original post, the solution. Thanks.
@diriy commented on GitHub (Aug 3, 2016):
I got the same error with Doctrine 2.5, Symfony 3.1, PHP 5.6, Windows 7 (64x) and 've been dissapointed a bit... How can I solve the issue?
@8khan commented on GitHub (Nov 22, 2017):
i khow this it an old topic, but i solve it with this
you need khow your php version, can add a var_dump(PHP_VERSION_ID); on app.php
then add your version on line 830 on \www\vendor\doctrine\orm\lib\Doctrine\ORM\Mapping\ClassMetadataInfo.php file
another think that help is able display php errors