Add test coverage for GotoAction

Created on 7 October 2015, over 9 years ago
Updated 6 June 2025, 1 day ago

Problem/Motivation

Follow-up for #2575869-69: Remove all remaining usage of deprecated UrlGeneratorInterface::generateFromPath() and delete it β†’ 4.

+++ b/core/modules/action/src/Plugin/Action/GotoAction.php
@@ -54,29 +55,47 @@ class GotoAction extends ConfigurableActionBase implements ContainerFactoryPlugi
+    $url = $this->configuration['url'];
+    // Leave external URLs unchanged, and assemble others as absolute URLs
+    // relative to the site's base URL.
+    if (!UrlHelper::isExternal($url)) {
+      $parts = UrlHelper::parse($url);
+      // @todo '<front>' is valid input for BC reasons, may be removed by
+      //   https://www.drupal.org/node/2421941
+      if ($parts['path'] === '<front>') {
+        $parts['path'] = '';
+      }
+      $uri = 'base:' . $parts['path'];
+      $options = [
+        'query' => $parts['query'],
+        'fragment' => $parts['fragment'],
+        'absolute' => TRUE,
+      ];
+      // Treat this as if it's user input of a path relative to the site's
+      // base URL.
+      $url = $this->unroutedUrlAssembler->assemble($uri, $options);
+    }

@xjm:

This is kind of hideous, but not as hideous as leaving the method around, I think. @pwolanin also suggested that we should add a followup for test coverage for actions.

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

πŸ“Œ Task
Status

Postponed: needs info

Version

11.0 πŸ”₯

Component

forms system

Created by

πŸ‡§πŸ‡ͺBelgium JeroenT πŸ‡§πŸ‡ͺ

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

  • stale-issue-cleanup

    To track issues in the developing policy for closing stale issues, [Policy, no patch] closing older issues

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    Thank you for creating this issue to improve Drupal.

    We are working to decide if this task is still relevant to a currently supported version of Drupal. There hasn't been any discussion here for over 8 years which suggests that this has either been implemented or is no longer relevant. Your thoughts on this will allow a decision to be made.

    Since we need more information to move forward with this issue, the status is now Postponed (maintainer needs more info). If we don't receive additional information to help with the issue, it may be closed after three months.

    Thanks!

Production build 0.71.5 2024