When programmatically creating a new node that uses the following pathauto setting in the $node object:

$node->path['pathauto'] = TRUE;

The following notice sometimes arises:

Notice: Undefined index: alias in path_node_insert() (line 187 of /####/modules/path/path.module).
Notice: Undefined index: alias in path_node_update() (line 204 of /####/modules/path/path.module).

Upon inspection of the path.module file, I found that both of these notices were on variables that weren't first checked by isset() or empty() before performing a trim() on them. Here's the line in both instances:

$path['alias'] = trim($path['alias']);

After moving this line to inside the if statement in both instances:

if (!empty($path['alias'])) {
...
}

This resolved the problem.

Obviously this is not a horrible issue, however, it did fill up my cron logs with tons of notices. So, hopefully this will get fixed in future versions of drupal.

Comments

marcingy’s picture

Project: Drupal core » Pathauto
Version: 7.12 » 7.x-1.x-dev
Component: path.module » Code

This sound more like a pathauto issue than a core issue.

mrharolda’s picture

I can confirm this issue.

dave reid’s picture

Here's how you can avoid it. Also set $node->path['alias'] = '';. I'm going to file a patch against core's path module to make this more flexible.

dave reid’s picture

Status: Active » Closed (duplicate)