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.

Files: 
CommentFileSizeAuthor
rules-path-delete-alias.patch937 bytesMatt Fitzpatrick
PASSED: [[SimpleTest]]: [MySQL] 13 pass(es).
[ View ]

Comments

Quick 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.

Component:Feature module support» Provided Rules integration

Status:Needs review» Fixed

thanks, committed.

Status:Fixed» Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Component:Provided Rules integration» Rules Core

Updated component.