Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
If you don't specify a URL alias on node creation, you get a "The path is already in use" error. This only applies on node 2 and above, presumably because the path "" gets saved on node/1, and is therefore unavailable for nodes 2+. I started noticing this last night after #332333: Add a real API to path.module went in, so I assume it's related.
Comment | File | Size | Author |
---|---|---|---|
#9 | url_alias-606888-9.patch | 1.86 KB | peximo |
#6 | url_alias-606888-4.patch | 2 KB | Sivaji_Ganesh_Jojodae |
#3 | url_alias-606888-3.patch | 1.97 KB | Sivaji_Ganesh_Jojodae |
#1 | url_alias-606888-2.patch | 752 bytes | peximo |
Comments
Comment #1
peximo CreditAttribution: peximo commentedIn path_node_insert() we need to control not only if is set $node->path but also if this field is not empty.
Otherwise path.module create always a empty path.
The following pacth fix this problem.
Comment #2
peximo CreditAttribution: peximo commentedComment #3
Sivaji_Ganesh_Jojodae CreditAttribution: Sivaji_Ganesh_Jojodae commented@peximo's patch adds !empty check to
hook_node_insert
alone. In my opinion it should be added tohook_node_validate
andhook_node_update
as well.hook_node_validate
is where the "The path is already in use." error message is generated and thus prevents from node creation.Comment #4
onejam CreditAttribution: onejam commentedTesting this patch. I still get an error trying to add an article or blog post.
Error: The path is already in use.
Also noticed, when i manually create the url alias, it accepts spaces in the url. Shouldn't it automatically replace the spaces with dashes instead. should this filed as a separate issue?
Comment #5
stBorchertThis review is powered by Dreditor.
Don't use
empty
because in the (rare) case someone wants to add "0" as alias that would fail.Use
$node->path != ''
instead.Comment #6
Sivaji_Ganesh_Jojodae CreditAttribution: Sivaji_Ganesh_Jojodae commentedoops.. There was a mistake in my previous patch
if (user_access('create url aliases') || user_access('administer url aliases') && !empty($node->path)) {
should be
if ((user_access('create url aliases') || user_access('administer url aliases')) && !empty($node->path)) {
Attached is a patch which corrects this mistake and replaces empty() with != check.
Comment #7
onejam CreditAttribution: onejam commentedMaybe, i'm doing something wrong but patch failed:
Comment #9
peximo CreditAttribution: peximo commentedRerolled
Comment #10
stBorchertWorks.
Comment #11
onejam CreditAttribution: onejam commentedYep, works for me too.
One issue though, when i tried to remove the url alias it wouldn't allow me. i'm able to save but old url alias still remains there. Should it not just default back to the internal url alias (ie, node/2)? I guess this might be a separate issue?
Comment #12
kscheirerpatch works for me.
2 notes:
Code is excuted only when both if statements are TRUE, they should be combined into 1 statement (and this will make the validate function match insert and update).
This needs to have a test attached. I think this issue is critical enough to go in right away even w/o a test, but there should definitely be some follow up.
Comment #13
mr.york CreditAttribution: mr.york commentedThe fix patch is on this page: http://drupal.org/node/332333
Comment #14
Sivaji_Ganesh_Jojodae CreditAttribution: Sivaji_Ganesh_Jojodae commentedLooks like it is fixed. I don't see any error message or an empty alias in {url_alias} table.
Comment #16
heather CreditAttribution: heather commentedI have just tested a fresh install - and I don't get a break on node creation.
Where/when did this get fixed?
I'd like to make the error highlight in red, as well as some UI text changes.
Anyone know where this issue was fixed?
Shall we close this?