We added a proper URL alias API with hook_path_insert/update/delete, but we do not have a way to alter an alias before its saved. This could make things tremendously easier for Pathauto in D7 since modules like Transliteration could implement hook_path_alter() to change non-standard characters in an alias.

Files: 
CommentFileSizeAuthor
#5 683510-hook-path-alter-D7.patch1.38 KBDave Reid
PASSED: [[SimpleTest]]: [MySQL] 19,582 pass(es).
[ View ]
#4 683510-hook-path-alter-D7.patch1.38 KBDave Reid
PASSED: [[SimpleTest]]: [MySQL] 18,970 pass(es).
[ View ]
#1 683510-hook-path-alter-D7.patch2.31 KBDave Reid
PASSED: [[SimpleTest]]: [MySQL] 18,732 pass(es).
[ View ]

Comments

Status:Active» Needs review
StatusFileSize
new2.31 KB
PASSED: [[SimpleTest]]: [MySQL] 18,732 pass(es).
[ View ]

Patch for review that adds hook_path_alter() invoked from inside path_save(). Also fixes a bug with locale.module causing aliases to be saved with an empty string for language instead of LANGUAGE_NONE ('und').

Status:Needs review» Reviewed & tested by the community

This seems like a a great addition. A lot of what makes Pathauto painful is that neither it nor the path module have sufficient hooks. This is a great improvement.

#1: 683510-hook-path-alter-D7.patch queued for re-testing.

StatusFileSize
new1.38 KB
PASSED: [[SimpleTest]]: [MySQL] 18,970 pass(es).
[ View ]

Re-rolled for the fixed locale section.

StatusFileSize
new1.38 KB
PASSED: [[SimpleTest]]: [MySQL] 19,582 pass(es).
[ View ]

Trivially re-rolled for HEAD only.

Status:Reviewed & tested by the community» Needs work

I think a hook here makes sense, but...

1. Seems like it would fit the pattern of _save() more than _alter(). _alter() tends to be when the thing is built and about to be presented, where this is more along the lines of hook_node_save()/hook_user_save().

2. We need fleshed out example docs here.

That's true for things that are presented, but URL aliases are not something that is 'visible'. We use '_alter' for non-visible things like menu items, etc. I can add more docs, although the same standard was used to add the URL alias documentation in the first place (see http://api.drupal.org/api/function/hook_path_insert/7).

I agree with Angie here. This hook should be hook_path_presave().

Hrm, it just doesn't make sense to me when we have hook_menu_link_alter (before it's saved), hook_menu_alter (before it's saved), hook_entity_info_alter (before its cached). Plus we cannot use module_invoke_all() with an array that needs to be altered by reference + PHP 5.2. It has to be using drupal_alter(). Thats why those other hooks use _alter.

This is too late for D7 anyway at this point, although since this isn't going to break any backwards compatibility, would be nice to have considered for a major post-7.0 Drupal release down the road.

Issue tags:+pathauto, +API addition

Adding tags...

Version:7.x-dev» 8.x-dev

Well, I guess this is too late now. I have worked on the bare minimum we need to unblock the D7CX versions of Pathauto and Redirect modules that doesn't change any APIs: #998256: Please let modules know about the original URL alias in hook_path_update().

Issue summary:View changes

Fixing typo.