Drupal 7.18
i18n 1.7 & 1.8
Pathautho 1.2 & 1.x-dev

Steps to reproduce:
1. Add new node in default language. Alias is generated well and works. There is only one nuance - it is language neutral.
2. Add a translation for that node. After adding alias for default language will be lost because there is no alias for that language in database. Alias for translation is generated well in correct language.
3. If you edit default language for that node and set "Generate automatic alias" (because it is bacame unset after translation addition) than the alias will be generated well for default language too.

I think this is related to ET because if I switch node translation type from "Enabled, with field translation" to "Enabled, with translation" alias is generated well in default language after 1'st step.

Files: 
CommentFileSizeAuthor
#8 entitytranslation-incorrect_pathauto_pattern-1925848-8.patch686 bytesBußmeyer
PASSED: [[SimpleTest]]: [MySQL] 681 pass(es).
[ View ]

Comments

Merlineus’s picture

It seems that issue is related to drupal core.
For some reason entity_language() returns und for newly created node. On node update return value is correct.
On local system all works fine.

Merlineus’s picture

No, it's not in core.
entity_translation_current_form_get_handler() returns empty handler when called from pathauto_entity_language().

Merlineus’s picture

The problem introduced in the dev version.
Fallback to beta2 fixes the issue.

It is related to changes in entity_translation_language.

Merlineus’s picture

plach’s picture

Component:Node translation upgrade» Base system
Status:Active» Postponed (maintainer needs more info)

Cannot reproduce this: tested with the latest dev of Core, ET, Pathauto and Token. Please provide the exact steps to reproduce this on a clean installation.

joel_osc’s picture

I am seeing this too and downgrading to beta2 fixed the issue. I think it is something with the patch mentioned in #4, because when I step through it in the debugger in includes/translation.handler.inc:: function getLanguage $this->entity is only the default entity object with no nid, title, language, etc. defined even though this gets called after node_save so the $node object is already populated with an nid and language well before.

I will see if I can get more information on a minimal configuration which induces the issue.

plach’s picture

Can you try the patch at #1865244: Allow multiple translation handlers on the same form? It's apparently unrelated but it deeply refactors handler instantiation so it may fix this (and break many more things ;)

Bußmeyer’s picture

StatusFileSize
new686 bytes
PASSED: [[SimpleTest]]: [MySQL] 681 pass(es).
[ View ]

I can reproduce this.

The method isWrappedEntity() tries to compare the entity type and id of the current entity and the entity information in the EntityTranslationHandler object.

The function entity_translation_language() is called twice. On the submission of the edit form and through pathauto. In the first run there is no entity id in the entity nor in the entity information of the EntityTranslationHandler object. The return value of the method isWrappedEntity() is true.

When pathauto calls entity_translation_language() the entity id is set in the entity but not in the entity information of the EntityTranslationHandler object.

My patch tries to fix this and updates the entity information of the EntityTranslationHandler object.

Bußmeyer’s picture

Status:Postponed (maintainer needs more info)» Needs review
plach’s picture

Status:Needs review» Postponed (maintainer needs more info)

Can you please try #1865244: Allow multiple translation handlers on the same form and see whether it fixes this issue? Since it's touching the same code I'd wish to avoid committing a conflicting patch.

eidoscom’s picture

patch on #8 works for me. Applied and after bulk update the urls are correct!!! Thanks!

plach’s picture

Just to clarify: #8 won't be committed if I don't get a feedback about #10.

eidoscom’s picture

I removed patch in #8 and applied the patch in #10.

Applying, it throw me some errors:

\sites\all\modules\entity_translation\entity_translation.info (Cannot apply hunk @@ 6 )
\sites\all\modules\entity_translation\entity_translation.module (Cannot apply hunk @@ 30 )
\sites\all\modules\entity_translation\includes\translation.handler.inc (Cannot apply hunk @@ 7 )

After bulk update the urls are not correct.

eidoscom’s picture

I must apply to dev??

I applied in 7.x-1.0-beta2

eidoscom’s picture

Installed dev, applied path from #10 but after bulk alias update, the tokens are not getting the correct language:

  1. Taxonomy term paths are updated but with no language variation in tokens. Translated the "node-title" but no the other tokens. Perhaps is another issue??
  2. Content paths are updated but with no language variation in tokens. Translated the "node-title" but no the other tokens. Perhaps another issue??

With dev version an patch #10 applied, patch in #8 failed to apply and then we can't see if it works...

plach’s picture

Ok, thanks for the test. The two patches are somehow conflicting and we need a solution that will work even with #1865244: Allow multiple translation handlers on the same form applied.

Meanwhile it would be good to know how to reproduce this issue.

milesw’s picture

This problem isn't specific to Pathauto, I experienced symptoms using Rules. Field values for new nodes appear to be empty in Rules when they are actually populated. Existing nodes are fine, this is only newly inserted nodes. Tracked it down to entity_language() and entity_translation_language(), as described by other posters here.

The patch in #8 resolves the issue for me. The patch in #1865244: Allow multiple translation handlers on the same form does resolve the issue as well.

Steps to reproduce:

  1. Enable field translation for a content type
  2. Add a text field called field_text
  3. Enable translation for field_text
  4. Create a blank module and implement hook_node_insert()
    <?php
    /**
     * Implements hook_node_insert().
     */
    function etdemo_node_insert($node) {
     
    $langcode = entity_language('node', $node);
     
    // This should be the node language but always ends up LANGUAGE_NONE.
     
    dpm($langcode);
    }
    ?>
milesw’s picture

Status:Postponed (maintainer needs more info)» Needs review

Changing status.

das-peter’s picture

I had the same issue.
How I reproduced it:

  • Setup: Enabled & configured Entity Translation / Pathauto (Automatic alias pattern: node:title-field
  • Create new node using UI, set language to something else than language neutral.
  • Check the created alias in table url_alias to ensure the proper language is set.

With the latest patch from #1865244-29: Allow multiple translation handlers on the same form to problem seems to be solved!
At least now I get an alias in the proper language after node creation instead one with language neutral (und).
An stepping through the code shows that entity_language() now returns the proper language in e.g. hook_node_insert().
I didn't check bulk alias update though.

@eidoscom: Did you try [node:title-field] as token? [node:title] can be a bit tricky because it's handled by the title module.

plach’s picture

Status:Needs review» Postponed (maintainer needs more info)

#1865244: Allow multiple translation handlers on the same form went in. Please check whether this is fixed now.

plach’s picture

Issue summary:View changes

Pathautho 1.x-dev also tested

guillaumev’s picture

Issue summary:View changes
Status:Postponed (maintainer needs more info)» Fixed

I had the same issue but, after upgrading to entity_translation 1.x-dev and clearing the caches, it went away. I'm marking this as fixed.

Status:Fixed» Closed (fixed)

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

timme77’s picture

Patch #8 works fine for me!

niechea’s picture

Patch #8 also works for me...

It was pathauto that brought the issue to my attention, after debugging I noticed that entity_language was returning LANGUAGE_NONE on node insert, when it really should have been 'en', this actually causes no path to be generated in my case.

In the comments above someone mentions entity_translation_current_form_get_handler(), but I really can't see how this ties in with core's entity_language?