From 53c541eea837a394255e1c13271d55a3886a1645 Mon Sep 17 00:00:00 2001 From: Jeroen Thora Date: Sat, 28 Mar 2020 17:29:15 +0100 Subject: [PATCH 1/2] [GeneratorBundle] Fix doctrine fixtures error during install command --- .../Command/InstallCommand.php | 33 ++++++++++--------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/src/Kunstmaan/GeneratorBundle/Command/InstallCommand.php b/src/Kunstmaan/GeneratorBundle/Command/InstallCommand.php index 5a7e4be800..92a276bfba 100644 --- a/src/Kunstmaan/GeneratorBundle/Command/InstallCommand.php +++ b/src/Kunstmaan/GeneratorBundle/Command/InstallCommand.php @@ -13,8 +13,8 @@ use Symfony\Component\Console\Output\OutputInterface; use Sensio\Bundle\GeneratorBundle\Command\Validators; use Symfony\Component\HttpKernel\Kernel; -use Symfony\Component\Process\Exception\RuntimeException; use Sensio\Bundle\GeneratorBundle\Command\Helper\QuestionHelper; +use Symfony\Component\Process\Process; /** * Kunstmaan installer @@ -152,7 +152,7 @@ protected function execute(InputInterface $input, OutputInterface $output) ->executeCommand($output, 'doctrine:database:create') ->executeCommand($output, 'doctrine:schema:drop', ['--force' => true]) ->executeCommand($output, 'doctrine:schema:create') - ->executeCommand($output, 'doctrine:fixtures:load') + ->executeCommand($output, 'doctrine:fixtures:load', ['-n' => true], true) ->executeCommand($output, 'assets:install') ; @@ -169,26 +169,29 @@ protected function execute(InputInterface $input, OutputInterface $output) $this->assistant->writeSection('PRO TIP: If you like to use the default frontend setup, run the buildUI.sh script or run the commands separate to compile the frontend assets. ', 'bg=blue;fg=white'); } - protected function executeCommand(OutputInterface $output, $command, array $options = []) + protected function executeCommand(OutputInterface $output, $command, array $options = [], $separateProcess = false) { - $options = array_merge( - [ - '--no-debug' => true, - ], - $options - ); + $options = array_merge(['--no-debug' => true], $options); ++$this->commandSteps; try { - $updateInput = new ArrayInput($options); - $updateInput->setInteractive(true); - $this->getApplication()->find($command)->run($updateInput, $output); + if ($separateProcess) { + $process = new Process(array_merge(['bin/console', $command], array_keys($options))); + $process->setTty(true); + $process->run(); + + if (!$process->isSuccessful()) { + throw new \RuntimeException($process->getErrorOutput()); + } + } else { + $updateInput = new ArrayInput($options); + $updateInput->setInteractive(true); + $this->getApplication()->find($command)->run($updateInput, $output); + } $output->writeln(sprintf('Step %d: "%s" - [OK]', $this->commandSteps, $command)); - } catch (RuntimeException $exception) { - $output->writeln(sprintf('Step %d: "%s" - [FAILED]', $this->commandSteps, $command)); } catch (\Throwable $e) { - $output->writeln(sprintf('Step %d: "%s" - [FAILED]', $this->commandSteps, $command)); + $output->writeln(sprintf('Step %d: "%s" - [FAILED] Message: %s', $this->commandSteps, $command, $e->getMessage())); } return $this; From c8798ffc89a6bfe5d767f862835995d01a60edeb Mon Sep 17 00:00:00 2001 From: Jeroen Thora Date: Tue, 5 May 2020 21:26:22 +0200 Subject: [PATCH 2/2] [MediaBundle] Fix php 7.4 incompatibility --- .../MediaBundle/Helper/Image/ImageHandler.php | 7 +++-- .../Tests/unit/Fixtures/sample.svg | 4 +++ .../unit/Helper/Image/ImageHandlerTest.php | 27 +++++++++++++++++++ 3 files changed, 36 insertions(+), 2 deletions(-) create mode 100644 src/Kunstmaan/MediaBundle/Tests/unit/Fixtures/sample.svg create mode 100644 src/Kunstmaan/MediaBundle/Tests/unit/Helper/Image/ImageHandlerTest.php diff --git a/src/Kunstmaan/MediaBundle/Helper/Image/ImageHandler.php b/src/Kunstmaan/MediaBundle/Helper/Image/ImageHandler.php index bcc1d770ec..edd8da4a0c 100644 --- a/src/Kunstmaan/MediaBundle/Helper/Image/ImageHandler.php +++ b/src/Kunstmaan/MediaBundle/Helper/Image/ImageHandler.php @@ -93,8 +93,11 @@ public function prepareMedia(Media $media) if ($media->getContent()) { $imageInfo = getimagesize($media->getContent()); - $width = $imageInfo[0]; - $height = $imageInfo[1]; + + $width = $height = null; + if (false !== $imageInfo) { + list($width, $height) = $imageInfo; + } $media ->setMetadataValue('original_width', $width) diff --git a/src/Kunstmaan/MediaBundle/Tests/unit/Fixtures/sample.svg b/src/Kunstmaan/MediaBundle/Tests/unit/Fixtures/sample.svg new file mode 100644 index 0000000000..7f611abbde --- /dev/null +++ b/src/Kunstmaan/MediaBundle/Tests/unit/Fixtures/sample.svg @@ -0,0 +1,4 @@ + + + + diff --git a/src/Kunstmaan/MediaBundle/Tests/unit/Helper/Image/ImageHandlerTest.php b/src/Kunstmaan/MediaBundle/Tests/unit/Helper/Image/ImageHandlerTest.php new file mode 100644 index 0000000000..996a820b9a --- /dev/null +++ b/src/Kunstmaan/MediaBundle/Tests/unit/Helper/Image/ImageHandlerTest.php @@ -0,0 +1,27 @@ +setContent(new File(__DIR__.'/../../Fixtures/sample.svg')); + + $handler = new ImageHandler(1, new MimeTypeGuesserFactory(), new ExtensionGuesserFactory(), 'aviaryKey'); + $handler->setSlugifier(new Slugifier()); + + $handler->prepareMedia($media); + + $this->assertSame(['original_width' => null, 'original_height' => null], $media->getMetadata()); + } +}