Ensure query cache is not ArrayCache in production
This commit is contained in:
parent
193e31f22a
commit
61c72e4aa7
@ -381,10 +381,16 @@ class Configuration extends \Doctrine\DBAL\Configuration
|
||||
*/
|
||||
public function ensureProductionSettings()
|
||||
{
|
||||
if ( ! $this->getQueryCacheImpl()) {
|
||||
$queryCacheImpl = $this->getQueryCacheImpl();
|
||||
|
||||
if ( ! $queryCacheImpl) {
|
||||
throw ORMException::queryCacheNotConfigured();
|
||||
}
|
||||
|
||||
if ($queryCacheImpl instanceof ArrayCache) {
|
||||
throw ORMException::queryCacheUsesNonPersistentCache($queryCacheImpl);
|
||||
}
|
||||
|
||||
$metadataCacheImpl = $this->getMetadataCacheImpl();
|
||||
|
||||
if ( ! $metadataCacheImpl) {
|
||||
|
@ -233,6 +233,16 @@ class ORMException extends Exception
|
||||
return new self('Class Metadata Cache is not configured.');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Doctrine\Common\Cache\Cache $cache
|
||||
*
|
||||
* @return ORMException
|
||||
*/
|
||||
public static function queryCacheUsesNonPersistentCache(CacheDriver $cache)
|
||||
{
|
||||
return new self('Query Cache uses a non-persistent cache driver, ' . get_class($cache) . '.');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Doctrine\Common\Cache\Cache $cache
|
||||
*
|
||||
|
@ -147,7 +147,7 @@ class ConfigurationTest extends PHPUnit_Framework_TestCase
|
||||
/**
|
||||
* Configures $this->configuration to use production settings.
|
||||
*
|
||||
* @param boolean $skipCache Do not configure a cache of this type, either "query" or "metadata".
|
||||
* @param string $skipCache Do not configure a cache of this type, either "query" or "metadata".
|
||||
*/
|
||||
protected function setProductionSettings($skipCache = false)
|
||||
{
|
||||
@ -184,6 +184,16 @@ class ConfigurationTest extends PHPUnit_Framework_TestCase
|
||||
$this->configuration->ensureProductionSettings();
|
||||
}
|
||||
|
||||
public function testEnsureProductionSettingsQueryArrayCache()
|
||||
{
|
||||
$this->setProductionSettings();
|
||||
$this->configuration->setQueryCacheImpl(new ArrayCache());
|
||||
$this->setExpectedException(
|
||||
'Doctrine\ORM\ORMException',
|
||||
'Query Cache uses a non-persistent cache driver, Doctrine\Common\Cache\ArrayCache.');
|
||||
$this->configuration->ensureProductionSettings();
|
||||
}
|
||||
|
||||
public function testEnsureProductionSettingsMetadataArrayCache()
|
||||
{
|
||||
$this->setProductionSettings();
|
||||
|
Loading…
x
Reference in New Issue
Block a user