diff --git a/core/includes/batch.inc b/core/includes/batch.inc index 711cb35..c48c468 100644 --- a/core/includes/batch.inc +++ b/core/includes/batch.inc @@ -451,21 +451,21 @@ function _batch_finished() { } if ($_batch['form_state']->getRedirect() === NULL) { $redirect = $_batch['batch_redirect'] ?: $_batch['source_url']; - $options = UrlHelper::parse($redirect); // Any path with a scheme does not correspond to a route. - if ($redirect instanceof \Drupal\Core\Url) { - // We already have a proper object. - } - elseif (parse_url($options['path'], PHP_URL_SCHEME)) { - $redirect = Url::fromUri($options['path'], $options); - } - else { - $redirect = \Drupal::pathValidator()->getUrlIfValid($options['path']); - if (!$redirect) { - // Stay on the same page if the redirect was invalid. - $redirect = Url::fromRoute(''); + if (!$redirect instanceof \Drupal\Core\Url) { + $options = UrlHelper::parse($redirect); + if (parse_url($options['path'], PHP_URL_SCHEME)) { + $redirect = Url::fromUri($options['path'], $options); + } + else { + $options = UrlHelper::parse($redirect); + $redirect = \Drupal::pathValidator()->getUrlIfValid($options['path']); + if (!$redirect) { + // Stay on the same page if the redirect was invalid. + $redirect = Url::fromRoute(''); + } + $redirect->setOptions($options); } - $redirect->setOptions($options); } $_batch['form_state']->setRedirectUrl($redirect); } diff --git a/core/modules/system/system.module b/core/modules/system/system.module index 7cdf927..cb9aa7f 100644 --- a/core/modules/system/system.module +++ b/core/modules/system/system.module @@ -240,7 +240,7 @@ function system_hook_info() { * Implements hook_theme_suggestions_HOOK(). */ function system_theme_suggestions_html(array $variables) { - $path_args = explode('/', \Drupal::routeMatch()->getUrl()->getInternalPath()); + $path_args = explode('/', Url::fromRoute('')->getInternalPath()); return theme_get_suggestions($path_args, 'html'); } @@ -248,7 +248,7 @@ function system_theme_suggestions_html(array $variables) { * Implements hook_theme_suggestions_HOOK(). */ function system_theme_suggestions_page(array $variables) { - $path_args = explode('/', \Drupal::routeMatch()->getUrl()->getInternalPath()); + $path_args = explode('/', Url::fromRoute('')->getInternalPath()); return theme_get_suggestions($path_args, 'page'); } diff --git a/core/modules/views/views.module b/core/modules/views/views.module index d27f3ad..c39e651 100644 --- a/core/modules/views/views.module +++ b/core/modules/views/views.module @@ -15,6 +15,7 @@ use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Render\Element; use Drupal\Core\Routing\RouteMatchInterface; +use Drupal\Core\Url; use Drupal\views\Plugin\Derivative\ViewsLocalTask; use Drupal\Core\Template\AttributeArray; use Drupal\views\ViewExecutable; @@ -61,7 +62,7 @@ function views_views_pre_render($view) { 'view_name' => $view->storage->id(), 'view_display_id' => $view->current_display, 'view_args' => String::checkPlain(implode('/', $view->args)), - 'view_path' => String::checkPlain(\Drupal::routeMatch()->getUrl()->toString()), + 'view_path' => String::checkPlain(Url::fromRoute('')->toString()), 'view_base_path' => $view->getPath(), 'view_dom_id' => $view->dom_id, // To fit multiple views on a page, the programmer may have diff --git a/core/modules/views_ui/src/Form/Ajax/ConfigHandler.php b/core/modules/views_ui/src/Form/Ajax/ConfigHandler.php index db770db..6883d16 100644 --- a/core/modules/views_ui/src/Form/Ajax/ConfigHandler.php +++ b/core/modules/views_ui/src/Form/Ajax/ConfigHandler.php @@ -9,6 +9,7 @@ use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Routing\RouteMatch; +use Drupal\Core\Url; use Drupal\views\ViewStorageInterface; use Drupal\views\ViewExecutable; use Drupal\views\Views; @@ -175,7 +176,7 @@ public function buildForm(array $form, FormStateInterface $form_state, Request $ '#submit' => array(array($this, 'remove')), '#limit_validation_errors' => array(array('override')), '#ajax' => array( - 'url' => RouteMatch::createFromRequest($request)->getUrl(), + 'url' => Url::fromRoute(''), ), ); }