Hi,
I have very strange problem with path_set_alias.
In my module i use this function to create aliases for nodes.
With creating aliases looking like:
path_set_alias('node/'.$node->nid, strtolower($node->title).'.html')
i see that alias is created and immediately after creating is deleted.
I checked it(added line:
function path_set_alias($path = NULL, $alias = NULL, $pid = NULL, $language = '') {
$path = urldecode($path);
$alias = urldecode($alias);
++ file_put_contents(time(), $path.' '.$alias);
----------------------------------
elseif ($path && $alias) {
++file_put_contents('inserted', '');
// Check for existing aliases.
if ($alias == drupal_get_path_alias($path, $language)) {
// There is already such an alias, neutral or in this language.
// Update the alias based on alias; setting the language if not yet done.
db_query("UPDATE {url_alias} SET src = '%s', dst = '%s', language = '%s' WHERE dst = '%s'", $path, $alias, $language, $alias);
}
else {
// A new alias. Add it to the database.
db_query("INSERT INTO {url_alias} (src, dst, language) VALUES ('%s', '%s', '%s')", $path, $alias, $language);
}
}
------------------------------------
else{
// Delete the alias.
if ($alias) {
db_query("DELETE FROM {url_alias} WHERE dst = '%s'", $alias);
}
else {
db_query("DELETE FROM {url_alias} WHERE src = '%s'", $path);
}
++ file_put_contents('deleted', '');
}
drupal_clear_path_cache();
my additions marked with "++" before), and it seems that variable $alias is existing only in closure ($path && $alias){..}, in rest of function it does not exists..
I use drupal 6.13, invoke function path_set_alias in implementation of hook_update and hook_insert, and have installed pathauto module(i`ve chcecked that disabling this module doesnt make any changes).
What i`m doing wrong?