I use pathauto.module and I want to avoid the creation of url aliases for some types of node (for instance the type 'case'). As far as I know the only way to do it is to use the node/[nid] pattern in the settings of pathauto.module
When I submit a new case, I get :
Created new alias node/737 for node/737
and the alias is actually created in the url aliases list!
path.module should not create such useless aliases !

Comments

chx’s picture

Version: 4.7.3 » x.y.z
Status: Active » Needs review
StatusFileSize
new517 bytes

Sounds like a plan.

chx’s picture

I guess it applies to 4.7, too...

dries’s picture

Status: Needs review » Needs work

This is an form validation issue, IMO, and should be fixed at the form validation level.

wim leers’s picture

Title: Useless aliases » Useless aliases allowed by path.module
Version: x.y.z » 6.x-dev
Assigned: Unassigned » wim leers

I'll create a patch later today.

scor’s picture

Assigned: wim leers » scor
Priority: Normal » Critical
Status: Needs work » Needs review
StatusFileSize
new1.28 KB

Still applies in drupal 6. I even noticed that once the useless path has been created, you can't overwrite it by a normal path.

To reproduce this bug:
1. create a node
2. edit it and enter the drupal path in the url path settings (ex node/2)
3. save. you will see the useless alias in the url_alias table
4. edit the node again. the url alias field is empty. enter whatever path you want (ex about) and save
5. the path you entered is not used, and there are now 2 paths for this node in the url_alias table
6. edit the node, the path field is empty again. enter another path, save. it will be added as a third alias in the url_alias table.
...you end up with a useless path and multiple paths for the same node in the url_alias table.

This patch adds:
- a form validation when editing a node
- a condition path_set_alias() to avoid creating an alias if the alias and the path are the same. This is for the modules such as pathauto which might use the path_set_alias function directly.

gábor hojtsy’s picture

Let's do 'node/'. $node->nid instead of "node/$node->nid".

catch’s picture

Status: Needs review » Needs work

In which case...

scor’s picture

Status: Needs work » Needs review
StatusFileSize
new1.28 KB

no problem.
On a side note, I find 24 of these "node/$node->nid" in the core.

dries’s picture

Priority: Critical » Normal

Is 'drupal path' the terminology that we are using? If so, it should be 'Drupal path' not 'drupal path'. I remember using 'internal path' elsewhere and 'URL alias' elsewhere.

I don't see why this is critical.

scor’s picture

StatusFileSize
new1.28 KB

yes Dries, 'URL alias' and 'internal path' are more consistent and make more sense.

greggles’s picture

This prevents some rare but potentially confusing bugs.

On admin/build/path we call the two types "Alias | System" at the top of the table. We call the internal ones "system paths" in the help text on that page, and on admin/build/path/add we call them "system paths". A few rounds of grepping the code showed that in the UI we use "system path" to describe this most often. There is a separate issu

So, I'd vote for using "system path" for this.

See also: standardize on system path so we can be totally consistent on the name of this within D6.

scor’s picture

StatusFileSize
new1.28 KB

rerolled with 'system path'

chx’s picture

Regarding "node/$node->nid" I suspect another PHP misbelief in the works -- that quotes are slower than apostrophes. Not so any longer. I can't remember whether 4.1 or 4.2 made this difference totally negligeble but one of them did.

scor’s picture

Even though there might have been some optimizations, PHP still needs to go through the whole double quoted expression to find the variables.
Anyways, this is not the question here: let's not move away from the main topic of this issue.

Jaza’s picture

StatusFileSize
new2.05 KB

As well as on node forms, path-same-as-alias validation should also be happening on the path add/edit admin form. Attached patch adds this. Otherwise, looks good.

scor’s picture

StatusFileSize
new1.97 KB

thanks Jaza. I rerolled the patch against HEAD.

Freso’s picture

Adding this to "my issues" so that I will hopefully be able to give it some love when I get back to patch testing. :)

dries’s picture

Status: Needs review » Closed (won't fix)

I don't think this is worth fixing. It is a bug in the calling code.

greggles’s picture

For the record, it's a configuration problem in addition to a calling code problem. The proper way to configure pathauto for this situation is to leave the pattern blank for the node type you don't want aliased and also leave the default blank at which point Pathauto won't try to create these useless aliases.

This is a somewhat reasonable concern, though, so I have added change this to a feature request against pathauto to "don't create aliases that are the same as the src". It shouldn't require much extra code and will prevent bloat of the infamous url_alias table.

See http://drupal.org/node/198138 for the Pathauto issue.