It is impossible to edit or delete existing URL aliases in Administer>Site building>URL aliases.

* If you select the edit link for an existing alias you get an empty form.
* If you select the delete link for an existing alias (and confirm afterwards), you get the message "The alias has been deleted", but it isn't deleted actually.

The problem is within path.module:
- The functions function path_admin_edit() and path_admin_delete_confirm() are still defined with pre-FAPI3 parameters
- The function path_form() is defined correctly, but invoked twice with wrong parameters.

Patch against HEAD attached.

Comments

riccardoR’s picture

StatusFileSize
new954 bytes

Fixed copy&paste typo.

riccardoR’s picture

Title: Can't edit/delete URL aliases » Path module and deletion API - "503 - Connect failed" error
Priority: Normal » Critical
StatusFileSize
new3.76 KB

A brief introduction before talking of the critical error mentioned in the issue title :
I have seen that one of the fixes I proposed here (deletion of existing aliases) was already committed as part of http://drupal.org/node/154046. Other changes to path module were committed with http://drupal.org/node/147723 -- Deletion API for core

While trying to reroll my patch I verified that it is still impossible to edit existing alias. Moreover I realized that URL alias filtering doesn't work, and I read on the Development ML that path module is still to be converted to use the deletion API.

Therefore I rerolled my patch with the following improvements/fixes concerning the URL aliases Admin interface:
- Fixed alias editing
- Fixed alias filtering and added "Reset" filter key (I think it is useful).
- Use of deletion API to delete URL aliases.

I think this might be a starting point for deletion API conversion. I did much testing and it works correctly.

Now the above mentioned critical error:
It is a follow-on of http://drupal.org/node/147723 -- Deletion API for core:
when I try to edit existing aliases from the Admin interface I always get 503 - "Connect failed" error.
The problem is caused by the following changes made to path_set_alias()

=== modified file 'modules/path/path.module'
--- modules/path/path.module	2007-06-18 14:29:53 +0000
+++ modules/path/path.module	2007-06-21 14:37:55 +0000
@@ -127,12 +127,12 @@ function path_admin_delete($pid = 0) {
 function path_set_alias($path = NULL, $alias = NULL, $pid = NULL, $language = '') {
   if ($path && !$alias) {
     // Delete based on path
-    db_query("DELETE FROM {url_alias} WHERE src = '%s' AND language = '%s'", $path, $language);
+    drupal_delete_add_query("DELETE FROM {url_alias} WHERE src = '%s' AND language = '%s'", $path, $language);
     drupal_clear_path_cache();
   }
   else if (!$path && $alias) {
     // Delete based on alias
-    db_query("DELETE FROM {url_alias} WHERE dst = '%s' AND language = '%s'", $alias, $language);
+    drupal_delete_add_query("DELETE FROM {url_alias} WHERE dst = '%s' AND language = '%s'", $alias, $language);
     drupal_clear_path_cache();

This approach work well when path_set_alias() is invoked via nodeapi hook with a deletion package already opened -- i.e. : if you delete a node with an alias, the alias is also deleted.
But when you edit an existing alias from the Admin area, the function path_set_alias() is used recursively and those deferred alias deletions cause an infinite loop, ending up in "503 - Connect failed" error.
To be precise, no deletion package is available in this case (because it is an edit operation actually).

    // The alias exists.
    else {
      // This path has no alias yet, so we redirect the alias here.
      if ($path_count == 0) {
        db_query("UPDATE {url_alias} SET src = '%s' WHERE dst = '%s' AND language = '%s'", $path, $alias, $language);
      }
      else {
        // This will delete the path that alias was originally pointing to.
        path_set_alias(NULL, $alias, NULL, $language);
        // This will remove the current aliases of the path.
        path_set_alias($path, NULL, NULL, $language);
        path_set_alias($path, $alias, NULL, $language);
      }
    }

For now I have rolled back the above changes. The side effect is that an aborted node deletion ends up in deleting the alias anyway. I think the logic here must be changed to accommodate both deletion API integration and URL alias editing.
Thanks for any comment or hint.

riccardoR’s picture

Priority: Critical » Normal
Status: Needs review » Closed (duplicate)

This issue has been fixed here: http://drupal.org/node/154517 -- path module breakage, deletion API conversion
Marking as duplicate.