diff --git a/core/includes/common.inc b/core/includes/common.inc index 9c95a55..936804c 100644 --- a/core/includes/common.inc +++ b/core/includes/common.inc @@ -460,7 +460,7 @@ function drupal_set_time_limit($time_limit) { * - http://example.com/drupal/folder returns "/drupal/folder/". */ function base_path() { - return \Drupal::service('app')->getBasePath() . '/'; + return \Drupal::app()->getBasePath() . '/'; } /** diff --git a/core/includes/file.inc b/core/includes/file.inc index 80fcda2..d75e5ac 100644 --- a/core/includes/file.inc +++ b/core/includes/file.inc @@ -218,7 +218,7 @@ function file_create_url($uri) { // If this is not a properly formatted stream, then it is a shipped file. // Therefore, return the urlencoded URI with the base URL prepended. $options = UrlHelper::parse($uri); - $path = \Drupal::service('app')->getBaseUrl() . '/' . UrlHelper::encodePath($options['path']); + $path = \Drupal::app()->getBaseUrl() . '/' . UrlHelper::encodePath($options['path']); // Append the query. if ($options['query']) { $path .= '?' . UrlHelper::buildQuery($options['query']); diff --git a/core/includes/install.core.inc b/core/includes/install.core.inc index 16d09fa..0cc0fa4 100644 --- a/core/includes/install.core.inc +++ b/core/includes/install.core.inc @@ -931,7 +931,7 @@ function install_redirect_url($install_state) { * @see install_redirect_url() */ function install_full_redirect_url($install_state) { - return \Drupal::service('app')->getBaseUrl() . '/' . install_redirect_url($install_state); + return \Drupal::app()->getBaseUrl() . '/' . install_redirect_url($install_state); } /** @@ -1986,7 +1986,7 @@ function install_check_translations($langcode, $server_pattern) { 'title' => t('Translations directory'), 'value' => t('The translations directory does not exist.'), 'severity' => REQUIREMENT_ERROR, - 'description' => t('The installer requires that you create a translations directory as part of the installation process. Create the directory %translations_directory . More details about installing Drupal are available in INSTALL.txt.', array('%translations_directory' => $translations_directory, '@install_txt' => \Drupal::service('app')->getBasePath() . '/core/INSTALL.txt')), + 'description' => t('The installer requires that you create a translations directory as part of the installation process. Create the directory %translations_directory . More details about installing Drupal are available in INSTALL.txt.', array('%translations_directory' => $translations_directory, '@install_txt' => \Drupal::app()->getBasePath() . '/core/INSTALL.txt')), ); } else { @@ -2186,7 +2186,7 @@ function install_check_requirements($install_state) { '@drupal' => drupal_install_profile_distribution_name(), '%file' => $file, '%default_file' => $default_file, - '@install_txt' => \Drupal::service('app')->getBasePath() . '/core/INSTALL.txt' + '@install_txt' => \Drupal::app()->getBasePath() . '/core/INSTALL.txt' )), ); } @@ -2236,7 +2236,7 @@ function install_check_requirements($install_state) { '@drupal' => drupal_install_profile_distribution_name(), '%file' => $file, '%default_file' => $default_file, - '@install_txt' => \Drupal::service('app')->getBasePath() . '/core/INSTALL.txt', + '@install_txt' => \Drupal::app()->getBasePath() . '/core/INSTALL.txt', '@handbook_url' => 'https://www.drupal.org/server-permissions' )), ); diff --git a/core/includes/install.inc b/core/includes/install.inc index 528cb44..9451fb1 100644 --- a/core/includes/install.inc +++ b/core/includes/install.inc @@ -838,7 +838,7 @@ function install_goto($path) { // Not a permanent redirect. 'Cache-Control' => 'no-cache', ); - $response = new RedirectResponse(\Drupal::service('app')->getBaseUrl() . '/' . $path, 302, $headers); + $response = new RedirectResponse(\Drupal::app()->getBaseUrl() . '/' . $path, 302, $headers); $response->send(); } diff --git a/core/includes/theme.inc b/core/includes/theme.inc index decbf1a..d13ece8 100644 --- a/core/includes/theme.inc +++ b/core/includes/theme.inc @@ -1320,7 +1320,7 @@ function template_preprocess_page(&$variables) { } } - $variables['base_path'] = \Drupal::service('app')->getBasePath() . '/'; + $variables['base_path'] = \Drupal::app()->getBasePath() . '/'; $variables['front_page'] = \Drupal::url(''); $variables['language'] = $language_interface; $variables['logo'] = theme_get_setting('logo.url'); diff --git a/core/lib/Drupal.php b/core/lib/Drupal.php index 7621a48..f8e0e0b 100644 --- a/core/lib/Drupal.php +++ b/core/lib/Drupal.php @@ -687,4 +687,14 @@ public static function destination() { return static::getContainer()->get('redirect.destination'); } + /** + * Returns the application helper. + * + * @return \Drupal\Core\App + * The application helper. + */ + public static function app() { + return static::getContainer()->get('app'); + } + } diff --git a/core/lib/Drupal/Core/App.php b/core/lib/Drupal/Core/App.php index 82997d9..68ee1fc 100644 --- a/core/lib/Drupal/Core/App.php +++ b/core/lib/Drupal/Core/App.php @@ -49,7 +49,7 @@ class App { * The absolute path to the Drupal root directory. */ public function __construct($root) { - $this->root = $root; + $this->root = realpath($root); } /** @@ -115,7 +115,7 @@ protected function prepareBasePath() { $this->basePath = $this->request->getBasePath(); if ($this->basePath) { - $script_path = $this->request->server->get('SCRIPT_FILENAME'); + $script_path = realpath($this->request->server->get('SCRIPT_FILENAME')); // Remove trailing filename from path to front controller. $script_base = substr($script_path, 0, -strlen(basename($script_path)) - 1); // Remove leading document root from path to front controller. diff --git a/core/lib/Drupal/Core/Installer/Exception/AlreadyInstalledException.php b/core/lib/Drupal/Core/Installer/Exception/AlreadyInstalledException.php index ffa1e0c..117a81d 100644 --- a/core/lib/Drupal/Core/Installer/Exception/AlreadyInstalledException.php +++ b/core/lib/Drupal/Core/Installer/Exception/AlreadyInstalledException.php @@ -29,8 +29,8 @@ public function __construct(TranslationInterface $string_translation) {
  • To upgrade an existing installation, proceed to the update script.
  • View your existing site.
  • ', array( - '!base-url' => \Drupal::service('app')->getBaseUrl(), - '!update-url' => \Drupal::service('app')->getBasePath() . '/update.php', + '!base-url' => \Drupal::app()->getBaseUrl(), + '!update-url' => \Drupal::app()->getBasePath() . '/update.php', )); parent::__construct($message, $title); } diff --git a/core/lib/Drupal/Core/Mail/MailFormatHelper.php b/core/lib/Drupal/Core/Mail/MailFormatHelper.php index 75183a7..b9134f0 100644 --- a/core/lib/Drupal/Core/Mail/MailFormatHelper.php +++ b/core/lib/Drupal/Core/Mail/MailFormatHelper.php @@ -342,12 +342,12 @@ protected static function htmlToMailUrls($match = NULL, $reset = FALSE) { } else { if (empty(static::$regexp)) { - static::$regexp = '@^' . preg_quote(\Drupal::service('app')->getBasePath() . '/', '@') . '@'; + static::$regexp = '@^' . preg_quote(\Drupal::app()->getBasePath() . '/', '@') . '@'; } if ($match) { list(, , $url, $label) = $match; // Ensure all URLs are absolute. - static::$urls[] = strpos($url, '://') ? $url : preg_replace(static::$regexp, \Drupal::service('app')->getBaseUrl() . '/', $url); + static::$urls[] = strpos($url, '://') ? $url : preg_replace(static::$regexp, \Drupal::app()->getBaseUrl() . '/', $url); return $label . ' [' . count(static::$urls) . ']'; } } diff --git a/core/lib/Drupal/Core/Routing/LocalAwareRedirectResponseTrait.php b/core/lib/Drupal/Core/Routing/LocalAwareRedirectResponseTrait.php index 0be5fb7..1aca77e 100644 --- a/core/lib/Drupal/Core/Routing/LocalAwareRedirectResponseTrait.php +++ b/core/lib/Drupal/Core/Routing/LocalAwareRedirectResponseTrait.php @@ -35,7 +35,7 @@ protected function isLocal($url) { */ protected function getBaseUrl() { if (!isset($this->baseUrl)) { - $this->baseUrl = \Drupal::service('app')->getBaseUrl(); + $this->baseUrl = \Drupal::app()->getBaseUrl(); } return $this->baseUrl; } diff --git a/core/lib/Drupal/Core/StreamWrapper/PublicStream.php b/core/lib/Drupal/Core/StreamWrapper/PublicStream.php index 4951373..f00881e 100644 --- a/core/lib/Drupal/Core/StreamWrapper/PublicStream.php +++ b/core/lib/Drupal/Core/StreamWrapper/PublicStream.php @@ -53,7 +53,7 @@ public function getDirectoryPath() { */ public function getExternalUrl() { $path = str_replace('\\', '/', $this->getTarget()); - return \Drupal::service('app')->getBaseUrl() . '/' . self::getDirectoryPath() . '/' . UrlHelper::encodePath($path); + return \Drupal::app()->getBaseUrl() . '/' . self::getDirectoryPath() . '/' . UrlHelper::encodePath($path); } /** diff --git a/core/modules/book/book.module b/core/modules/book/book.module index 660181f..3aa3373 100644 --- a/core/modules/book/book.module +++ b/core/modules/book/book.module @@ -464,7 +464,7 @@ function template_preprocess_book_export_html(&$variables) { $language_interface = \Drupal::languageManager()->getCurrentLanguage(); $variables['title'] = SafeMarkup::checkPlain($variables['title']); - $variables['base_url'] = \Drupal::service('app')->getBaseUrl(); + $variables['base_url'] = \Drupal::app()->getBaseUrl(); $variables['language'] = $language_interface; $variables['language_rtl'] = ($language_interface->getDirection() == LanguageInterface::DIRECTION_RTL); $variables['head'] = drupal_get_html_head(); diff --git a/core/modules/color/color.module b/core/modules/color/color.module index ad9488b..346ea98 100644 --- a/core/modules/color/color.module +++ b/core/modules/color/color.module @@ -471,7 +471,7 @@ function color_scheme_form_submit($form, FormStateInterface $form_state) { // Return the path to where this CSS file originated from, stripping // off the name of the file at the end of the path. - $css_optimizer->rewriteFileURIBasePath = \Drupal::service('app')->getBasePath() . '/' . dirname($paths['source'] . $file) . '/'; + $css_optimizer->rewriteFileURIBasePath = \Drupal::app()->getBasePath() . '/' . dirname($paths['source'] . $file) . '/'; // Prefix all paths within this CSS file, ignoring absolute paths. $style = preg_replace_callback('/url\([\'"]?(?![a-z]+:|\/+)([^\'")]+)[\'"]?\)/i', array($css_optimizer, 'rewriteFileURI'), $style); @@ -556,7 +556,7 @@ function _color_rewrite_stylesheet($theme, &$info, &$paths, $palette, $style) { // Replace paths to images. foreach ($paths['map'] as $before => $after) { - $before = \Drupal::service('app')->getBasePath() . '/' . $paths['source'] . $before; + $before = \Drupal::app()->getBasePath() . '/' . $paths['source'] . $before; $before = preg_replace('`(^|/)(?!../)([^/]+)/../`', '$1', $before); $output = str_replace($before, $after, $output); } diff --git a/core/modules/comment/src/Plugin/views/row/Rss.php b/core/modules/comment/src/Plugin/views/row/Rss.php index 7568187..f46d87a 100644 --- a/core/modules/comment/src/Plugin/views/row/Rss.php +++ b/core/modules/comment/src/Plugin/views/row/Rss.php @@ -97,7 +97,7 @@ public function render($row) { ), array( 'key' => 'guid', - 'value' => 'comment ' . $comment->id() . ' at ' . \Drupal::service('app')->getBaseUrl(), + 'value' => 'comment ' . $comment->id() . ' at ' . \Drupal::app()->getBaseUrl(), 'attributes' => array('isPermaLink' => 'false'), ), ); diff --git a/core/modules/file/tests/file_test/file_test.module b/core/modules/file/tests/file_test/file_test.module index 039c7fb..402e1a6 100644 --- a/core/modules/file/tests/file_test/file_test.module +++ b/core/modules/file/tests/file_test/file_test.module @@ -260,7 +260,7 @@ function file_test_file_url_alter(&$uri) { $path = str_replace('\\', '/', $path); // Generate a root-relative URL. - $uri = \Drupal::service('app')->getBasePath() . '/' . $path; + $uri = \Drupal::app()->getBasePath() . '/' . $path; } } // Test alteration of file URLs to use protocol-relative URLs. @@ -283,7 +283,7 @@ function file_test_file_url_alter(&$uri) { $path = str_replace('\\', '/', $path); // Generate a protocol-relative URL. - $uri = '/' . \Drupal::service('app')->getBasePath() . '/' . $path; + $uri = '/' . \Drupal::app()->getBasePath() . '/' . $path; } } } diff --git a/core/modules/filter/filter.api.php b/core/modules/filter/filter.api.php index 6b9cce6..ace33da 100644 --- a/core/modules/filter/filter.api.php +++ b/core/modules/filter/filter.api.php @@ -35,7 +35,7 @@ function hook_filter_info_alter(&$info) { */ function hook_filter_secure_image_alter(&$image) { // Turn an invalid image into an error indicator. - $image->setAttribute('src', \Drupal::service('app')->getBasePath() . '/core/misc/icons/ea2800/error.svg'); + $image->setAttribute('src', \Drupal::app()->getBasePath() . '/core/misc/icons/ea2800/error.svg'); $image->setAttribute('alt', t('Image removed.')); $image->setAttribute('title', t('This image has been removed. For security reasons, only images from the local domain are allowed.')); diff --git a/core/modules/filter/filter.module b/core/modules/filter/filter.module index b1ac5ab..7816f63 100644 --- a/core/modules/filter/filter.module +++ b/core/modules/filter/filter.module @@ -786,7 +786,7 @@ function _filter_html_escape($text) { */ function _filter_html_image_secure_process($text) { // Find the path (e.g. '/') to Drupal root. - $base_path = \Drupal::service('app')->getBasePath() . '/'; + $base_path = \Drupal::app()->getBasePath() . '/'; $base_path_length = Unicode::strlen($base_path); // Find the directory on the server where index.php resides. @@ -834,7 +834,7 @@ function _filter_html_image_secure_process($text) { */ function filter_filter_secure_image_alter(&$image) { // Turn an invalid image into an error indicator. - $image->setAttribute('src', \Drupal::service('app')->getBasePath() . '/core/misc/icons/ea2800/error.svg'); + $image->setAttribute('src', \Drupal::app()->getBasePath() . '/core/misc/icons/ea2800/error.svg'); $image->setAttribute('alt', t('Image removed.')); $image->setAttribute('title', t('This image has been removed. For security reasons, only images from the local domain are allowed.')); $image->setAttribute('height', '16'); diff --git a/core/modules/filter/src/Plugin/Filter/FilterHtml.php b/core/modules/filter/src/Plugin/Filter/FilterHtml.php index 5dbdb2d..3e3e108 100644 --- a/core/modules/filter/src/Plugin/Filter/FilterHtml.php +++ b/core/modules/filter/src/Plugin/Filter/FilterHtml.php @@ -100,7 +100,7 @@ public function tips($long = FALSE) { $output .= '

    ' . $this->t('This site allows HTML content. While learning all of HTML may feel intimidating, learning how to use a very small number of the most basic HTML "tags" is very easy. This table provides examples for each tag that is enabled on this site.') . '

    '; $output .= '

    ' . $this->t('For more information see W3C\'s HTML Specifications or use your favorite search engine to find other sites that explain HTML.', array('@html-specifications' => 'http://www.w3.org/TR/html/')) . '

    '; $tips = array( - 'a' => array($this->t('Anchors are used to make links to other pages.'), '' . SafeMarkup::checkPlain(\Drupal::config('system.site')->get('name')) . ''), + 'a' => array($this->t('Anchors are used to make links to other pages.'), '' . SafeMarkup::checkPlain(\Drupal::config('system.site')->get('name')) . ''), 'br' => array($this->t('By default line break tags are automatically added, so use this tag to add additional ones. Use of this tag is different because it is not used with an open/close pair like all the others. Use the extra " /" inside the tag to maintain XHTML 1.0 compatibility'), $this->t('Text with
    line break')), 'p' => array($this->t('By default paragraph tags are automatically added, so use this tag to add additional ones.'), '

    ' . $this->t('Paragraph one.') . '

    ' . $this->t('Paragraph two.') . '

    '), 'strong' => array($this->t('Strong', array(), array('context' => 'Font weight')), '' . $this->t('Strong', array(), array('context' => 'Font weight')) . ''), diff --git a/core/modules/node/src/Plugin/views/row/Rss.php b/core/modules/node/src/Plugin/views/row/Rss.php index 1c42e01..f67946e 100644 --- a/core/modules/node/src/Plugin/views/row/Rss.php +++ b/core/modules/node/src/Plugin/views/row/Rss.php @@ -124,7 +124,7 @@ public function render($row) { ), array( 'key' => 'guid', - 'value' => $node->id() . ' at ' . \Drupal::service('app')->getBaseUrl(), + 'value' => $node->id() . ' at ' . \Drupal::app()->getBaseUrl(), 'attributes' => array('isPermaLink' => 'false'), ), ); diff --git a/core/modules/views/src/Plugin/views/field/FieldPluginBase.php b/core/modules/views/src/Plugin/views/field/FieldPluginBase.php index 496349b..617daa0 100644 --- a/core/modules/views/src/Plugin/views/field/FieldPluginBase.php +++ b/core/modules/views/src/Plugin/views/field/FieldPluginBase.php @@ -1272,7 +1272,7 @@ public function renderText($alter) { $more_link_path = strip_tags(Html::decodeEntities($this->viewsTokenReplace($more_link_path, $tokens))); // Make sure that paths which were run through _url() work as well. - $base_path = \Drupal::service('app')->getBasePath() . '/'; + $base_path = \Drupal::app()->getBasePath() . '/'; // Checks whether the path starts with the base_path. if (strpos($more_link_path, $base_path) === 0) { $more_link_path = Unicode::substr($more_link_path, Unicode::strlen($base_path));