我刚刚升级到symfony 2.7,并且有令人讨厌的行为。
我的config.yml中的某些连接是可选项,并描述了不打算在每个prod实例中使用的外部数据库。
执行缓存时:清除,现在似乎检查了每个连接,即使我不希望它们在特定服务器上处于活动状态。
设置--no-warmup选项时,问题发生在一半时间
php app/console cache:clear --env=prod --no-warmup --verbose
[学说\ DBAL \异常\ ConnectionException]
驱动程序中发生异常:SQLSTATE [42000] [1049]未知 数据库'bal_syncrho_database'异常跟踪:()at /var/www/ror3/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php:103 Doctrine \ DBAL \ Driver \ AbstractMySQLDriver-> convertException()at /var/www/ror3/vendor/doctrine/dbal/lib/Doctrine/DBAL/DBALException.php:133 Doctrine \ DBAL \ DBALException :: driverException()at /var/www/ror3/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOMySql/Driver.php:47 Doctrine \ DBAL \ Driver \ PDOMySql \ Driver-> connect()at /var/www/ror3/vendor/doctrine/dbal/lib/Doctrine/DBAL/Connection.php:360 Doctrine \ DBAL \ Connection-> connect()at /var/www/ror3/vendor/doctrine/dbal/lib/Doctrine/DBAL/Connection.php:429 Doctrine \ DBAL \ Connection-> getDatabasePlatformVersion()at /var/www/ror3/vendor/doctrine/dbal/lib/Doctrine/DBAL/Connection.php:389 Doctrine \ DBAL \ Connection-> detectDatabasePlatform()at /var/www/ror3/vendor/doctrine/dbal/lib/Doctrine/DBAL/Connection.php:328 Doctrine \ DBAL \ Connection-> getDatabasePlatform()at /var/www/ror3/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php:763 Doctrine \ ORM \ Mapping \ ClassMetadataFactory-> getTargetPlatform()at /var/www/ror3/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php:616 教义\ ORM \映射\ ClassMetadataFactory-> completeIdGeneratorMapping() 在 /var/www/ror3/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php:174 Doctrine \ ORM \ Mapping \ ClassMetadataFactory-> doLoadMetadata()at /var/www/ror3/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/AbstractClassMetadataFactory.php:332 教义\共同\持久性\映射\ AbstractClassMetadataFactory-> loadMetadata() 在 /var/www/ror3/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php:78 Doctrine \ ORM \ Mapping \ ClassMetadataFactory-> loadMetadata()at /var/www/ror3/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/AbstractClassMetadataFactory.php:216 教义\共同\持久性\映射\ AbstractClassMetadataFactory-> getMetadataFor() 在 /var/www/ror3/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/AbstractClassMetadataFactory.php:115 教义\共同\持久性\映射\ AbstractClassMetadataFactory-> getAllMetadata() 在 /var/www/ror3/vendor/symfony/symfony/src/Symfony/Bridge/Doctrine/CacheWarmer/ProxyCacheWarmer.php:69 Symfony \ Bridge \ Doctrine \ CacheWarmer \ ProxyCacheWarmer-> warmUp()at /var/www/ror3/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/CacheWarmer/CacheWarmerAggregate.php:48 的Symfony \组件\ HttpKernel \ CacheWarmer \ CacheWarmerAggregate->预热() 在/var/www/ror3/app/bootstrap.php.cache:2641 Symfony \ Component \ HttpKernel \ Kernel-> initializeContainer()at /var/www/ror3/app/bootstrap.php.cache:2411 Symfony \ Component \ HttpKernel \ Kernel-> boot()at /var/www/ror3/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Console/Application.php:70 Symfony \ Bundle \ FrameworkBundle \ Console \ Application-> doRun()at /var/www/ror3/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:120 Symfony \ Component \ Console \ Application-> run()在
的/ var / WWW / ror3 /应用/控制台:27
答案 0 :(得分:71)
Doctrine正试图确定数据库平台版本。
您可以避免在Doctrine DBAL Configuration服务器版本中添加此行为。来自doc:
在Doctrine DBAL 2.5中添加了server_version选项,即 由DoctrineBundle 1.3使用。此选项的值应与您的匹配 数据库服务器版本(使用postgres -V或psql -V命令查找 你的PostgreSQL版本和mysql -V来获得你的MySQL版本。
如果您没有定义此选项但尚未创建数据库,则可能会出现PDOException错误,因为Doctrine将会 尝试自动猜测数据库服务器版本,没有 可用。强>
例如:
#config.yml
doctrine:
dbal:
...
server_version: 5.6
希望这个帮助