Followup from #2343759: Provide an API function to replace url()/l() for external urls. Part of #2339219: [meta] Finalize URL generation API (naming, docs, deprecation).

Problem/Motivation

Following #2343759: Provide an API function to replace url()/l() for external urls, Url supports both routed and non-routed URLs. However, the constructor documentation and parameters as well as the class properties refer to route names even for unrouted URIs.

Proposed resolution

Clean this up.

Remaining tasks

There will be several @todo in the class referencing this issue.

User interface changes

None.

API changes

No public API changes.

Postponed until

#2343759: Provide an API function to replace url()/l() for external urls

Comments

tim.plunkett’s picture

Status: Postponed » Active
webchick’s picture

Component: routing system » documentation

Moving to documentation component.

webchick’s picture

Title: Update Url to reflect that it handles both routes and non-routed URIs » Update Url documentation to reflect that it handles both routes and non-routed URIs
hussainweb’s picture

Status: Active » Needs review
StatusFileSize
new916 bytes

Giving it a shot. I think I got all instances which need changing.

jhodgdon’s picture

Status: Needs review » Needs work
+   *   The name of the route or an URI without a Drupal route.

- An -> A
- What does this mean, anyway "URI without a Drupal route"? It just doesn't seem clear to me. Do you mean it's a URL that is outside the site? Or ... ? just not sure, and how do you distinguish the two?

Also there is a @todo in the constructor doc header that needs to be removed. ;)

hussainweb’s picture

Status: Needs work » Needs review
StatusFileSize
new934 bytes
new1.23 KB

Fixing as per #5.

@jhodgdon, "URI without a Drupal route" means that we are not using a route name. Do you have any suggestions on how we can phrase it better?
For the record, the phrase is used in several other places in the file and if it doesn't make sense, we should think about changing all the instances.

jhodgdon’s picture

Well maybe it would be a bit clearer as:

The name of a route, or the full URI for URLs without routes (such as URLs outside the site).

Are there other reasons for having a URL without a route? Unsure...

I also don't think I like the term "unrouted", which is still in the latest patch in the member variable docs.

hussainweb’s picture

Status: Needs review » Needs work

Setting it to needs work. I will pick it up later today unless someone beats me to it.

xjm’s picture

Thanks @hussainweb! I think this is going to end up as a duplicate of #2417459: Provide internal API for special schemes and thin public wrappers for user input and non-routed URLs and others, though.

xjm’s picture

Reopening per #2417459-38: Provide internal API for special schemes and thin public wrappers for user input and non-routed URLs point 3.

I think this is not just about documentation -- I think it is wrong, and weird, that we pass something called a route to the constructor, and then require something else to do setUnrouted() to handle it as a URI, especially when we now have so many cases of that.

xjm’s picture

Status: Closed (duplicate) » Postponed
xjm’s picture

Title: Update Url documentation to reflect that it handles both routes and non-routed URIs » Update Url to reflect that it handles both routes and non-routed URIs
Component: documentation » routing system

My original summary even reflects that this is also about parameter and member names, not just docs, so moving back to routing as per the original issue that was filed.

mile23’s picture

dawehner’s picture

Status: Postponed » Active
Issue tags: +rc eligible
hussainweb’s picture

Status: Active » Needs work

Setting to needs work based on #8 and #9.

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

dawehner’s picture

Status: Needs work » Needs review
StatusFileSize
new8.82 KB

I'm wondering whether we could do something like this

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

Bug reports should be targeted against the 8.6.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.8.x-dev

Drupal 8.6.x will not receive any further development aside from security fixes. Bug reports should be targeted against the 8.8.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.9.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

neclimdul’s picture

So I've been trying to unravel some bugs in base url handling and ran into this issue. I think Daniel's idea of splitting things out like that is a great idea! One of the hardest things I've run into is trying to figure out what the effect of any change to the Url class will be because it behaves different based on that internal weird internal state logic built from the external and unrouted properties. Classic state code smell.

I've rerolled this and I'm playing with what the logical outcomes of this might be. A RoutedUrl class, remove conditionals with routed and unrouted methods, traits, deprecations, etc. Maybe an interface?

neclimdul’s picture

StatusFileSize
new8.98 KB

woops, patch didn't make it on the comment.

Version: 8.9.x-dev » 9.2.x-dev

Drupal 8 is end-of-life as of November 17, 2021. There will not be further changes made to Drupal 8. Bugfixes are now made to the 9.3.x and higher branches only. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.15 was released on June 1st, 2022 and is the final full bugfix release for the Drupal 9.3.x series. Drupal 9.3.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.4.x-dev branch from now on, and new development or disruptive changes should be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.9 was released on December 7, 2022 and is the final full bugfix release for the Drupal 9.4.x series. Drupal 9.4.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.5.x-dev branch from now on, and new development or disruptive changes should be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

needs-review-queue-bot’s picture

Status: Needs review » Needs work
StatusFileSize
new145 bytes

The Needs Review Queue Bot tested this issue. It either no longer applies to Drupal core, or fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".

Apart from a re-roll or rebase, this issue may need more work to address feedback in the issue or MR comments. To progress an issue, incorporate this feedback as part of the process of updating the issue. This helps other contributors to know what is outstanding.

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

nikhil_110’s picture

StatusFileSize
new9.19 KB

Attached patch against Drupal 9.5.x

ameymudras’s picture

Status: Needs work » Needs review
StatusFileSize
new8.93 KB

Fixing the issues with the above patch

smustgrave’s picture

Status: Needs review » Needs work
Issue tags: +Needs Review Queue Initiative

Can you please provide an interdiff with the patches.

Version: 9.5.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.

avpaderno’s picture

Since patches are no longer tested, a merge request should be provided.