Commit 5baf8db0 authored by webchick's avatar webchick

Issue #2342925 by tim.plunkett: Simplify url() in order for the installer to function without it.

parent 9b16aeb5
......@@ -642,21 +642,7 @@ function _format_date_callback(array $matches = NULL, $new_langcode = NULL) {
* @see \Drupal\Core\Routing\UrlGeneratorInterface::generateFromPath().
*/
function url($path = NULL, array $options = array()) {
$generator = \Drupal::urlGenerator();
try {
$url = $generator->generateFromPath($path, $options);
}
catch (GeneratorNotInitializedException $e) {
// Fallback to using globals.
// @todo Remove this once there is no code that calls url() when there is
// no request.
global $base_url, $base_path, $script_path;
$generator->setBasePath($base_path);
$generator->setBaseUrl($base_url . '/');
$generator->setScriptPath($script_path);
$url = $generator->generateFromPath($path, $options);
}
return $url;
return \Drupal::urlGenerator()->generateFromPath($path, $options);
}
/**
......
......@@ -886,6 +886,9 @@ function install_display_output($output, $install_state) {
// reached in case of an early installer error.
drupal_maintenance_theme();
// Ensure the URL generator is initialized.
\Drupal::urlGenerator()->updateFromRequest();
drupal_page_header();
// Prevent install.php from being indexed when installed in a sub folder.
......
......@@ -22,6 +22,16 @@ class NullGenerator extends UrlGenerator {
public function __construct() {
}
/**
* {@inheritdoc}
*/
public function updateFromRequest() {
global $base_url, $base_path, $script_path;
$this->basePath = $base_path;
$this->baseUrl = $base_url . '/';
$this->scriptPath = $script_path;
}
/**
* {@inheritdoc}
*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment