I edited my node, unchecked the `Generate automatic URL alias` checkbox and typed my custom url into the path box and clicked save.

This is the value I typed: `blog/blog.cfm/aid/496/Test-url-alias`

I don't get any errors when I save, but the url doesn't seem to take effect. When I edit the node again and go look at the url alias the `Generate automatic URL alias` checkbox is checked again. My value is still in the text field, but the field is disabled because the checkbox is checked meaning it should use an automatic alias.

Why won't my changes stick and use my custom url alias?

Files: 
CommentFileSizeAuthor
#45 pathauto-1847444-45.patch1.73 KBygerasimov
PASSED: [[SimpleTest]]: [MySQL] 337 pass(es).
[ View ]
#40 URL aliases Sahara Question.png58.16 KBaminebourkadi
#34 pathauto-1847444-34.patch1.11 KBmccrodp
PASSED: [[SimpleTest]]: [MySQL] 337 pass(es).
[ View ]

Comments

stella’s picture

I have the same issue. When I look at the database for the node, I can see two entries for each language in the database:

+-----+---------+-------------------------------+----------+
| pid | source  | alias                         | language |
+-----+---------+-------------------------------+----------+
| 165 | node/43 | registered-naionrai/schemes   | en       |
| 244 | node/43 | content/schemes               | en       |
|  83 | node/43 | naionrai-claraithe/sceimeanna | ga       |
| 246 | node/43 | content/sceimeanna            | ga       |
+-----+---------+-------------------------------+----------+

It looks like drupal_get_path_alias() in pathauto_field_attach_form() just returns one alias, and since that one matches the pattern based one, it sets the checkbox to enabled. I tried it with all 3 "Update action" options, but nothing changed.

I'm using entity translation in case that makes a difference.

Riptidez’s picture

Having the same problem. Can set my own alias when I create a node, however I can't override existing nodes that had "Generate automatic URL alias" previously checked.

Dave Reid’s picture

Status:Active» Postponed (maintainer needs more info)

None of the simpletests can confirm this behavior. I'd need specific steps to reproduce this issue on a clean install of core + Token + Pathauto only enabled.

SGhosh’s picture

I had a clean install of core, token, pathauto. I created a node, unchecked generate automatic url, saved my custom url, and there does not seem to be any problem.

@kennywyland - please give the exact steps on reproducing this problem.

henrikakselsen’s picture

I have the same issue. My page has some multilingual content and only one language seem to be affected by it.

root66’s picture

I've the same issue, but with "und" (undefined) language nodes only. When the manual path (pathauto unchecked) is saved, the alias is written to the url_alias table and the 'language' field is empty. When loading the node again, the pathauto checkbox is checked again, because pathauto can't find the 'url_alias' table row, because it selects something like "AND language = 'und'" and there's a row with a empty language only.

Martijn Houtman’s picture

I have the same problem. Steps to reproduce:

1. Enable i18n and i18n_content, and set basic page to translatable, with translation
2. Enable pathauto
3. Enable a second language, e.g. Dutch
4. Create a basic page, in English, with 'create automatic url alias' checked
5. Translate the page to a different language, e.g. Dutch (also url alias checked)
6. Go back to original page, uncheck url alias and edit it
7. Go to translated page, uncheck url alias and edit it
8. Go back to original node, edit it, and the 'url alias' checkbox is checked again (it should be unchecked)

Tested on a D7.19 install with i18n 1.8 and pathauto 1.2. Can anyone try to confirm if they also have this behavior?

onewomanbiz’s picture

I have the the reverse issue. I cannot get the automatic alias checkboxes to stay checked on one site.
I have a multisite single Drupal Core, 2 databases, one English site, one French site.

English site auto url stays checked and able to set urls. French site the auto url will not stay checked and cannot generate auto urls. Any ideas?

zemax’s picture

I have the same issue but I think I know where it comes from.
When updating a node with translations and WITH SYNCHONISED FIELDS, the translations are also updated automaticaly by the i18n module, and the pathauto hook re-generate the paths directly from the pattern for these translations nodes.

If I disable the synchronisation between fields, the paths remain correct.

zemax’s picture

Solved my problem by adding the same tests that are done on the form :
In pathauto.module, line 347 :

<?php
function pathauto_entity_presave($entity, $type) {
    if (!isset(
$entity->path['pathauto'])) {
       
$entity_type = $type;
       
$langcode = $entity->language;
        list(
$id, , $bundle) = entity_extract_ids($entity_type, $entity);
       
        if (!empty(
$id)) {
           
module_load_include('inc', 'pathauto');
           
$uri = entity_uri($entity_type, $entity);
           
$path = drupal_get_path_alias($uri['path'], $langcode);
           
$pathauto_alias = pathauto_create_alias($entity_type, 'return', $uri['path'], array($entity_type => $entity), $bundle, $langcode);
           
$entity->path['pathauto'] = ($path != $uri['path'] && $path == $pathauto_alias);
        }
        else {
           
$entity->path['pathauto'] = TRUE;
        }
    }
 
 
// About to be saved (before insert/update)
 
...
?>
stella’s picture

@zemax can you add a patch for your changes please?

zemax’s picture

StatusFileSize
new3.11 KB
PASSED: [[SimpleTest]]: [MySQL] 316 pass(es).
[ View ]

Here is the patch.
Don't know if it will fix your bug (which seems to be related with multiple aliases ?)

alanburke’s picture

When the pathauto field is attached to the the translation form - it ignores whether a path has already been set for the source translation.
Hence when the source node is saved, pathauto is set to true, and a new alias is saved.
The problem is that the entity already has pathauto set to true when the translation form tries to attach itself.
The expected behaviour is that if a manual path is set for the source translation, the pathauto should be false
[as it is when editing the source translation] and the path from the source entity should be the default value.

Still trying to workout where that 'pathauto=true' is set when loading the translation form.

krishanchandra’s picture

Go TO URL Alias Configuration -> Go To Setting Tab --> Update action
Select This option - Do nothing. Leave the old alias intact.

artfulrobot’s picture

Thanks, this fixed it for me.

davidlovere’s picture

I am running pathauto with internationalization, and was having this problem. Here's what fixed it for me, quite simple:

For each affected content type, enable Multilingual support.

Charles Belov’s picture

I was getting this too - in my case I was trying to change the alias, not get rid of it - but I'm adding this in case it is relevant to your issue.

When you edit the URL path setting, there is a link Configure URL alias patterns. I decided to follow that link, and found that the alias pattern for the particular content type is:

[node:menu-link:parents:join-path]/[node:menu-link]

So I left the URL Path Setting tab and went to the Menu Settings tab, and changed the link title and saved.

The alias changed to what I wanted it to be.

Hope this helps.

VVS’s picture

Solution for me:

Go to /admin/config/search/path, delete old path with warning.
Resave the node with custom path.

ricovandevin’s picture

Issue summary:View changes

I've overlooked this issue earlier and created another one on #2194305: Checkbox Generate automatic URL alias behaves strange. The problem might be that drupal_lookup_path() returns a language neutral alias instead of a language specific one when both exist for the same node. In #2194305: Checkbox Generate automatic URL alias behaves strange there is a link to an issue for the core Path module where a patch for that bug in core can be found.

Growiel’s picture

I had the same kind of problem.

Whenever I updated a node via node_save(), the alias config was reset to "create an automatic alias".

This is VERY easy to reproduce:

1: Install brand new Drupal.
2: Install Pathauto and Token.
3: Create two nodes, make sure the second one has a custom alias.
4: Create a custom "test" module with:

<?php
function test_node_update($node){
    if(
$node->nid == 1){
       
node_save(node_load(2));
    }
}
?>

5: Activate test module.
6: Save the first node which will node_save() the second one.
7: Go to edit page of the second one and see that it now has "Generate automatic alias".

The patch in #12 fixed it for me.

It need to be commited ASAP, I lost a long time finding out why the hell where my translations getting screwed up.

Growiel’s picture

Priority:Normal» Major
Status:Postponed (maintainer needs more info)» Reviewed & tested by the community
jenlampton’s picture

StatusFileSize
new1.08 KB
FAILED: [[SimpleTest]]: [MySQL] 316 pass(es), 0 fail(s), and 37 exception(s).
[ View ]

Patch also works for me. I needed a version to apply to the 7.x-1.2 version. Attached.

Status:Reviewed & tested by the community» Needs work

The last submitted patch, 22: pathauto-1847444-22.patch, failed testing.

tobiberlin’s picture

I used patch #12 but now the following notice message show off during cron (in Drupal logs):

Notice: Undefined property: RulesReactionRule::$language in pathauto_entity_presave() (Zeile 363 von /sites/all/modules/pathauto/pathauto.module).

Notice: Undefined property: OgMembershipType::$language in pathauto_entity_presave() (Zeile 363 von /sites/all/modules/pathauto/pathauto.module).

This is the code there - line 363 is the last line of the snippet:

  // Prevent rebuilding custom paths from node_save
  // when syncing translations
  if (!isset($entity->path['pathauto'])) {
  $langcode = $entity->language;

Seems that this patch makes trouble with entities like organic group membership or rules?!

Best,
Tobias

jenlampton’s picture

Title:"Generate automatic URL alias" stays checked after uncheck and save» "Generate automatic URL alias" stays checked after uncheck and save (and vice versa)

Yeah, I take it back too. The patch in #22 does not actually work for me. In fact, I think this whole issue is a dupe of https://drupal.org/node/936222

jenlampton’s picture

Status:Needs work» Closed (duplicate)

updating status. Please test the patch in the other issue!

ndobromirov’s picture

StatusFileSize
new3.2 KB

This is fixing the notices issue for me.
Based on the patch in #10.

glass.dimly’s picture

Version:7.x-1.2» 7.x-1.x-dev
Status:Closed (duplicate)» Active

I was experiencing the behavior that "generate automatic alias" remains checked after node save even after unchecking and adding a manual alias, and the new URL worked but forwarded to the old URL.

I patched from a comment, the supposed duplicate of this issue and I can confirm that the "generate automatic alias" no longer remains checked on save after applying the patch.

However, the old alias is still preferred over the new.

Disabling Global Redirect causes all aliases to function without forwarding.

Confirmed with both update actions, "Do nothing. Leave the old alias intact." and "Create a new alias. Leave the existing alias functioning."

I'm re-opening this and unmarking as duplicate because the "lack of forwarding to a the canonical URL" is a separate bug from "generate automatic alias remains checked after node save." Also, strangely enough, with "Create a new alias. Delete the old alias." The old alias doesn't get deleted and still functions. WTF.

Though, the lack of forwarding to a the canonical URL bug may belong in either Global Redirect or Path Redirect's issue cue.

I'm leaving this as "Major" and changing it to the dev branch, where I've replicated the issue. Sorry to mess with this big bug with so many subscribers, but that's how I sees it.

nrutkowski’s picture

I am having the same issue as glass.dimly. I need to change my url aliases for specific pages, however when I update them through workbench moderation the new alias does not replace the old one. I have tried all the settings for URL aliases ("Do nothing. Leave the old alias intact", "Create a new alias, Leave the existing alias functioning", "Create new alias, Delete the old alias") and none of them solve this issue.

The alias is updated in the $node object, however is displaying a 404 error if you manually enter the alias into the address bar.

I am using Pathauto Persistent to prevent the "Generate automatic URL alias" checkbox from staying checked when I save a draft, but the alias just does not seem to stick with the node.

jenstechs’s picture

I'm having the same issue as glass.dimly. When I edit a node and UN-check the "generate automatic alias" box, it stays checked and the previous alias is the one that's preferred. I have to go into the alias module and manually delete the alias in order to get it to stay! And, really, I don't want to delete the alias, I just don't want it to be the preferred path.

Stuck on a live server with thousands of nodes...

emanaton’s picture

Of note, i was just having this issue on a translatable site, and krishanchandra's steps above fixed it for me.

hschott’s picture

I think I'm having the opposite problem. To start, generate url alias is checked when creating new content. When saved the url shows the node id. If I choose edit the generate url alias is unchecked. I can't get it to generate an alias, but can type in my own url.

hschott’s picture

My issue was the url alias /patterns changed. Once I set the paths using new tokens, it worked. Still having problem. It creates the alias, but it's not using the tokens correctly. Getting urls like this: featured/create-featured

mccrodp’s picture

Status:Active» Needs review
StatusFileSize
new1.11 KB
PASSED: [[SimpleTest]]: [MySQL] 337 pass(es).
[ View ]

The patch in #22 is working for me and I re-rolled against latest dev in attempt to pass all tests.

I added a check for $language property that was causing the test failure.

<?php
 
if (!isset($entity->path['pathauto']) && !empty($entity->language)) {
   
$langcode = $entity->language;
?>

Was this patch working for other people having this issue, from #28 onwards?

jayhawkfan75’s picture

@mccrodp: Patch #34 fixed this issue for me.

wiipiiw’s picture

#34 is also working for me. Thx!

podarok’s picture

Status:Needs review» Reviewed & tested by the community

#34 works for me too
Let's get committed

aminebourkadi’s picture

Thank you very much, how to install the path #34 ?

mccrodp’s picture

@aminebourkadi Are you asking, how to apply a patch?

All looking good so far!

aminebourkadi’s picture

StatusFileSize
new58.16 KB

The patch #34 didn't fix my issue , no url rewriting is workin and i still get the native drupal url like "node/23" .
As i see i have 2 problems here:

  1. The url "admin/config/search/path/patterns" don't return the old path configuration forms :Only local images are allowed.
  2. The second notice is that when i try to add or edit an existant node ( with no url alias ) i get the message:
    The Titre de page utilise les jetons (tokens) invalides suivants : [node:title], [site:name].
    The Description utilise les jetons (tokens) invalides suivants : [current-page:title], [node:summary], [node:field-tags].
    The Résumé utilise les jetons (tokens) invalides suivants : [current-page:title], [node:summary].
    The Mots-clés utilise les jetons (tokens) invalides suivants : [node:field-tags].
    The Image utilise les jetons (tokens) invalides suivants : [node:field_photo].
    The URL canonique utilise les jetons (tokens) invalides suivants : [current-page:url].
    The URL raccourcie utilise les jetons (tokens) invalides suivants : [current-page:url:brief].
    The Page URL utilise les jetons (tokens) invalides suivants : [current-page:title].
    The Titre utilise les jetons (tokens) invalides suivants : [node:title].
    The Description utilise les jetons (tokens) invalides suivants : [node:summary], [node:field-tags].
    The URL de l'image utilise les jetons (tokens) invalides suivants : [node:field_photo].

Can anyone help me please

mccrodp’s picture

This patch should not affect the Alias Pattern form display at admin/config/search/path/patterns. It contains code for pathauto's hook_entity_presave only.

  1. Did this patterns form display issue exist before you patched the module?
  2. Do these tokens work elsewhere on the site?

I think both of these issues may be related to each other but separate from the problem in this issue. You may need to look at your tokens, it may be an issue with Token module you are experiencing.

aminebourkadi’s picture

I found the solution here and it's pretty fine right now

Marko B’s picture

#34 seems to work fine and described the problem very well. thanx

ygerasimov’s picture

Status:Reviewed & tested by the community» Needs work

Unfortunately patch makes fieldable_panel_panes to be unusable. The problem is that path property got changed to be array. pathauto should actually check whether this entity should have pathauto settings or not.

ygerasimov’s picture

Status:Needs work» Needs review
StatusFileSize
new1.73 KB
PASSED: [[SimpleTest]]: [MySQL] 337 pass(es).
[ View ]

Here is updated patch that adds a check if entity type supports pathauto. It looks pretty hacky to me, but I don't see nicer solution at the moment.

Dave Reid’s picture

This needs SimpleTests to confirm the problem and ensure this won't regress in the future.