Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUGFIX] Fix setup during composer run #652

Merged
merged 1 commit into from
Dec 26, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions Classes/Core/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
*/

use Composer\Autoload\ClassLoader;
use Doctrine\Common\Annotations\AnnotationRegistry;
use Helhum\Typo3Console\Core\Booting\RunLevel;
use Helhum\Typo3Console\Core\Booting\Scripts;
use Helhum\Typo3Console\Mvc\Cli\CommandCollection;
Expand Down Expand Up @@ -56,6 +57,9 @@ public function __construct(\Composer\Autoload\ClassLoader $classLoader)
$this->ensureRequiredEnvironment();
$this->bootstrap = Bootstrap::getInstance();
$this->bootstrap->initializeClassLoader($classLoader);
// Initialize basic annotation loader until TYPO3 does so as well
AnnotationRegistry::registerLoader('class_exists');

// We need to be sure all classes can be loaded in non composer mode as early as possible
$this->initializeNonComposerClassLoading();
$this->runLevel = new RunLevel($this->bootstrap);
Expand Down
3 changes: 1 addition & 2 deletions Classes/Install/CliSetupRequestHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -252,8 +252,7 @@ private function setActionArgument(&$currentActionArguments, $value, CommandArgu
if ($argumentDefinition->acceptsValue()) {
$currentActionArguments['options'][$argumentDefinition->getDashedName()] = $value;
} else {
$value = (bool)$value;
if ($value) {
if ((bool)$value) {
$currentActionArguments['options'][] = $argumentDefinition->getDashedName();
}
}
Expand Down
16 changes: 12 additions & 4 deletions Classes/Mvc/Cli/CommandDispatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
use Symfony\Component\Console\Exception\RuntimeException;
use Symfony\Component\Process\PhpExecutableFinder;
use Symfony\Component\Process\Process;
use Symfony\Component\Process\ProcessBuilder;

/**
* This class can be used to execute console commands in a sub process
Expand Down Expand Up @@ -63,7 +64,8 @@ private function __construct(array $commandLine, array $environmentVars = [])
*/
public static function createFromComposerRun(ScriptEvent $event, array $commandLine = [], array $environmentVars = [], PhpExecutableFinder $phpFinder = null)
{
$name = Application::COMMAND_NAME;
// should be Application::COMMAND_NAME, but our Application class currently conflicts with symfony/console 2.7, which is used by Composer
$name = 'typo3cms';
$searchDirs = [
$event->getComposer()->getConfig()->get('bin-dir'),
dirname(__DIR__, 3),
Expand All @@ -76,7 +78,7 @@ public static function createFromComposerRun(ScriptEvent $event, array $commandL
}
}
if (!isset($typo3CommandPath)) {
throw new RuntimeException(sprintf('The "%s" binary could not be found.', Application::COMMAND_NAME), 1494778973);
throw new RuntimeException(sprintf('The "%s" binary could not be found.', $name), 1494778973);
}
$environmentVars['TYPO3_CONSOLE_PLUGIN_RUN'] = true;

Expand Down Expand Up @@ -189,8 +191,14 @@ public function executeCommand($command, array $arguments = [], array $environme
}
}

$process = new Process($commandLine, null, $environmentVars, $input, 0);
$process->inheritEnvironmentVariables();
if (isset($environmentVars['TYPO3_CONSOLE_PLUGIN_RUN']) && class_exists(ProcessBuilder::class)) {
// During a composer run, we have symfony/console 2.7 unfortunately, thus we must handle it here with "old" code.
$process = (new ProcessBuilder($commandLine))->setTimeout(null)->addEnvironmentVariables($environmentVars)->getProcess();
} else {
$process = new Process($commandLine, null, $environmentVars, $input, 0);
$process->inheritEnvironmentVariables();
}

$process->run();
$output = str_replace("\r\n", "\n", trim($process->getOutput()));

Expand Down
3 changes: 0 additions & 3 deletions Compatibility/TYPO3v87/Core/Booting/CompatibilityScripts.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
*/

use Doctrine\Common\Annotations\AnnotationReader;
use Doctrine\Common\Annotations\AnnotationRegistry;
use TYPO3\CMS\Core\Core\Bootstrap;

class CompatibilityScripts
Expand All @@ -38,8 +37,6 @@ public static function initializeConfigurationManagement(Bootstrap $bootstrap)

private static function initializeAnnotationReader()
{
AnnotationRegistry::registerLoader('class_exists');

/*
* All annotations defined by and for Extbase need to be
* ignored during their deprecation. Later, their usage may and
Expand Down