From 2d928d38482e4e3d69f4e30b19eb64beaed8429b Mon Sep 17 00:00:00 2001 From: Ankur Kaneria Date: Tue, 14 Jun 2016 10:51:57 -0500 Subject: [PATCH 1/2] MAGETWO-54205: After Disable/Enable Magento modules via CLI all cache types become disabled - Create regenerate flag when module gets uninstalled --- src/MagentoHackathon/Composer/Magento/Plugin.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/MagentoHackathon/Composer/Magento/Plugin.php b/src/MagentoHackathon/Composer/Magento/Plugin.php index 93125bb7..090b8b49 100644 --- a/src/MagentoHackathon/Composer/Magento/Plugin.php +++ b/src/MagentoHackathon/Composer/Magento/Plugin.php @@ -129,6 +129,12 @@ public function onPackageUnistall(\Composer\Installer\PackageEvent $event) $deployStrategy = $this->installer->getDeployStrategy($package); $deployStrategy->rmdirRecursive($packageInstallationPath . $ds . $libPath); $deployStrategy->rmdirRecursive($packageInstallationPath . $ds . $magentoPackagePath); + + // Force regeneration of var/di, var/cache, var/generation on next object manager invocation + if (file_exists($this->installer->getTargetDir() . $this->varFolder)) { + $filename = $this->installer->getTargetDir() . $this->varFolder . $this->regenerate; + touch($filename); + } } /** @@ -155,6 +161,8 @@ public function onNewCodeEvent(\Composer\Script\Event $event) $this->deployManager->doDeploy(); $this->deployLibraries(); $this->saveVendorDirPath($event->getComposer()); + + // Force regeneration of var/di, var/cache, var/generation on next object manager invocation if (file_exists($this->installer->getTargetDir() . $this->varFolder)) { $filename = $this->installer->getTargetDir() . $this->varFolder . $this->regenerate; touch($filename); From b55ddcbb26861e06a1407361f8b4b30fa5a79108 Mon Sep 17 00:00:00 2001 From: Ankur Kaneria Date: Tue, 14 Jun 2016 12:11:53 -0500 Subject: [PATCH 2/2] MAGETWO-54205: After Disable/Enable Magento modules via CLI all cache types become disabled - minor update based on review --- .../Composer/Magento/Plugin.php | 27 ++++++++++--------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/src/MagentoHackathon/Composer/Magento/Plugin.php b/src/MagentoHackathon/Composer/Magento/Plugin.php index 090b8b49..ec845f72 100644 --- a/src/MagentoHackathon/Composer/Magento/Plugin.php +++ b/src/MagentoHackathon/Composer/Magento/Plugin.php @@ -129,12 +129,7 @@ public function onPackageUnistall(\Composer\Installer\PackageEvent $event) $deployStrategy = $this->installer->getDeployStrategy($package); $deployStrategy->rmdirRecursive($packageInstallationPath . $ds . $libPath); $deployStrategy->rmdirRecursive($packageInstallationPath . $ds . $magentoPackagePath); - - // Force regeneration of var/di, var/cache, var/generation on next object manager invocation - if (file_exists($this->installer->getTargetDir() . $this->varFolder)) { - $filename = $this->installer->getTargetDir() . $this->varFolder . $this->regenerate; - touch($filename); - } + $this->requestRegeneration(); } /** @@ -161,12 +156,7 @@ public function onNewCodeEvent(\Composer\Script\Event $event) $this->deployManager->doDeploy(); $this->deployLibraries(); $this->saveVendorDirPath($event->getComposer()); - - // Force regeneration of var/di, var/cache, var/generation on next object manager invocation - if (file_exists($this->installer->getTargetDir() . $this->varFolder)) { - $filename = $this->installer->getTargetDir() . $this->varFolder . $this->regenerate; - touch($filename); - } + $this->requestRegeneration(); } @@ -289,4 +279,17 @@ private function saveVendorDirPath(Composer $composer) AUTOLOAD; file_put_contents($vendorPathFile, $content); } + + /** + * Force regeneration of var/di, var/cache, var/generation on next object manager invocation + * + * @return void + */ + private function requestRegeneration() + { + if (is_writable($this->installer->getTargetDir() . $this->varFolder)) { + $filename = $this->installer->getTargetDir() . $this->varFolder . $this->regenerate; + touch($filename); + } + } }