Skip to content
Snippets Groups Projects
Commit a08c59eb authored by Gábor Hojtsy's avatar Gábor Hojtsy
Browse files

Issue #3224660 by Gábor Hojtsy, shaal, DYdave, laura.gates, tedbow,...

Issue #3224660 by Gábor Hojtsy, shaal, DYdave, laura.gates, tedbow, alisonjo315, nessunluogo: The Drupal 8 to 9 $config_directories deprecation is not detected
parent 04edb37f
No related branches found
No related tags found
No related merge requests found
...@@ -4,6 +4,7 @@ namespace Drupal\upgrade_status\Form; ...@@ -4,6 +4,7 @@ namespace Drupal\upgrade_status\Form;
use Composer\Semver\Semver; use Composer\Semver\Semver;
use Drupal\Component\Serialization\Json; use Drupal\Component\Serialization\Json;
use Drupal\Core\DrupalKernelInterface;
use Drupal\Core\Extension\Extension; use Drupal\Core\Extension\Extension;
use Drupal\Core\Extension\ModuleHandler; use Drupal\Core\Extension\ModuleHandler;
use Drupal\Core\Database\Connection; use Drupal\Core\Database\Connection;
...@@ -106,12 +107,19 @@ class UpgradeStatusForm extends FormBase { ...@@ -106,12 +107,19 @@ class UpgradeStatusForm extends FormBase {
protected $nextMajor; protected $nextMajor;
/** /**
* Database connection * Database connection.
* *
* @var \Drupal\Core\Database\Connection * @var \Drupal\Core\Database\Connection
*/ */
protected $database; protected $database;
/**
* Drupal kernel.
*
* @var \Drupal\Core\DrupalKernelInterface
*/
protected $kernel;
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
...@@ -127,7 +135,8 @@ class UpgradeStatusForm extends FormBase { ...@@ -127,7 +135,8 @@ class UpgradeStatusForm extends FormBase {
$container->get('state'), $container->get('state'),
$container->get('date.formatter'), $container->get('date.formatter'),
$container->get('redirect.destination'), $container->get('redirect.destination'),
$container->get('database') $container->get('database'),
$container->get('kernel')
); );
} }
...@@ -155,7 +164,9 @@ class UpgradeStatusForm extends FormBase { ...@@ -155,7 +164,9 @@ class UpgradeStatusForm extends FormBase {
* @param \Drupal\Core\Routing\RedirectDestination $destination * @param \Drupal\Core\Routing\RedirectDestination $destination
* The destination service. * The destination service.
* @param \Drupal\Core\Database\Connection $connection * @param \Drupal\Core\Database\Connection $connection
* The database connection * The database connection.
* @param \Drupal\Core\DrupalKernelInterface $kernel
* The Drupal kernel.
*/ */
public function __construct( public function __construct(
ProjectCollector $project_collector, ProjectCollector $project_collector,
...@@ -168,7 +179,8 @@ class UpgradeStatusForm extends FormBase { ...@@ -168,7 +179,8 @@ class UpgradeStatusForm extends FormBase {
StateInterface $state, StateInterface $state,
DateFormatter $date_formatter, DateFormatter $date_formatter,
RedirectDestination $destination, RedirectDestination $destination,
Connection $database Connection $database,
DrupalKernelInterface $kernel
) { ) {
$this->projectCollector = $project_collector; $this->projectCollector = $project_collector;
$this->releaseStore = $key_value_expirable->get('update_available_releases'); $this->releaseStore = $key_value_expirable->get('update_available_releases');
...@@ -182,6 +194,7 @@ class UpgradeStatusForm extends FormBase { ...@@ -182,6 +194,7 @@ class UpgradeStatusForm extends FormBase {
$this->destination = $destination; $this->destination = $destination;
$this->nextMajor = ProjectCollector::getDrupalCoreMajorVersion() + 1; $this->nextMajor = ProjectCollector::getDrupalCoreMajorVersion() + 1;
$this->database = $database; $this->database = $database;
$this->kernel = $kernel;
} }
/** /**
...@@ -984,6 +997,45 @@ MARKUP ...@@ -984,6 +997,45 @@ MARKUP
] ]
]; ];
// Check deprecated $config_directories if after Drupal 8.8.0. On older
// Drupal versions, the replacement is not supported and the setting may
// be generated by platforms like ddev, leading to false positives that
// the user should not even resolve yet before updating core.
if (version_compare(\Drupal::VERSION, '8.8.0') >= 0) {
$class = 'no-known-error';
$requirement = $this->t('Use of $config_directories in settings.php is deprecated.');
$label = $this->t('Not used');
$is_deprecated = $this->isDeprecatedConfigDirectorySettingUsed();
if ($is_deprecated !== FALSE) {
$status = FALSE;
$class = 'known-error';
if ($is_deprecated === TRUE) {
$label = $this->t('Deprecated configuration used');
$requirement .= ' ' . $this->t('<a href=":settings">Use $settings[\'config_sync_directory\'] instead.</a>', [':settings' => 'https://www.drupal.org/node/3018145']);
}
else {
$label = $this->t('Deprecated and new configuration used');
$requirement .= ' ' . $this->t('<a href=":settings">Use $settings[\'config_sync_directory\'] only.</a>', [':settings' => 'https://www.drupal.org/node/3018145']);
}
}
$build['data']['#rows'][] = [
'class' => $class,
'data' => [
'requirement' => [
'class' => 'requirement-label',
'data' => [
'#type' => 'markup',
'#markup' => $requirement
],
],
'status' => [
'data' => $label,
'class' => 'status-info',
],
]
];
}
// Save the overall status indicator in the build array. It will be // Save the overall status indicator in the build array. It will be
// popped off later to be used in the summary table. // popped off later to be used in the summary table.
$build['status'] = $status; $build['status'] = $status;
...@@ -1267,6 +1319,41 @@ MARKUP ...@@ -1267,6 +1319,41 @@ MARKUP
return [$error, $message, $data]; return [$error, $message, $data];
} }
/**
* Checks config directory settings for use of deprecated values.
*
* The $config_directories variable is deprecated in Drupal 8. However,
* the Settings object obscures the fact in Settings:initialise(), where
* it throws an error but levels the values in the deprecated location
* and $settings. So after that, it is not possible to tell if either
* were set in settings.php or not.
*
* Therefore we reproduce loading of settings and check the raw values.
*
* @return bool|NULL
* TRUE if the deprecated setting is used. FALSE if not used.
* NULL if both values are used.
*/
protected function isDeprecatedConfigDirectorySettingUsed() {
$app_root = $this->kernel->getAppRoot();
$site_path = $this->kernel->getSitePath();
if (is_readable($app_root . '/' . $site_path . '/settings.php')) {
require $app_root . '/' . $site_path . '/settings.php';
}
if (!empty($config_directories)) {
if (!empty($settings['config_sync_directory'])) {
// Both are set. The $settings copy will prevail in Settings::initialise().
return NULL;
}
// Only the deprecated variable is set.
return TRUE;
}
// The deprecated variable is not set.
return FALSE;
}
/** /**
* Dynamic page title for the form to make the status target clear. * Dynamic page title for the form to make the status target clear.
*/ */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment