I've noticed that when submitting an edit node page for an existing node that has a path alias set (path.module turned on), the URL_Alias table's entry for that Drupal path/alias entry is deleted and re-inserted (new path ID) even if the alias is the same.

This action (deletion and re-insertion) seems unnecessary and I can trace it to the code in path.module:function path_set_alias() at this snippet :

...
else if ($path_count == 1 && $alias_count == 1) {
// This will delete the path that alias was originally pointing to:
path_set_alias(NULL, $alias);
path_set_alias($path);
path_set_alias($path, $alias);
}
...

I can understand the purpose of the three path_set_alias calls, for the (rare) case where $path AND $alias are in the existing URL_Alias table but are not in the same row. That is, the current $path has an existing alias that is not the one being passed to the function, and the $alias passed in (to be set) is already in use by some other Drupal system path (usually another node). The 3 calls basicly clean everything up (delete the old aliases) and insert the current call's (path,alias) pair.

But in the (I'm sure more common) case where the $path and $alias are the same as the existing node's setting in URL_Alias, could we avoid this ?

Comments

mkalkbrenner’s picture

Status: Active » Closed (duplicate)