You are here

protected function UpgradeStatusForm::isDeprecatedConfigDirectorySettingUsed in Upgrade Status 8.3

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 value

bool|NULL TRUE if the deprecated setting is used. FALSE if not used. NULL if both values are used.

1 call to UpgradeStatusForm::isDeprecatedConfigDirectorySettingUsed()
UpgradeStatusForm::buildEnvironmentChecks in src/Form/UpgradeStatusForm.php
Builds a list of environment checks.

File

src/Form/UpgradeStatusForm.php, line 1360

Class

UpgradeStatusForm

Namespace

Drupal\upgrade_status\Form

Code

protected function isDeprecatedConfigDirectorySettingUsed() {
  $app_root = $this->kernel
    ->getAppRoot();
  $site_path = $this->kernel
    ->getSitePath();
  if (is_readable($app_root . '/' . $site_path . '/settings.php')) {

    // Reset the "global" variables expected to exist for settings.
    $settings = [];
    $config = [];
    $databases = [];
    $class_loader = (require $app_root . '/autoload.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;
}