base_url used in routed Url assembler, but not in unrouted assembler

Created on 12 February 2024, 19 days ago
Updated 26 February 2024, 6 days ago


When building routed Urls, you're able to set the option absolute to TRUE, and set the base_url option. When assembling the URL, this will result in the specified base URL being used in the URL.

But this option doesn't work for unrouted URLs. We should probably make this behavior consistent.

Steps to reproduce

This will work for a routed URL:
drush php:eval "echo \Drupal\Core\Url::fromUri('internal:/', ['absolute' => 1, 'base_url' => ''])->toString();"
will return

But it won't work for unrouted URLs:
drush php:eval "echo \Drupal\Core\Url::fromUri('internal:/404', ['absolute' => 1, 'base_url' => ''])->toString();"
will return https://your-local-domain/404

Proposed resolution

Adjust UnroutedUrlAssembler to take into account the base_url option.

Merge request link

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

🐛 Bug report

Needs work


11.0 🔥


Last updated less than a minute ago

Created by

🇸🇮Slovenia alecsmrekar

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @alecsmrekar
  • 🇸🇮Slovenia alecsmrekar

    There is a test failure, but I can't reproduce it locally. And I am not sure if it's indeed related to the changes from the PR

        Testing Drupal\Tests\language\Functional\LanguageUILanguageNegotiationTest
        ..E..                                                               5 / 5
        Time: 00:34.850, Memory: 4.00 MB
        There was 1 error:
        Behat\Mink\Exception\ElementNotFoundException: Button with
        id|name|label|value "Save configuration" not found.
  • Status changed to Needs work 19 days ago
  • Pipeline finished with Failed
    19 days ago
    Total: 7247s
  • 🇸🇮Slovenia alecsmrekar

    I ran the failing tests locally on 10.2.x with this diff applied and they are passing just fine.

  • 🇮🇹Italy plach Venezia

    Bug fixes need to be applied to the dev branch first and then backported :)

  • Pipeline finished with Failed
    18 days ago
    Total: 490s
  • Pipeline finished with Failed
    18 days ago
    Total: 572s
  • Pipeline finished with Failed
    18 days ago
    Total: 564s
  • Pipeline finished with Success
    17 days ago
    Total: 470s
  • Issue was unassigned.
  • Status changed to Needs review 17 days ago
  • 🇸🇮Slovenia alecsmrekar

    alecsmrekar changed the visibility of the branch 3420768-baseurl-used-in to hidden.

  • Pipeline finished with Failed
    17 days ago
    Total: 182s
  • Pipeline finished with Failed
    17 days ago
    Total: 458s
  • Pipeline finished with Success
    17 days ago
    Total: 589s
  • Pipeline finished with Success
    16 days ago
    Total: 551s
  • 🇸🇮Slovenia alecsmrekar

    Perfect, thanks! I didn't apply your suggestion as-is, because $this->requestStack->getMainRequest(); can also return NULL, so I took that into account.

  • Status changed to RTBC 16 days ago
  • 🇮🇹Italy plach Venezia

    Looks good to me and works well here, thanks!

  • Status changed to Needs work 6 days ago
  • The Needs Review Queue Bot tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".

    This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

    Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

Production build 0.61.6-2-g546bc20