Impossible to alter node URLs efficiently

Created on 10 June 2010, almost 15 years ago
Updated 27 March 2025, 11 days ago

Follow-up from #525622: 'as link' formatters need a generic way to build the url of an 'entity' β†’ and #699440: Add bundle support to entity_uri callback to remove performance overhead of forum_url_outbound_alter() (regression from D6) β†’ . In Drupal 6 we have taxonomy_term_path(). In those other issues, this got upgraded to entity_uri() for Drupal 7, because for the same reason that the forum module wants to take over the paths of the taxonomy terms in the forum vocabulary, other entity bundles may want to take over the paths of their entities. Part of this upgrade was changing 'path' to 'uri', because at least for comments, the 'fragment' needs to be specified as well as the path.

Problem is, the majority of code in HEAD still hard-codes the entity path instead of using this function. So we're basically telling people: hey, we've got this cool feature giving modules control over entity URIs (via the 'uri callback' in hook_entity_info() and hook_entity_info_alter()), except we're bypassing it in the majority of core code. Not cool. If we're gonna have the entity_uri() function, we need to use it for what it's intended to be there for.

For Drupal 8, one could raise the question of whether entity_uri() makes sense as a function. Why not have entity uri manipulation done via hook_url_outbound_alter()? In Drupal 7, we can't do it, because of performance constraints: every hook_url_outbound_alter() runs for every call to url(). Perhaps a hook_url_outbound_TAG_alter() system similar to hook_query_TAG_alter() might offer a better solution in Drupal 8 than entity_uri(). But for Drupal 7, entity_uri() is what we have, so this issue is just about making sure it is used where it needs to be.

I'll follow-up with a comment summarizing some challenges, and a patch.

πŸ“Œ Task
Status

Postponed: needs info

Version

11.0 πŸ”₯

Component

base system

Created by

πŸ‡ΊπŸ‡ΈUnited States effulgentsia

Live updates comments and jobs are added and updated live.
  • Performance

    It affects performance. It is often combined with the Needs profiling tag.

  • Needs issue summary update

    Issue summaries save everyone time if they are kept up-to-date. See Update issue summary task instructions.

  • 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