I have an existing path alias, 'foo/bar'. I execute the Rules action "Create or delete an URL alias" attempting to delete that alias.
Existing system path: (empty)
Path alias: foo/bar
Expected result: Alias is deleted (Existing system path input field says: "Leave it empty to delete URL aliases pointing to the given path alias.")
Actual result: Nothing happens
I then attempt a workaround to delete the alias by fetching its system path:
Existing system path: <?php echo drupal_get_normal_path('foo/bar'); ?>
Path alias: (empty)
Expected result: Alias is deleted
Actual result: Alias is deleted, works as expected
Browsing rules_action_path_alias(), lines 71-74 in rules/modules/path.rules.inc, I saw
// Only set the alias if the path alias isn't taken yet.
if (!drupal_lookup_path('source', $dst)) {
path_set_alias($settings['src'], $dst, NULL, $settings['language']);
}
This if statement appears to be causing this behavior. Letting a blank $settings['src'] pass through should let path_set_alias() delete an existing alias $dst as expected.
This issue doesn't apply to Rules 7.x-2.x.
Comment | File | Size | Author |
---|---|---|---|
rules-path-delete-alias.patch | 937 bytes | Matt Fitzpatrick | |
Comments
Comment #1
Matt Fitzpatrick CreditAttribution: Matt Fitzpatrick commentedQuick follow-up: The workaround I gave above, using drupal_get_normal_path(), actually isn't working as expected. The workaround deletes foo/bar, true, but it also deletes all other aliases pointing to the same system path as foo/bar. The patch seems to be the only way to delete one alias without deleting all the aliases pointing to the same system path.
Comment #2
Matt Fitzpatrick CreditAttribution: Matt Fitzpatrick commentedComment #3
fagothanks, committed.
Comment #5
mitchell CreditAttribution: mitchell commentedUpdated component.