Change record status: 
Project: 
Introduced in branch: 
8.x
Description: 

Following the other directory layout changes (https://drupal.org/node/1766160) settings.php is now required to exist in the root of the Drupal site. This is convenient for people not using Drupal's multi-site functionality as the settings.php is located directly next to the modules, themes and installation profiles in the root modules, themes and profiles directories, respectively.

Even for multi-site installations the top-level settings.php is required to exist. In that case a $sites array (that may be empty) must be added to the top-level settings.php file in order to enable the multi-site detection/negotation process. This $sites variable also covers the functionality that was previously contained in the sites/sites.php file, i.e. you can also define URL-to-directory site mappings. As a consequence, support for the sites/sites.php file has been removed.

Alternatively, a fixed path to a site-specific settings.php file can be defined in the top-level settings.php file (statically or dynamically) by setting the $conf_path variable.

Examples:

// In the top-level settings.php file:

// If the multi-site functionality should not be enabled and a custom
// configuration path should not be set, then neither the $sites nor the
// $conf_path variable should be set. This is the default behavior of the Drupal
// installer.

// If the multi-site functionality should be enabled (without any predefined
// mappings, set the $sites variable to an empty array. This is equivalent to
// the behavior in Drupal 7.
$sites = array();

// If a set of site mappings should be used additionally, specify those in the
// $sites variable. This is equivalent to the behavior in Drupal 7 with a
// sites/sites.php file. The $sites array is identical to that of a Drupal 7
// sites.php file.
$sites = array(
  'localhost.example' => 'example.com',
);

// If a predefined path to a site-specific setings.php should be used, specify
// the $conf_path variable. This circumvents the multisite negotiation.
$conf_path = 'sites/day';
if (time() > date_sunset(time(), SUNFUNCS_RET_TIMESTAMP)) {
  // Use a different settings.php after sunset.
  $conf_path = 'sites/night';
}

One consequence of this change is that the configuration path may be an empty string, in case the multi-site functionality is not enabled. This means that it is unsafe to concatenate the configuration path as part of other paths. For example:

// DO NOT TRY THIS AT HOME!!!
This deletes the top-level files directory of your file-system!!!
unlink($conf_path . '/files');

To prevent this from happening a \Drupal\Core\Site\Site utility has been added and conf_path() has been removed. Use Site::getPath($filepath) and Site::getAbsolutePath($filepath) instead of concatenating paths.

Drupal 7

// These are perfectly safe and valid in Drupal 7.
conf_path() . '/files';
DRUPAL_ROOT . '/' . conf_path() . '/files';

Drupal 8

use Drupal\Core\Site\Site;

// This is unsafe in Drupal 8, as it could be '/files'
Site::getPath() . '/files';
// Instead use the following. If the multi-site functionality is disabled, this
// will simply return 'files'.
Site::getPath('files');

// This is incorrect in Drupal 8 as it could contain a double slash.
DRUPAL_ROOT . '/' . Site::getPath() . '/' files;
// Instead use the following:
Site::getAbsolutePath('files');

The find_conf_path() function has been removed as well. Its functionality is encapsuled in the Site utility but is not directly accessible as a method.

Impacts: 
Site builders, administrators, editors