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

Remove dead code and re-enable --partial test. #5036

Merged
merged 2 commits into from Jan 19, 2022
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
35 changes: 0 additions & 35 deletions src/Commands/core/SiteInstallCommands.php
Expand Up @@ -2,7 +2,6 @@

namespace Drush\Commands\core;

use Composer\Semver\Comparator;
use Consolidation\AnnotatedCommand\CommandData;
use Drupal\Component\FileCache\FileCacheFactory;
use Drupal\Core\Database\Database;
Expand Down Expand Up @@ -173,13 +172,6 @@ public function taskCallback($install_state): void

protected function determineProfile($profile, $options, $class_loader)
{
// --config-dir fails with Standard profile and any other one that carries content entities.
// Force to minimal install profile only for drupal < 8.6.
if ($options['config-dir'] && Comparator::lessThan(self::getVersion(), '8.6')) {
$this->logger()->info(dt("Using 'minimal' install profile since --config-dir option was provided."));
$profile = 'minimal';
}

// Try to get profile from existing config if not provided as an argument.
// @todo Arguably Drupal core [$boot->getKernel()->getInstallProfile()] could do this - https://github.com/drupal/drupal/blob/8.6.x/core/lib/Drupal/Core/DrupalKernel.php#L1606 reads from DB storage but not file storage.
if (empty($profile) && $options['existing-config']) {
Expand Down Expand Up @@ -224,27 +216,6 @@ protected function determineProfile($profile, $options, $class_loader)
return $profile;
}

/**
* Post installation, run the configuration import.
*
* @hook post-command site-install
*/
public function post($result, CommandData $commandData): void
{
if ($config = $commandData->input()->getOption('config-dir') && Comparator::lessThan(self::getVersion(), '8.6')) {
// Set the destination site UUID to match the source UUID, to bypass a core fail-safe.
$source_storage = new FileStorage($config);
$options = array_merge(Drush::redispatchOptions(), ['yes' => true, 'strict' => 0]);
$selfRecord = $this->siteAliasManager()->getSelf();

$process = $this->processManager()->drush($selfRecord, 'config-set', ['system.site', 'uuid', $source_storage->read('system.site')['uuid']], $options);
$process->mustRun();

$process = $this->processManager()->drush($selfRecord, 'config-import', [], ['source' => $config] + $options);
$process->mustRun($process->showRealtime());
}
}

/**
* Check to see if there are any .yml files in the provided config directory.
*/
Expand Down Expand Up @@ -440,12 +411,6 @@ protected function getSitesSubdirFromUri($root, $uri)
return false;
}

public static function getVersion(): ?string
{
$drupal_root = Drush::bootstrapManager()->getRoot();
return Drush::bootstrap()->getVersion($drupal_root);
}

/**
* Fake the necessary HTTP headers that the Drupal installer still needs:
* @see https://github.com/drupal/drupal/blob/d260101f1ea8a6970df88d2f1899248985c499fc/core/includes/install.core.inc#L287
Expand Down
19 changes: 7 additions & 12 deletions tests/functional/ConfigTest.php
Expand Up @@ -100,20 +100,15 @@ public function testConfigExportImportStatusExistingConfig()
// Test the --existing-config option for site:install.
$this->drush('core:status', [], ['field' => 'drupal-version']);
$drupal_version = $this->getOutputRaw();
if (Comparator::greaterThanOrEqualTo($drupal_version, '8.6')) {
$contents = file_get_contents($system_site_yml);
$contents = preg_replace('/front: .*/', 'front: unish existing', $contents);
file_put_contents($system_site_yml, $contents);
$this->installDrupal('dev', true, ['existing-config' => true], false);
$this->drush('config-get', ['system.site', 'page'], ['format' => 'json']);
$page = $this->getOutputFromJSON('system.site:page');
$this->assertStringContainsString('unish existing', $page['front'], 'Existing config was successfully imported during site:install.');
}
$contents = file_get_contents($system_site_yml);
$contents = preg_replace('/front: .*/', 'front: unish existing', $contents);
file_put_contents($system_site_yml, $contents);
$this->installDrupal('dev', true, ['existing-config' => true], false);
$this->drush('config-get', ['system.site', 'page'], ['format' => 'json']);
$page = $this->getOutputFromJSON('system.site:page');
$this->assertStringContainsString('unish existing', $page['front'], 'Existing config was successfully imported during site:install.');

// Similar, but this time via --partial option.
if ($this->isDrupalGreaterThanOrEqualTo('8.8.0')) {
$this->markTestSkipped('Partial config import not yet working on 8.8.0');
}
$contents = file_get_contents($system_site_yml);
$contents = preg_replace('/front: .*/', 'front: unish partial', $contents);
$partial_path = self::getSandbox() . '/partial';
Expand Down
6 changes: 0 additions & 6 deletions tests/functional/PmEnDisUnListInfoTest.php
Expand Up @@ -47,13 +47,7 @@ public function testEnDisUnList()
$drupal_version = $this->getOutputRaw();

// Test the testing install profile theme is installed.
// Since Drupal 8.8, stark is the default testing theme.
// https://www.drupal.org/node/3083055.
// TODO: Replace once Drupal 8.7 is no longer supported.
$active_theme = 'stark';
if (Comparator::lessThan($drupal_version, '8.8')) {
$active_theme = 'classy';
}
$this->assertStringContainsString($active_theme, $out, 'Themes are in the pm-list');

// Test cache was cleared after enabling a module.
Expand Down