I have a Symfony 2.3 app using Doctrine >=2.2.3,<2.4-dev. I upgraded my production server to PHP 5.6 which caused the following error with the FOSUserBundle:
Warning: Erroneous data format for unserializing 'air\cms2Bundle\Entity\User' in /vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php on line 833
Fatal error: __clone method called on non-object in /vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php on line 837
The entity is a just an extension of the FOSUserBundle BaseUser, as shown here. The FOSUserBundle BaseUser class can be found here.
After doing some initial research, I found out that the error is caused by a PHP 5.6 and Doctrine 2 compatibility issue due to a change in Serializable in PHP 5.6. The Doctrine developers have fixed the issue (see GitHub pull request), but I'm still not sure which version of Doctrine 2 I have to require in the composer.json to get the fix and I'm also not sure to which versions of Symfony 2 it is compatible.
My current composer.json:
"require": {
"php": ">=5.3.3",
"symfony/symfony": "2.3.*",
"doctrine/orm": ">=2.2.3,<2.4-dev",
"doctrine/doctrine-bundle": "1.2.*",
...
},
Update:
I've updated my composer.json to:
"require": {
"php": ">=5.6.0",
"symfony/symfony": "2.6.*",
"doctrine/orm": "~2.5",
"doctrine/doctrine-bundle": "1.2.*",
...
},
But unfortunately this causes a unreseovlable dependency issue:
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.
Problem 1
- Conclusion: don't install doctrine/orm v2.5.4
- Conclusion: remove doctrine/doctrine-bundle v1.2.0
- Conclusion: remove doctrine/dbal v2.4.5
- Conclusion: don't install doctrine/orm v2.5.3
- Conclusion: don't install doctrine/orm v2.5.2
- Conclusion: don't install doctrine/orm v2.5.1
- Conclusion: don't install doctrine/dbal v2.4.5
- Conclusion: don't install doctrine/dbal v2.5.2|install doctrine/dbal v2.4.5
- Conclusion: don't install doctrine/dbal v2.5.3|install doctrine/dbal v2.4.5
- Conclusion: don't install doctrine/dbal v2.5.4|install doctrine/dbal v2.4.5
- Installation request for doctrine/doctrine-bundle 1.2.* -> satisfiable by doctrine/doctrine-bundle[v1.2.0].
- Installation request for doctrine/orm ~2.5 -> satisfiable by doctrine/orm[v2.5.0, v2.5.1, v2.5.2, v2.5.3, v2.5.4].
- doctrine/doctrine-bundle v1.2.0 requires doctrine/dbal >=2.2,<2.5-dev -> satisfiable by doctrine/dbal[v2.4.5, 2.2.0, 2.2.1, 2.2.2, 2.3.0, 2.3.1, 2.3.2, 2.3.3, 2.3.4, 2.3.5, v2.4.0, v2.4.1, v2.4.2, v2.4.3, v2.4.4].
- Can only install one of: doctrine/dbal[v2.5.0, 2.2.0].
- Can only install one of: doctrine/dbal[v2.5.0, 2.2.1].
- Can only install one of: doctrine/dbal[v2.5.0, 2.2.2].
- Can only install one of: doctrine/dbal[v2.5.0, 2.3.0].
- Can only install one of: doctrine/dbal[v2.5.0, 2.3.1].
- Can only install one of: doctrine/dbal[v2.5.0, 2.3.2].
- Can only install one of: doctrine/dbal[v2.5.0, 2.3.3].
- Can only install one of: doctrine/dbal[v2.5.0, 2.3.4].
- Can only install one of: doctrine/dbal[v2.5.0, 2.3.5].
- Can only install one of: doctrine/dbal[v2.5.0, v2.4.0].
- Can only install one of: doctrine/dbal[v2.5.0, v2.4.1].
- Can only install one of: doctrine/dbal[v2.5.0, v2.4.2].
- Can only install one of: doctrine/dbal[v2.5.0, v2.4.3].
- Can only install one of: doctrine/dbal[v2.5.0, v2.4.4].
- doctrine/orm v2.5.0 requires doctrine/dbal >=2.5-dev,<2.6-dev -> satisfiable by doctrine/dbal[v2.5.0, v2.5.1, v2.5.2, v2.5.3, v2.5.4].
- Conclusion: don't install doctrine/dbal v2.5.1
I also tried to updated my composer.json to
"require": {
"php": ">=5.6.0",
"symfony/symfony": "2.6.*",
"doctrine/common": "~2.5",
...
},
But this causes an error on the app/console clear:cache run after composer has finished updating.
Loading composer repositories with package information
Updating dependencies (including require-dev)
- Removing doctrine/orm (v2.4.8)
- Removing doctrine/doctrine-bundle (v1.2.0)
- Removing doctrine/dbal (v2.4.5)
- Removing jdorn/sql-formatter (v1.2.17)
Writing lock file
Generating autoload files
> Incenteev\ParameterHandler\ScriptHandler::buildParameters
Updating the "app/config/parameters.yml" file
> Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::buildBootstrap
> Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache
PHP Fatal error: Class 'Doctrine\Bundle\DoctrineBundle\DoctrineBundle' not found in /vagrant/logbookWebApp-data/app/AppKernel.php on line 16
Script Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache handling the post-update-cmd event terminated with an exception
[RuntimeException]
An error occurred when executing the "'cache:clear --no-warmup'" command.
update [--prefer-source] [--prefer-dist] [--dry-run] [--dev] [--no-dev] [--lock] [--no-plugins] [--no-custom-installers] [--no-autoloader] [--no-scripts] [--no-progress] [--with-dependencies] [-v|vv|vvv|--verbose] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--ignore-platform-reqs] [--prefer-stable] [--prefer-lowest] [-i|--interactive] [--] [<packages>]...