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] Only activate default exts in non composer mode #496

Merged
merged 1 commit into from
May 12, 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
21 changes: 19 additions & 2 deletions Classes/Install/CliSetupRequestHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
*
*/

use Helhum\Typo3Console\Core\ConsoleBootstrap;
use Helhum\Typo3Console\Mvc\Cli\CommandDispatcher;
use Helhum\Typo3Console\Mvc\Cli\CommandManager;
use Helhum\Typo3Console\Mvc\Cli\ConsoleOutput;
Expand Down Expand Up @@ -113,12 +114,28 @@ public function setup($interactiveSetup, array $givenRequestArguments)
touch($firstInstallPath);
}

// Start with a clean set of packages
@unlink(PATH_site . 'typo3conf/PackageStates.php');
// In composer mode, we rely on the fact that core extensions that should
// be active are defined in the composer.json file, while we gracefully activate all default core
// packages when setup is done in non composer mode.
$packageStatesArguments = ['--activate-default' => !ConsoleBootstrap::usesComposerClassLoading()];
// Exclude all local extensions in case any are present, to avoid interference with the setup
foreach (glob(PATH_site . 'typo3conf/ext/*') as $item) {
$packageStatesArguments['--excluded-extensions'][] = basename($item);
}
$this->commandDispatcher->executeCommand('install:generatepackagestates', $packageStatesArguments);

foreach ($this->installationActions as $actionName) {
$this->dispatchAction($actionName);
}

// The TYPO3 installation process does not take care of setting up all extensions properly,
// so we do it manually here
$this->commandDispatcher->executeCommand('install:generatepackagestates', ['--activate-default' => true]);
// so we do it manually here.
unset($packageStatesArguments['excludedExtensions']);
$this->commandDispatcher->executeCommand('install:generatepackagestates', $packageStatesArguments);
// Flush caches, as the extension list has changed
$this->commandDispatcher->executeCommand('cache:flush', ['--force' => true]);
$this->commandDispatcher->executeCommand('extension:setupactive');
}

Expand Down
12 changes: 12 additions & 0 deletions Classes/Install/PackageStatesGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

use Helhum\Typo3Console\Package\UncachedPackageManager;
use TYPO3\CMS\Core\Package\PackageInterface;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\PathUtility;

/**
Expand Down Expand Up @@ -45,6 +46,7 @@ public function __construct(UncachedPackageManager $packageManager)
*/
public function generate(array $frameworkExtensionsToActivate = [], $activateDefaultExtensions = false, array $excludedExtensions = [])
{
$this->ensureDirectoryExists(PATH_site . 'typo3conf');
$this->packageManager->scanAvailablePackages();
foreach ($this->packageManager->getAvailablePackages() as $package) {
if (
Expand All @@ -67,4 +69,14 @@ public function generate(array $frameworkExtensionsToActivate = [], $activateDef
$this->packageManager->forceSortAndSavePackageStates();
return $this->packageManager->getActivePackages();
}

/**
* @param string $directory
*/
private function ensureDirectoryExists($directory)
{
if (!is_dir($directory)) {
GeneralUtility::mkdir_deep(rtrim($directory, '/\\') . '/');
}
}
}
3 changes: 3 additions & 0 deletions Classes/Mvc/Cli/CommandDispatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,9 @@ public function executeCommand($command, array $arguments = [], array $environme
$dashedName = preg_replace('/([A-Z][a-z0-9]+)/', '$1-', $dashedName);
$dashedName = '--' . strtolower(substr($dashedName, 0, -1));
}
if (is_array($argumentValue)) {
$argumentValue = implode(',', $argumentValue);
}
if (strpos($argumentValue, '=') !== false) {
// Big WTF in argument parsing here
// If the value contains a = we need to separate the name and value with a = ourselves
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,15 +100,12 @@ public function packageStatesFileIsCreatedWithoutDefaultPackages()
public function packageStatesFileIsCreatedWithDefaultPackages()
{
$packageStatesFile = getenv('TYPO3_PATH_ROOT') . '/typo3conf/PackageStates.php';
copy($packageStatesFile, $packageStatesFile . '_');
@unlink($packageStatesFile);
$this->commandDispatcher->executeCommand(
'install:generatepackagestates',
[
'--activate-default' => true,
]
);
$this->commandDispatcher->executeCommand('install:generatepackagestates', ['--activate-default' => true]);
$this->assertTrue(file_exists($packageStatesFile));
$packageConfig = require $packageStatesFile;
copy($packageStatesFile . '_', $packageStatesFile);
if ($packageConfig['version'] === 5) {
$this->assertArrayHasKey('reports', $packageConfig['packages']);
} else {
Expand All @@ -122,6 +119,7 @@ public function packageStatesFileIsCreatedWithDefaultPackages()
public function packageStatesFileIsCreatedFromComposerRun()
{
$packageStatesFile = getenv('TYPO3_PATH_ROOT') . '/typo3conf/PackageStates.php';
copy($packageStatesFile, $packageStatesFile . '_');
@unlink($packageStatesFile);

$this->executeComposerCommand(
Expand All @@ -138,6 +136,7 @@ public function packageStatesFileIsCreatedFromComposerRun()

$this->assertTrue(file_exists($packageStatesFile));
$packageConfig = require $packageStatesFile;
copy($packageStatesFile . '_', $packageStatesFile);
if ($packageConfig['version'] === 5) {
$this->assertArrayHasKey('reports', $packageConfig['packages']);
} else {
Expand Down