diff --git a/app/config/eccube/packages/codeception/doctrine.yaml b/app/config/eccube/packages/codeception/doctrine.yaml new file mode 100644 index 00000000000..e5f04eb0bdf --- /dev/null +++ b/app/config/eccube/packages/codeception/doctrine.yaml @@ -0,0 +1,30 @@ +# https://github.com/symfony/demo/blob/master/config/packages/prod/doctrine.yaml +# https://symfony.com/doc/master/bundles/DoctrineBundle/configuration.html +doctrine: + orm: + metadata_cache_driver: + type: service + id: doctrine.app_cache_provider + query_cache_driver: + type: service + id: doctrine.app_cache_provider + result_cache_driver: + type: service + id: doctrine.app_cache_provider + second_level_cache: + region_cache_driver: + type: service + id: doctrine.app_cache_provider + +services: + doctrine.app_cache_provider: + class: Symfony\Component\Cache\DoctrineProvider + public: false + arguments: + - '@doctrine.app_cache_pool' + +framework: + cache: + pools: + doctrine.app_cache_pool: + adapter: cache.app diff --git a/codeception/_data/plugins/Horizon-1.0.1.tgz b/codeception/_data/plugins/Horizon-1.0.1.tgz index 0633c80942d..e8d73d8e2d8 100644 Binary files a/codeception/_data/plugins/Horizon-1.0.1.tgz and b/codeception/_data/plugins/Horizon-1.0.1.tgz differ diff --git a/codeception/acceptance/EA10PluginCest.php b/codeception/acceptance/EA10PluginCest.php index 67a825a467f..16de48758a3 100644 --- a/codeception/acceptance/EA10PluginCest.php +++ b/codeception/acceptance/EA10PluginCest.php @@ -793,6 +793,13 @@ public function __construct(AcceptanceTester $I) $this->traits['\Plugin\Horizon\Entity\CartTrait'] = 'src/Eccube/Entity/Cart'; } + public function アップデート() + { + // アップデートで新たしいカラムが追加される + $this->columns[] = 'dtb_dash.new_column'; + return parent::アップデート(); + } + public static function start(AcceptanceTester $I) { return new self($I); @@ -810,6 +817,13 @@ public function __construct(AcceptanceTester $I) $this->traits['\Plugin\Horizon\Entity\CartTrait'] = 'src/Eccube/Entity/Cart'; } + public function アップデート() + { + // アップデートで新たしいカラムが追加される + $this->columns[] = 'dtb_dash.new_column'; + return parent::アップデート(); + } + public static function start(AcceptanceTester $I) { $result = new self($I); diff --git a/codeception/acceptance/EF01TopCest.php b/codeception/acceptance/EF01TopCest.php index a51d4455edc..4da7d3d8432 100644 --- a/codeception/acceptance/EF01TopCest.php +++ b/codeception/acceptance/EF01TopCest.php @@ -31,12 +31,14 @@ public function _after(\AcceptanceTester $I) private function clearDoctrineCache() { - // APP_ENV=prodで実行した際は, 直接データを投入しても反映されないため, + // APP_ENV=prod/codeceptionで実行した際は, 直接データを投入しても反映されないため, // キャッシュを削除して表示できるようにする $fs = new Symfony\Component\Filesystem\Filesystem(); - $cacheDir = __DIR__.'/../../var/cache/prod/pools'; - if ($fs->exists($cacheDir)) { - $fs->remove($cacheDir); + foreach (['prod', 'codeception'] as $env) { + $cacheDir = __DIR__."/../../var/cache/${env}/pools"; + if ($fs->exists($cacheDir)) { + $fs->remove($cacheDir); + } } } diff --git a/src/Eccube/Service/PluginService.php b/src/Eccube/Service/PluginService.php index 885e8530373..96d817f91b2 100644 --- a/src/Eccube/Service/PluginService.php +++ b/src/Eccube/Service/PluginService.php @@ -282,6 +282,9 @@ public function postInstall($config, $source) */ public function generateProxyAndUpdateSchema(Plugin $plugin, $config, $uninstall = false, $saveMode = true) { + // キャッシュしたメタデータを利用しないようにキャッシュドライバを外しておく + $this->entityManager->getMetadataFactory()->setCacheDriver(null); + $this->generateProxyAndCallback(function ($generatedFiles, $proxiesDirectory) use ($saveMode) { $this->schemaService->updateSchema($generatedFiles, $proxiesDirectory, $saveMode); }, $plugin, $config, $uninstall); @@ -747,6 +750,8 @@ public function updatePlugin(Plugin $plugin, $meta) $em->persist($plugin); + $this->generateProxyAndUpdateSchema($plugin, $meta); + if ($plugin->isInitialized()) { $this->callPluginManagerMethod($meta, 'update'); } diff --git a/src/Eccube/Util/CacheUtil.php b/src/Eccube/Util/CacheUtil.php index 01ff49c2b40..eacd7687939 100644 --- a/src/Eccube/Util/CacheUtil.php +++ b/src/Eccube/Util/CacheUtil.php @@ -17,6 +17,7 @@ use Symfony\Component\Console\Input\ArrayInput; use Symfony\Component\Console\Output\BufferedOutput; use Symfony\Component\Console\Output\OutputInterface; +use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\Filesystem\Filesystem; use Symfony\Component\Finder\Finder; @@ -29,21 +30,30 @@ */ class CacheUtil implements EventSubscriberInterface { + + const DOCTRINE_APP_CACHE_KEY = 'doctrine.app_cache_pool'; + private $clearCacheAfterResponse = false; /** * @var KernelInterface */ protected $kernel; + /** + * @var ContainerInterface + */ + private $container; /** * CacheUtil constructor. * * @param KernelInterface $kernel + * @param ContainerInterface $container */ - public function __construct(KernelInterface $kernel) + public function __construct(KernelInterface $kernel, ContainerInterface $container) { $this->kernel = $kernel; + $this->container = $container; } /** @@ -100,7 +110,6 @@ public function forceClearCache(PostResponseEvent $event) /** * Doctrineのキャッシュを削除します. - * APP_ENV=prodの場合のみ実行されます. * * @param null $env * @@ -110,7 +119,7 @@ public function forceClearCache(PostResponseEvent $event) */ public function clearDoctrineCache() { - if ($this->kernel->getEnvironment() !== 'prod') { + if (!$this->container->has(self::DOCTRINE_APP_CACHE_KEY)) { return; } $console = new Application($this->kernel); @@ -118,7 +127,7 @@ public function clearDoctrineCache() $command = [ 'command' => 'cache:pool:clear', - 'pools' => ['doctrine.app_cache_pool'], + 'pools' => [self::DOCTRINE_APP_CACHE_KEY], '--no-ansi' => true, ];