From c115a0eed361af179804f5c862bea5ec38bb57f1 Mon Sep 17 00:00:00 2001 From: Luke Rodgers Date: Fri, 16 Oct 2020 15:59:59 +0100 Subject: [PATCH] Update DeployManager.php to hard fail on errors We had a project fail to composer install with the following error ``` PHP Warning: Uncaught Exception: Warning: require(/var/www/vhosts/example.com/staging/releases/1602858012/setup/config/application.config.php): failed to open stream: No such file or directory in /var/www/vhosts/example.com/staging/releases/1602858012/vendor/magento/framework/Console/Cli.php on line 78 in /var/www/vhosts/example.com/staging/releases/1602858012/vendor/magento/framework/App/ErrorHandler.php:61 Stack trace: #0 /var/www/vhosts/example.com/staging/releases/1602858012/vendor/magento/framework/Console/Cli.php(78): Magento\Framework\App\ErrorHandler->handler(2, 'require(/var/ww...', '/var/www/vhosts...', 78, Array) #1 /var/www/vhosts/example.com/staging/releases/1602858012/vendor/magento/framework/Console/Cli.php(78): require() #2 /var/www/vhosts/example.com/staging/releases/1602858012/bin/magento(22): Magento\Framework\Console\Cli->__construct('Magento CLI') #3 {main} thrown in /var/www/vhosts/example.com/staging/releases/1602858012/vendor/magento/framework/App/ErrorHandler.php on line 61 ``` When debugging i could see that a lot of the files from `magento/magento2-base` had not been copied over. I can see an error produced when running with `-vvv` ``` start magento deploy via deployManager start magento deploy for magento/magento2-base mkdir(): File exists start magento deploy for magento/magento2-base mkdir(): File exists start magento deploy for magento/magento2-ee-base jump over deployLibraries as no Magento libraryPath is set ``` I debugged and the issue was that previously on our NFS we had no `pub/media/import` but now we have had one created. Now when magento tried to `composer install` it was trying to copy over https://github.com/magento/magento2/blob/2.4-develop/pub/media/import/.htaccess, it faced this `File exists` error and stopped copying over the remainder of the files silently. I think `composer install` should fail loud and early in these scenarios, removing the error handling entirely allows the exception to bubble up. Any feedback appreciated --- src/MagentoHackathon/Composer/Magento/DeployManager.php | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/MagentoHackathon/Composer/Magento/DeployManager.php b/src/MagentoHackathon/Composer/Magento/DeployManager.php index 9776bc92..b2119163 100644 --- a/src/MagentoHackathon/Composer/Magento/DeployManager.php +++ b/src/MagentoHackathon/Composer/Magento/DeployManager.php @@ -93,13 +93,7 @@ public function doDeploy() if ($this->io->isDebug()) { $this->io->write('start magento deploy for ' . $package->getPackageName()); } - try { - $package->getDeployStrategy()->deploy(); - } catch (\ErrorException $e) { - if ($this->io->isDebug()) { - $this->io->write($e->getMessage()); - } - } + $package->getDeployStrategy()->deploy(); } }