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

Created on 12 February 2024, 9 months ago
Updated 26 February 2024, 9 months ago

Problem/Motivation

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' => 'https://test.com'])->toString();"
will return https://test.com/

But it won't work for unrouted URLs:
drush php:eval "echo \Drupal\Core\Url::fromUri('internal:/404', ['absolute' => 1, 'base_url' => 'https://test.com'])->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
Status

Needs work

Version

11.0 🔥

Component
Base 

Last updated about 3 hours 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
        (100%)
        
        Time: 00:34.850, Memory: 4.00 MB
        
        There was 1 error:
        
        1)
        Drupal\Tests\language\Functional\LanguageUILanguageNegotiationTest::testLanguageDomain
        Behat\Mink\Exception\ElementNotFoundException: Button with
        id|name|label|value "Save configuration" not found.
  • Status changed to Needs work 9 months ago
  • Pipeline finished with Failed
    9 months ago
    Total: 7247s
    #92844
  • 🇸🇮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
    9 months ago
    Total: 490s
    #93728
  • Pipeline finished with Failed
    9 months ago
    Total: 572s
    #94105
  • Pipeline finished with Failed
    9 months ago
    Total: 564s
    #94115
  • Pipeline finished with Success
    9 months ago
    Total: 470s
    #94830
  • Issue was unassigned.
  • Status changed to Needs review 9 months ago
  • 🇸🇮Slovenia alecsmrekar

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

  • Pipeline finished with Failed
    9 months ago
    Total: 182s
    #95083
  • Pipeline finished with Failed
    9 months ago
    Total: 458s
    #95092
  • Pipeline finished with Success
    9 months ago
    Total: 589s
    #95498
  • Pipeline finished with Success
    9 months ago
    Total: 551s
    #95846
  • 🇸🇮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 9 months ago
  • 🇮🇹Italy plach Venezia

    Looks good to me and works well here, thanks!

  • Status changed to Needs work 9 months 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.

  • Pipeline finished with Success
    5 months ago
    Total: 580s
    #211002
Production build 0.71.5 2024