From b15756cce0657831fa8c18110913b5fd836b5b13 Mon Sep 17 00:00:00 2001 From: fcjurado Date: Fri, 15 Jun 2018 10:18:17 +0200 Subject: [PATCH 1/3] Update DiCompileCommand.php There are some issues related to the 404 error when entering on setup wizard page when /pub directory is configured as root path in apache or nginx. With this fix, the compile command will create a symlink to setup. Related: https://github.com/magento/magento2/search?q=wizard+404&unscoped_q=wizard+404&type=Issues --- .../Console/Command/DiCompileCommand.php | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/setup/src/Magento/Setup/Console/Command/DiCompileCommand.php b/setup/src/Magento/Setup/Console/Command/DiCompileCommand.php index 68e26ec83c3f7..6625ede6ec96d 100644 --- a/setup/src/Magento/Setup/Console/Command/DiCompileCommand.php +++ b/setup/src/Magento/Setup/Console/Command/DiCompileCommand.php @@ -22,6 +22,7 @@ use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Helper\ProgressBar; use Magento\Framework\Console\Cli; +use Symfony\Component\Process\Process; /** * Command to run compile in single-tenant mode @@ -136,6 +137,8 @@ private function checkEnvironment() */ protected function execute(InputInterface $input, OutputInterface $output) { + $this->generateSetupFolderInPublic($output); + $errors = $this->checkEnvironment(); if ($errors) { foreach ($errors as $line) { @@ -400,4 +403,27 @@ private function getOperationsConfiguration( return $operations; } + + private function generateSetupFolderInPublic(OutputInterface $output) + { + $output->writeln('Generating symlink for setup.'); + + $setupPath = $this->directoryList->getPath(DirectoryList::ROOT) . '/' . DirectoryList::SETUP; + $setupPublicPath = $this->directoryList->getPath(DirectoryList::PUB) . '/' . DirectoryList::SETUP; + + if (!file_exists($setupPublicPath)) { + $process = new Process('ln -s ' . $setupPath . ' ' . $setupPublicPath); + + $process->run(); + if ($process->isSuccessful()) { + $output->writeln('Generated symlink for setup in public.'); + } else { + $output->writeln('' . trim($process->getErrorOutput()) . ''); + $output->writeln('Failed to generate the symlink for setup.'); + } + } else { + $output->writeln('Setup folder already exists in public.'); + } + } + } From 19b7e7c383ab7318aacb3335ca03effc286adac6 Mon Sep 17 00:00:00 2001 From: fcjurado Date: Fri, 15 Jun 2018 11:21:47 +0200 Subject: [PATCH 2/3] Update DiCompileCommand.php for Quality review Fix Codacy PR Quality review --- .../Console/Command/DiCompileCommand.php | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/setup/src/Magento/Setup/Console/Command/DiCompileCommand.php b/setup/src/Magento/Setup/Console/Command/DiCompileCommand.php index 6625ede6ec96d..93b2c9a1329e2 100644 --- a/setup/src/Magento/Setup/Console/Command/DiCompileCommand.php +++ b/setup/src/Magento/Setup/Console/Command/DiCompileCommand.php @@ -412,18 +412,20 @@ private function generateSetupFolderInPublic(OutputInterface $output) $setupPublicPath = $this->directoryList->getPath(DirectoryList::PUB) . '/' . DirectoryList::SETUP; if (!file_exists($setupPublicPath)) { - $process = new Process('ln -s ' . $setupPath . ' ' . $setupPublicPath); - - $process->run(); - if ($process->isSuccessful()) { - $output->writeln('Generated symlink for setup in public.'); - } else { - $output->writeln('' . trim($process->getErrorOutput()) . ''); - $output->writeln('Failed to generate the symlink for setup.'); - } - } else { $output->writeln('Setup folder already exists in public.'); + return; + } + + $process = new Process('ln -s ' . $setupPath . ' ' . $setupPublicPath); + + $process->run(); + if (!$process->isSuccessful()) { + $output->writeln('' . trim($process->getErrorOutput()) . ''); + $output->writeln('Failed to generate the symlink for setup.'); + return; } + + $output->writeln('Generated symlink for setup in public.'); } } From e9a5a76a3adc054795bf68e8933fa9dfb89b5f9f Mon Sep 17 00:00:00 2001 From: fcjurado Date: Fri, 15 Jun 2018 11:22:52 +0200 Subject: [PATCH 3/3] Fix file_exists return on checking setupPublicPath Fix file_exists return on checking setupPublicPath --- setup/src/Magento/Setup/Console/Command/DiCompileCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup/src/Magento/Setup/Console/Command/DiCompileCommand.php b/setup/src/Magento/Setup/Console/Command/DiCompileCommand.php index 93b2c9a1329e2..03b820c2aa72e 100644 --- a/setup/src/Magento/Setup/Console/Command/DiCompileCommand.php +++ b/setup/src/Magento/Setup/Console/Command/DiCompileCommand.php @@ -411,7 +411,7 @@ private function generateSetupFolderInPublic(OutputInterface $output) $setupPath = $this->directoryList->getPath(DirectoryList::ROOT) . '/' . DirectoryList::SETUP; $setupPublicPath = $this->directoryList->getPath(DirectoryList::PUB) . '/' . DirectoryList::SETUP; - if (!file_exists($setupPublicPath)) { + if (file_exists($setupPublicPath)) { $output->writeln('Setup folder already exists in public.'); return; }