From 6ede84af1b17ea8c6d9f18009e280e9970a9c574 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Jakes=CC=8C?= Date: Wed, 24 Jul 2019 10:51:37 +0200 Subject: [PATCH] Use only array cache in Doctrine at the moment [MAILPOET-2014] --- lib/Doctrine/ConfigurationFactory.php | 15 +-------------- .../Doctrine/ConfigurationFactoryTest.php | 9 ++++----- 2 files changed, 5 insertions(+), 19 deletions(-) diff --git a/lib/Doctrine/ConfigurationFactory.php b/lib/Doctrine/ConfigurationFactory.php index b76b787454..1051cfc23b 100644 --- a/lib/Doctrine/ConfigurationFactory.php +++ b/lib/Doctrine/ConfigurationFactory.php @@ -2,10 +2,8 @@ namespace MailPoet\Doctrine; -use MailPoet\Config\Env; use MailPoetVendor\Doctrine\Common\Annotations\SimpleAnnotationReader; use MailPoetVendor\Doctrine\Common\Cache\ArrayCache; -use MailPoetVendor\Doctrine\Common\Cache\FilesystemCache; use MailPoetVendor\Doctrine\Common\Proxy\AbstractProxyFactory; use MailPoetVendor\Doctrine\ORM\Configuration; use MailPoetVendor\Doctrine\ORM\Mapping\UnderscoreNamingStrategy; @@ -30,10 +28,6 @@ class ConfigurationFactory { $this->configureMetadata($configuration); $this->configureProxies($configuration); $this->configureCache($configuration); - - if (!$this->is_dev_mode) { - $configuration->ensureProductionSettings(); - } return $configuration; } @@ -62,14 +56,7 @@ class ConfigurationFactory { } private function configureCache(Configuration $configuration) { - if ($this->is_dev_mode) { - $cache = new ArrayCache(); - } else { - $cache_dir = Env::$cache_path . '/doctrine'; - $cache = new FilesystemCache($cache_dir); - $cache->setNamespace('mp3-' . md5($cache_dir) . '-'); - } - + $cache = new ArrayCache(); $configuration->setQueryCacheImpl($cache); $configuration->setResultCacheImpl($cache); } diff --git a/tests/integration/Doctrine/ConfigurationFactoryTest.php b/tests/integration/Doctrine/ConfigurationFactoryTest.php index dac3ddcd2f..87246f763b 100644 --- a/tests/integration/Doctrine/ConfigurationFactoryTest.php +++ b/tests/integration/Doctrine/ConfigurationFactoryTest.php @@ -6,7 +6,6 @@ use MailPoet\Doctrine\ConfigurationFactory; use MailPoet\Doctrine\MetadataCache; use MailPoet\Doctrine\TablePrefixMetadataFactory; use MailPoetVendor\Doctrine\Common\Cache\ArrayCache; -use MailPoetVendor\Doctrine\Common\Cache\FilesystemCache; use MailPoetVendor\Doctrine\Common\Proxy\AbstractProxyFactory; use MailPoetVendor\Doctrine\ORM\Configuration; use MailPoetVendor\Doctrine\ORM\Mapping\Driver\AnnotationDriver; @@ -25,6 +24,10 @@ class ConfigurationFactoryTest extends \MailPoetTest { expect($configuration->getMetadataCacheImpl())->isInstanceOf(MetadataCache::class); expect($configuration->getMetadataDriverImpl())->isInstanceOf(AnnotationDriver::class); + // cache + expect($configuration->getQueryCacheImpl())->isInstanceOf(ArrayCache::class); + expect($configuration->getResultCacheImpl())->isInstanceOf(ArrayCache::class); + // proxies expect(realpath($configuration->getProxyDir()))->equals(realpath(__DIR__ . '/../../../generated/doctrine-proxies')); expect($configuration->getProxyNamespace())->equals('MailPoetDoctrineProxies'); @@ -34,15 +37,11 @@ class ConfigurationFactoryTest extends \MailPoetTest { // dev mode $configuration_factory = new ConfigurationFactory(true); $configuration = $configuration_factory->createConfiguration(); - expect($configuration->getQueryCacheImpl())->isInstanceOf(ArrayCache::class); - expect($configuration->getResultCacheImpl())->isInstanceOf(ArrayCache::class); expect($configuration->getAutoGenerateProxyClasses())->equals(AbstractProxyFactory::AUTOGENERATE_FILE_NOT_EXISTS); // production mode $configuration_factory = new ConfigurationFactory(false); $configuration = $configuration_factory->createConfiguration(); - expect($configuration->getQueryCacheImpl())->isInstanceOf(FilesystemCache::class); - expect($configuration->getResultCacheImpl())->isInstanceOf(FilesystemCache::class); expect($configuration->getAutoGenerateProxyClasses())->equals(AbstractProxyFactory::AUTOGENERATE_NEVER); } }