Download & Extend

drupal_get_path_alias() does not invoke url alter hook while drupal_get_normal_path() does

Project:Drupal core
Version:8.x-dev
Component:base system
Category:bug report
Priority:normal
Assigned:Dave Reid
Status:active

Issue Summary

We have a DX problem that drupal_get_path_alias() does not invoke hook_url_outbound_alter() while drupal_get_normal_path() does invoke its respective own hook_url_inbound_alter(). Modules like Sub-pathauto which rely on being able to run hook_url_outbound_alter() are unable to affect functions like block visibility settings which uses drupal_get_path_alias().

I propose that we move the invocation of hook_url_outbound_alter() from url() to drupal_get_path_alias().

Comments

#1

subscribe

#2

I would REALLY like to see this as well. Right now other modules (path_alias_xt) rely on the developer to use php runkit or modify core. Neither of those options are safe to use in our environment, so we're kinda stuck doing things the long, hard way.

What we want is the ability to replace node/123/edit with my-alias-here/edit, and allow Blocks to use my-alias-here* for visibility.

#3

There's a little bit of a challenge here because url() has more information about the full URL requested than drupal_get_path_alias(). hook_url_outbound_alter() currently gets the $path as well as the $options array which includes things like the query parameter, whether the link is external, etc. whereas drupal_get_path_alias() only has the $path without those options. Also drupal_get_path_alias() only gets called for URLs that need aliasing whereas currently hook_url_outbound_alter() gets called regardless of whether the URL gets aliased. I'm not sure what the right solution is, but we should probably define more clearly what hook_url_outbound_alter() is (used) for and compare that to the functionality that this issue needs.

#4

Sorry guys, any news on this? I'm using sub-pathauto in many sites and still I can't properly set block visibility in sub-pathauto url aliases...

Thank you very much for considering this

#5

Another vote for addressing this. Subpathauto and it's preservation of SEO friendly url's is a significant pursuit for Drupal, and providing support (or a proposed alternative) for this would benefit many. I'll keep an eye on this issue, and help however I can.