【发布时间】:2016-01-15 17:05:21
【问题描述】:
我有一个使用 Doctrine >=2.2.3,
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
实体只是 FOSUserBundle BaseUser 的一个扩展,如here 所示。 FOSUserBundle BaseUser 类可以在here找到。
经过初步研究,我发现该错误是由于 PHP 5.6 中 Serializable 的更改导致的 PHP 5.6 和 Doctrine 2 兼容性问题引起的。 Doctrine 开发人员已经解决了这个问题(参见GitHub pull request),但我仍然不确定我必须在composer.json 中要求哪个版本的 Doctrine 2 才能获得修复,我也不确定哪个版本的Symfony 2 是兼容的。
我现在的composer.json:
"require": {
"php": ">=5.3.3",
"symfony/symfony": "2.3.*",
"doctrine/orm": ">=2.2.3,<2.4-dev",
"doctrine/doctrine-bundle": "1.2.*",
...
},
更新:
我已将 composer.json 更新为:
"require": {
"php": ">=5.6.0",
"symfony/symfony": "2.6.*",
"doctrine/orm": "~2.5",
"doctrine/doctrine-bundle": "1.2.*",
...
},
但不幸的是,这会导致无法解决的依赖问题:
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
我还尝试将我的 composer.json 更新为
"require": {
"php": ">=5.6.0",
"symfony/symfony": "2.6.*",
"doctrine/common": "~2.5",
...
},
但这会导致 composer 完成更新后运行 app/console clear:cache 时出错。
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>]...
【问题讨论】:
-
请详细说明您遇到了什么错误
-
您链接到的拉取请求在很久以前被合并在所有仍然维护的 Doctrine 版本中。
-
Doctrine 2.4.8 是我在运行 symfony 2.8 的 php5.3 中所能获得的最大值
-
您在 composer.json 中设置的平台配置选项是什么? getcomposer.org/doc/06-config.md#platform
-
@xabbuh:你知道 Doctrine 2.4 分支是否包含提到的固定?
标签: symfony doctrine-orm fosuserbundle php-5.6