Issue #2831065 by andypost, alexpott, mpdonadio, longwave, Berdir: Remove BC layer from \Drupal\Core\DrupalKernel::getInstallProfile()

merge-requests/2419/head
catch 2020-02-06 20:31:05 +00:00
parent 228df49384
commit 51bf3e2d86
8 changed files with 4 additions and 153 deletions

View File

@ -491,7 +491,7 @@ class DrupalKernel implements DrupalKernelInterface, TerminableInterface {
// Continue if the PharStreamWrapperManager is already initialized. For
// example, this occurs during a module install.
// @see \Drupal\Core\Extension\ModuleInstaller::install()
};
}
stream_wrapper_unregister('phar');
stream_wrapper_register('phar', PharStreamWrapper::class);
}
@ -1602,18 +1602,9 @@ class DrupalKernel implements DrupalKernelInterface, TerminableInterface {
*/
protected function getInstallProfile() {
$config = $this->getConfigStorage()->read('core.extension');
if (isset($config['profile'])) {
$install_profile = $config['profile'];
}
// @todo https://www.drupal.org/node/2831065 remove the BC layer.
else {
// If system_update_8300() has not yet run fallback to using settings.
$settings = Settings::getAll();
$install_profile = isset($settings['install_profile']) ? $settings['install_profile'] : NULL;
}
// Normalize an empty string to a NULL value.
return empty($install_profile) ? NULL : $install_profile;
return $config['profile'] ?? NULL;
}
}

View File

@ -84,9 +84,6 @@ final class Settings {
* The value of the setting, the provided default if not set.
*/
public static function get($name, $default = NULL) {
if ($name === 'install_profile' && isset(self::$instance->storage[$name])) {
@trigger_error('To access the install profile in Drupal 8 use \Drupal::installProfile() or inject the install_profile container parameter into your service. See https://www.drupal.org/node/2538996', E_USER_DEPRECATED);
}
return isset(self::$instance->storage[$name]) ? self::$instance->storage[$name] : $default;
}

View File

@ -1021,8 +1021,8 @@ function system_requirements($phase) {
// hosting provider.
$requirements['install_profile_in_settings'] = [
'title' => t('Install profile in settings'),
'value' => t("Drupal 8 no longer uses the \$settings['install_profile'] value in settings.php and it can be removed."),
'severity' => REQUIREMENT_INFO,
'value' => t("Drupal 9 no longer uses the \$settings['install_profile'] value in settings.php and it should be removed."),
'severity' => REQUIREMENT_WARNING,
];
}
}

View File

@ -5,7 +5,6 @@ namespace Drupal\FunctionalTests\Installer;
use Drupal\Component\Serialization\Yaml;
use Drupal\Core\Database\Database;
use Drupal\Core\DrupalKernel;
use Drupal\Core\Site\Settings;
use Symfony\Component\HttpFoundation\Request;
/**
@ -122,7 +121,6 @@ class DistributionProfileExistingSettingsTest extends InstallerTestBase {
// Confirm that Drupal recognizes this distribution as the current profile.
$this->assertEqual(\Drupal::installProfile(), 'mydistro');
$this->assertArrayNotHasKey('install_profile', Settings::getAll(), 'The install profile has not been written to settings.php.');
$this->assertEqual($this->config('core.extension')->get('profile'), 'mydistro', 'The install profile has been written to core.extension configuration.');
$this->rebuildContainer();

View File

@ -1,113 +0,0 @@
<?php
namespace Drupal\FunctionalTests\Installer;
use Drupal\Core\DrupalKernel;
use Drupal\Core\Database\Database;
use Drupal\Core\Site\Settings;
use Symfony\Component\HttpFoundation\Request;
/**
* Tests installer breaks with a profile mismatch and a read-only settings.php.
*
* @group Installer
* @group legacy
*/
class InstallerExistingSettingsReadOnlyMismatchProfileTest extends InstallerTestBase {
/**
* {@inheritdoc}
*/
protected $defaultTheme = 'stark';
/**
* {@inheritdoc}
*
* Configures a preexisting settings.php file without an install_profile
* setting before invoking the interactive installer.
*/
protected function prepareEnvironment() {
parent::prepareEnvironment();
// Pre-configure hash salt.
// Any string is valid, so simply use the class name of this test.
$this->settings['settings']['hash_salt'] = (object) [
'value' => __CLASS__,
'required' => TRUE,
];
// Pre-configure database credentials.
$connection_info = Database::getConnectionInfo();
unset($connection_info['default']['pdo']);
unset($connection_info['default']['init_commands']);
$this->settings['databases']['default'] = (object) [
'value' => $connection_info,
'required' => TRUE,
];
// During interactive install we'll change this to a different profile and
// this test will ensure that the new value is written to settings.php.
$this->settings['settings']['install_profile'] = (object) [
'value' => 'minimal',
'required' => TRUE,
];
// Pre-configure config directories.
$site_path = DrupalKernel::findSitePath(Request::createFromGlobals());
$this->settings['settings']['config_sync_directory'] = (object) [
'value' => $site_path . '/files/config_staging',
'required' => TRUE,
];
mkdir($this->settings['settings']['config_sync_directory']->value, 0777, TRUE);
}
/**
* {@inheritdoc}
*/
protected function visitInstaller() {
// Make settings file not writable. This will break the installer.
$filename = $this->siteDirectory . '/settings.php';
// Make the settings file read-only.
// Not using File API; a potential error must trigger a PHP warning.
chmod($filename, 0444);
$this->drupalGet($GLOBALS['base_url'] . '/core/install.php?langcode=en&profile=testing');
}
/**
* {@inheritdoc}
*/
protected function setUpLanguage() {
// This step is skipped, because there is a lagcode as a query param.
}
/**
* {@inheritdoc}
*/
protected function setUpProfile() {
// This step is skipped, because there is a profile as a query param.
}
/**
* {@inheritdoc}
*/
protected function setUpSettings() {
// This step should not appear, since settings.php is fully configured
// already.
}
/**
* Verifies that installation succeeded.
*
* @expectedDeprecation To access the install profile in Drupal 8 use \Drupal::installProfile() or inject the install_profile container parameter into your service. See https://www.drupal.org/node/2538996
*/
public function testInstalled() {
$this->initBrowserOutputFile();
$this->htmlOutput(NULL);
$this->assertEquals('testing', \Drupal::installProfile());
$this->assertEquals('minimal', Settings::get('install_profile'));
$this->drupalGet('admin/reports/status');
$this->assertSession()->pageTextContains("Drupal 8 no longer uses the \$settings['install_profile'] value in settings.php and it can be removed.");
}
}

View File

@ -66,13 +66,6 @@ abstract class UpdatePathTestBase extends BrowserTestBase {
*/
protected $databaseDumpFiles = [];
/**
* The install profile used in the database dump file.
*
* @var string
*/
protected $installProfile = 'standard';
/**
* Flag that indicates whether the child site has been updated.
*
@ -250,11 +243,6 @@ abstract class UpdatePathTestBase extends BrowserTestBase {
protected function prepareSettings() {
parent::prepareSettings();
// Remember the profile which was used.
$settings['settings']['install_profile'] = (object) [
'value' => $this->installProfile,
'required' => TRUE,
];
// Generate a hash salt.
$settings['settings']['hash_salt'] = (object) [
'value' => Crypt::randomBytesBase64(55),

View File

@ -2,7 +2,6 @@
namespace Drupal\KernelTests\Core\Extension;
use Drupal\Core\Site\Settings;
use Drupal\KernelTests\KernelTestBase;
/**
@ -15,10 +14,6 @@ class ThemeEngineExtensionListTest extends KernelTestBase {
* @covers ::getList
*/
public function testGetlist() {
$settings = Settings::getAll();
$settings['install_profile'] = 'testing';
new Settings($settings);
// Confirm that all theme engines are available.
$theme_engines = \Drupal::service('extension.list.theme_engine')->getList();
$this->assertArrayHasKey('twig', $theme_engines);

View File

@ -2,7 +2,6 @@
namespace Drupal\KernelTests\Core\Extension;
use Drupal\Core\Site\Settings;
use Drupal\KernelTests\KernelTestBase;
/**
@ -15,10 +14,6 @@ class ThemeExtensionListTest extends KernelTestBase {
* @covers ::getList
*/
public function testGetlist() {
$settings = Settings::getAll();
$settings['install_profile'] = 'testing';
new Settings($settings);
\Drupal::configFactory()->getEditable('core.extension')
->set('module.testing', 1000)
->set('theme.test_theme', 0)