diff --git a/core/includes/bootstrap.inc b/core/includes/bootstrap.inc index ac5968b..11e9743 100644 --- a/core/includes/bootstrap.inc +++ b/core/includes/bootstrap.inc @@ -428,7 +428,8 @@ function drupal_settings_initialize() { Site::init(DRUPAL_ROOT, isset($sites) ? $sites : NULL, isset($conf_path) ? $conf_path : NULL); // Make $conf_path available as local variable in settings.php. - $conf_path = Site::getSitePath(); + // Concatenation is safe here, since $conf_path is known to be not empty. + $conf_path = Site::getPath(); if ($conf_path !== '' && is_readable(DRUPAL_ROOT . '/' . $conf_path . '/settings.php')) { include_once DRUPAL_ROOT . '/' . $conf_path . '/settings.php'; } diff --git a/core/lib/Drupal/Core/Utility/Site.php b/core/lib/Drupal/Core/Utility/Site.php index d0f0f39..aadb5a1 100644 --- a/core/lib/Drupal/Core/Utility/Site.php +++ b/core/lib/Drupal/Core/Utility/Site.php @@ -57,14 +57,12 @@ class Site { * potential value from the root /settings.php file. */ public static function init($root_directory, array $sites = NULL, $custom_path = NULL) { - if (isset(self::$instance)) { - if (!self::$instance->isInstaller) { - throw new \BadMethodCallException('Site path is initialized already.'); - } - } - else { + if (!isset(self::$instance)) { new self($root_directory); } + elseif (!self::$instance->isInstaller) { + throw new \BadMethodCallException('Site path is initialized already.'); + } self::$instance->initializePath($sites, $custom_path); return self::$instance; } @@ -257,15 +255,6 @@ private function getSimpletestPath() { } /** - * Returns the relative path of the site directory, if any. - * - * @return string - */ - public static function getSitePath() { - return self::$instance->path; - } - - /** * Prefixes a given filepath with the site directory, if any. * * @param string $filepath @@ -301,6 +290,8 @@ private function resolvePath($filepath) { * * @return string * The given $filepath, potentially prefixed with the site path. + * + * @see \Drupal\Core\Utility\Site::getAbsolutePath() */ public static function getPath($filepath = '') { return self::$instance->resolvePath($filepath); @@ -315,9 +306,17 @@ public static function getPath($filepath = '') { * @return string * The given $filepath, potentially prefixed with the site path, as an * absolute filesystem path. + * + * @see \Drupal\Core\Utility\Site::getPath() */ public static function getAbsolutePath($filepath = '') { - return self::$instance->root . '/' . self::$instance->resolvePath($filepath); + $filepath = self::$instance->resolvePath($filepath); + if ($filepath !== '') { + return self::$instance->root . '/' . $filepath; + } + else { + return self::$instance->root; + } } /**