Suppose you create two nodes using the same title. Suppose you have pathauto set to "verbose" and the update action set to "Do nothing. Leave the old alias intact."

The first node gets saved with a variant of the title name. The second node gets the same name with a "-0" suffix added on.

If I edit the second node, this error message is displayed:

The automatically generated alias content/daves-duplicate-page conflicted with an existing alias. Alias changed to content/daves-duplicate-page-0

In looking at the code, I question why this error message should be displayed. (I need the "verbose" setting for the other messages.) Nothing is really wrong with the aliases.

To me it seems like a confusing error message for easily shaken users. Is there a reason for this message? Thanks for a great module.

BTW: Editing the first node does not produce the same error message.

CommentFileSizeAuthor
#5 855606-pathauto-verbose-D7.patch6.48 KBdave reid

Comments

greggles’s picture

Title: Unnecessary error message when editing a node » Check permission to see pathauto messages before showing the message about duplicate aliases
Category: support » feature

The theory behind that is that users will be confused why their alias got a -0 or -1 added to it. I think this was fairly popular when it was added.

I can see your idea to make this require the same permission as the other pathauto messages but let's get feedback from others doing this.

dpearcefl’s picture

I guess what I'm wondering about is if the alias has been assigned and it doesn't conflict with an existing alias, this error message really doesn't need to be displayed. Does this seem reasonable?

I'm going to try and change the code to produce this result and see if the change looks clean.

dpearcefl’s picture

In pathauto_create_alias(), the second parameter is 'op'. One of the possible values is 'return'. Can you please tell me what your definition is of that operation? (hook_nodeapi does not define this operation.)

Thanks.

dpearcefl’s picture

I'm going to make an assumption that the value 'return' is supposed to return the alias for the specified node in $src.

In pathauto.module (version 6.x-1.3) line 285 a check is made to see if an alias needs to be created. This done by comparing $node->path (the alias as defined in the node) and $pathauto_alias (which is the return from pathauto_create_alias('node', 'return',...) ).

The above code works fine, but if verbose is turned on, the error message "The automatically generated alias %original_alias conflicted with an existing alias. Alias changed to %alias." is displayed.

Since the code in pathauto.module is working fine, the message is not pertinent since we only asked for the alias to be 'returned'. So to not display that message, I changed line 325 in pathauto.inc from
if ($verbose) {
to
if ($verbose && $op <> 'return') {

Does this make sense?

Dave

dave reid’s picture

Version: 6.x-1.3 » 7.x-1.x-dev
Assigned: Unassigned » dave reid
Status: Active » Needs review
StatusFileSize
new6.48 KB

Here's a patch that abstracts the logic of the verbose messages into its own function so it can be re-usable and we can statically store if verbose messages are enabled.

dave reid’s picture

Status: Fixed » Closed (fixed)

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