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

[FEATURE] Add --skip-extension-setup to install:setup #572

Merged
merged 1 commit into from
Sep 20, 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
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ script:
- typo3cms commandreference:render > /dev/null 2>&1 && test -z "$(git diff --shortstat 2> /dev/null | tail -n1)";
- >
echo "Running php lint…";
if [[ ${TRAVIS_PHP_VERSION:0:1} == "5" ]]; then rm -rf Classes/Composer/InstallerScript; fi;
find . -name \*.php ! -path "./.Build/*" | parallel --gnu php -d display_errors=stderr -l {} > /dev/null \;;
git checkout Classes/Composer/InstallerScript;
- >
Expand Down
6 changes: 4 additions & 2 deletions Classes/Command/InstallCommandController.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ class InstallCommandController extends CommandController
* @param bool $nonInteractive If specified, optional arguments are not requested, but default values are assumed.
* @param bool $force Force installation of TYPO3, even if <code>LocalConfiguration.php</code> file already exists.
* @param bool $skipIntegrityCheck Skip the checking for clean state before executing setup. This allows a pre-defined <code>LocalConfiguration.php</code> to be present. Handle with care. It might lead to unexpected or broken installation results.
* @param bool $skipExtensionSetup Skip setting up extensions after TYPO3 is set up. Defaults to false in composer setups and to true in non composer setups.
* @param string $databaseUserName User name for database server
* @param string $databaseUserPassword User password for database server
* @param string $databaseHostName Host name of database server
Expand All @@ -70,6 +71,7 @@ public function setupCommand(
$nonInteractive = false,
$force = false,
$skipIntegrityCheck = false,
$skipExtensionSetup = false,
$databaseUserName = '',
$databaseUserPassword = '',
$databaseHostName = '',
Expand All @@ -88,8 +90,8 @@ public function setupCommand(
if (!$skipIntegrityCheck) {
$this->ensureInstallationPossible($nonInteractive, $force);
}

$this->cliSetupRequestHandler->setup(!$nonInteractive, $this->request->getArguments());
$skipExtensionSetup |= !Bootstrap::usesComposerClassLoading();
$this->cliSetupRequestHandler->setup(!$nonInteractive, $this->request->getArguments(), $skipExtensionSetup);

$this->outputLine();
$this->outputLine('<i>Successfully installed TYPO3 CMS!</i>');
Expand Down
60 changes: 30 additions & 30 deletions Classes/Install/CliSetupRequestHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,9 @@ public function __construct(
/**
* @param bool $interactiveSetup
* @param array $givenRequestArguments
* @param bool $skipExtensionSetup
*/
public function setup($interactiveSetup, array $givenRequestArguments)
public function setup($interactiveSetup, array $givenRequestArguments, $skipExtensionSetup = false)
{
$this->interactiveSetup = $interactiveSetup;
$this->givenRequestArguments = $givenRequestArguments;
Expand All @@ -119,41 +120,40 @@ 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);
if (!$skipExtensionSetup) {
// Start with a clean set of packages
@unlink(PATH_site . 'typo3conf/PackageStates.php');
$packageStatesArguments = [];
// 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);
}
$this->commandDispatcher->executeCommand('install:generatepackagestates', $packageStatesArguments);

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

$this->output->outputLine();
$this->output->outputLine('Set up extensions:');

// The TYPO3 installation process does not take care of setting up all extensions properly,
// so we do it manually here.
try {
$this->commandDispatcher->executeCommand('install:generatepackagestates', array_diff_key($packageStatesArguments, ['--excluded-extensions' => '']));
} catch (FailedSubProcessCommandException $e) {
// There are very likely broken extensions or extensions with invalid dependencies
// Therefore we fall back to TYPO3 standard behaviour and only install default TYPO3 core extensions
// @deprecated in 4.6, will be removed in 5.0.0
$packageStatesArguments['--activate-default'] = true;
$this->commandDispatcher->executeCommand('install:generatepackagestates', $packageStatesArguments);
$this->output->outputLine('<warning>An error occurred while generating PackageStates.php</warning>');
$this->output->outputLine('<warning>Most likely you have missed correctly specifying depedencies to typo3/cms-* packages</warning>');
$this->output->outputLine('<warning>The error message was "%s"</warning>', [$e->getPrevious()->getMessage()]);
if (!$skipExtensionSetup) {
// The TYPO3 installation process does not take care of setting up all extensions properly,
// so we do it manually here.
$this->output->outputLine();
$this->output->outputLine('Set up extensions:');
try {
$this->commandDispatcher->executeCommand('install:generatepackagestates');
} catch (FailedSubProcessCommandException $e) {
// There are very likely broken extensions or extensions with invalid dependencies
// Therefore we fall back to TYPO3 standard behaviour and only install default TYPO3 core extensions
// @deprecated in 4.6, will be removed in 5.0.0
$packageStatesArguments['--activate-default'] = true;
$this->commandDispatcher->executeCommand('install:generatepackagestates');
$this->output->outputLine('<warning>An error occurred while generating PackageStates.php</warning>');
$this->output->outputLine('<warning>Most likely you have missed correctly specifying depedencies to typo3/cms-* packages</warning>');
$this->output->outputLine('<warning>The error message was "%s"</warning>', [$e->getPrevious()->getMessage()]);
}
$this->commandDispatcher->executeCommand('database:updateschema');
$this->commandDispatcher->executeCommand('extension:setupactive');
}
$this->commandDispatcher->executeCommand('database:updateschema');
$this->commandDispatcher->executeCommand('extension:setupactive');
$this->output->outputLine('<success>OK</success>');
}

Expand Down
2 changes: 2 additions & 0 deletions Documentation/CommandReference/Index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -906,6 +906,8 @@ Options
Force installation of TYPO3, even if ``LocalConfiguration.php`` file already exists.
``--skip-integrity-check``
Skip the checking for clean state before executing setup. This allows a pre-defined ``LocalConfiguration.php`` to be present. Handle with care. It might lead to unexpected or broken installation results.
``--skip-extension-setup``
Skip setting up extensions after TYPO3 is set up. Defaults to false in composer setups and to true in non composer setups.
``--database-user-name``
User name for database server
``--database-user-password``
Expand Down
29 changes: 29 additions & 0 deletions Tests/Functional/Command/Install/InstallCommandControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,34 @@ public function helpBeforeSetupDoesNotCreatePackageStatesFile()
$this->assertFalse(file_exists(getenv('TYPO3_PATH_ROOT') . '/typo3conf/PackageStates.php'));
}

/**
* @test
*/
public function setupCommandDoesNotSetupExtensionsIfRequested()
{
$this->executeMysqlQuery('DROP DATABASE IF EXISTS ' . getenv('TYPO3_INSTALL_DB_DBNAME'), false);
@unlink(getenv('TYPO3_PATH_ROOT') . '/typo3conf/PackageStates.php');
@unlink(getenv('TYPO3_PATH_ROOT') . '/typo3conf/LocalConfiguration.php');
$output = $this->commandDispatcher->executeCommand(
'install:setup',
[
'--non-interactive' => true,
'--skip-extension-setup' => true,
'--database-user-name' => getenv('TYPO3_INSTALL_DB_USER'),
'--database-user-password' => getenv('TYPO3_INSTALL_DB_PASSWORD'),
'--database-host-name' => 'localhost',
'--database-port' => '3306',
'--database-name' => getenv('TYPO3_INSTALL_DB_DBNAME'),
'--admin-user-name' => 'admin',
'--admin-password' => 'password',
'--site-name' => 'Travis Install',
'--site-setup-type' => 'createsite',
]
);
$this->assertContains('Successfully installed TYPO3 CMS!', $output);
$this->assertNotContains('Set up extensions', $output);
}

/**
* @test
*/
Expand All @@ -51,6 +79,7 @@ public function setupCommandWorksWithoutErrors()
]
);
$this->assertContains('Successfully installed TYPO3 CMS!', $output);
$this->assertContains('Set up extensions', $output);
}

/**
Expand Down