I write my setup:
Node page settings, in the book field (for every book) I have:
b/[bookpath-raw]/[title-raw]

Then I create a book with some child book pages in english for example and the alias is created correctly. For example:
example.com/b/mybook/introduction (where my book is the first page of the book, and introduction is the child)

Now, I translate the content to spanish, so I get the following path:
example.com/es/b/milibro/introduccion (where milibro and introduccion are the translated page of mybook, and introduction respectively)

Everything fine until I recheck the paths for the english version, and those are changed to:
example.com/b/introduction (without "mybook" in the path)

And the same for all the childs, etc.
If I edit the english page the it recreates the correct path again, but then the spanish path version is modified to
example.com/es/introduccion (without "milibro" in the path)

Using i18n module and pathauto

Thanks for the help.

CommentFileSizeAuthor
#9 menu.inc_.patch576 bytesclaudiu.cristea
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

davebv’s picture

nobody? is there any other related post to this?

greggles’s picture

Component: Code » i18n Stuff

Sorry. I don't use the i18n module and I don't have any ideas, so I can' t help with this.

Maybe Freso can, but I don't think he uses i18n either.

Freso’s picture

This sounds rather weird. What other (node) alias patterns have you set up?

davebv’s picture

Component: i18n Stuff » Code

I have:

default node path pattern

c/[title-raw]

default path pattern for blog post

blog/[title-raw]

default path pattern for book pages (also for neutral, english and spanish languages, all the same)

b/[bookpath-raw]/[title-raw]

default path for Page nodes

p/[title-raw]

For Taxonomy I have the following:

default path pattern:
category/[vocab-raw]/[catpath-raw]

for Blog Tags vocabulary:
blog/[vocab-raw]/[catpath-raw]

Do you see anything weird? or bad configured?

greggles’s picture

Component: Code » I18n stuff
davebv’s picture

(sorry for having changed the component, I did not realised)

claudiu.cristea’s picture

It seems that this occur when i18n synchronize translations...

claudiu.cristea’s picture

Title: Wrong subpaths when translating content. » Book & Menu paths tokens not calculated on the second node on same request
Project: Pathauto » Token
Version: 7.x-1.x-dev » 6.x-1.11
Component: I18n stuff » Code

After making some investigations I found the following:

  1. This happens when i18n synchronizes the translations of the main node (which is being saved). The function i18nsync_node_translation() from module i18nsync (from i18n) saves also the translated nodes, using node_save().
  2. When node_save() is applied on the translated nodes, he ask all modules to act on the node update. And so Pathauto module is recreating the paths for the translated nodes.
  3. Pathauto is calling the Token module to build the the path's tokens.
  4. In functions node_token_values() and book_token_values() from token_node.inc, the Token module is calling for _menu_titles() to get the trail to the current book page (or the menu trail for the current node).
  5. _menu_titles() uses the menu_tree_all_data() function to obtain the hierarchy data for books and/or menus.
  6. The problem is that menu_tree_all_data() is returning no data when is called second time in the same request. And so _menu_titles() is returning an empty array that causes empty paths for [bookpath-raw], [bookpath], [menupath-raw] and [menupath] tokens for the second and next nodes saves in the same request.

Affected tokens:

  • [bookpath-raw]
  • [bookpath]
  • [menupath-raw]
  • [menupath]

Related issues

Actions taken:

  • Moved the ticket to Token module
  • Changed the title
claudiu.cristea’s picture

Status: Active » Needs review
FileSize
576 bytes

Digging more, I found that this is fired up by a line in menu.inc Drupal core file. In line ~970, function menu_tree_collect_node_links() we have:

      if (is_numeric($nid)) {
        $node_links[$nid][$tree[$key]['link']['mlid']] = &$tree[$key]['link'];
        $tree[$key]['link']['access'] = FALSE;
      }

You can see there that the access of the menu item ($tree[$key]['link']['access']) is set to FALSE. This is causing menu_tree_check_access() [called from menu_tree_all_data()] to exclude the item for menu trail.

It would have been desirable that function menu_tree_check_access() to set the proper access value... but it doesn't.

I hacked the Drupal file menu.inc as in the attached patch and now the paths are built fine on my site...

If you want to use the patch keep in mind that this patch is a Drupal core patch and can break other things on Drupal. Some testing and inputs can be valuable... Maybe some guys that designed the new Menu system can explain more here...

humble.techy’s picture

Is this related ? #242601: translate node references with i18nsync The patch is for 5.x

humble.techy’s picture

I disabled the synchronization for now to not to update the translated content.

Panchobook’s picture

In my experience of this bug, with any synchronization the url aliases to the translated nodes (not the one being saved) get completely wiped out, not only modified, as davebv reported.

Did as humble.techy and disabled all synch. Pathauto works fine then.

claudiu.cristea’s picture

I'm almost sure that this bug is caused because the items of the menu system that are in other language than the current language have the access property set to FALSE. This mean that when i18nsync tries to recompute the paths for the non-current-language menu items he cannot access them for read. This is causing the failure of getting the trail for the non-current-language menu items. This a by design issue.

My opinion is that this is a wrong approach to hide non-current-language menu items. The multilanguage system MUST NOT use access flag to hide those menu items. If they are in other language this DOESN'T MEAN that the user is denied to access them. It only means that they are hidden to user. A new flag must be used to hide other language menu/book items. Maybe something like hidden.

We need a qualified input here from developers of menu system and of the i18n on this issue!

claudiu.cristea’s picture

Project: Token » Internationalization
Version: 6.x-1.11 » 6.x-1.0
Status: Needs review » Active
Issue tags: +i18n, +menu

Moved the issue to Internationalization module while is related to translated menu items and i18nsync.

Jose Reyero’s picture

Category: bug » support
Status: Active » Postponed (maintainer needs more info)

It seems this issue has moved around a lot of modules. And while it's a side effect of how they all work, it's not really a bug on any of them

@claudiu,
I think you've made a great analysis of this issue in #8 and #13
I completely agree about the menu system issues.

As patching D6 core is not really an option and there's very little we can do on i18nsync alone, I think the better solution would be either:
- Not doing any path aliasing that depends on the page context (I can imagine this will fail too with any other module using node_load / node_save in a different page than node/x/edit.)
- Implementing some way to skip recalculating path aliases on node update. Though this may be an issue too because these paths may may actually need to be recalculated based on the updates done by i18nsync (tags, etc...)

Ideally, doing a node_save(node_load(nid)) should never change a node... Could this be a feature request for pathauto? If you find other contrib modules doing node updates using the api, maybe...

Btw, if someone wants to do some more research, what happens when you update several nodes at once using the content administration pages? does pathauto works fine on this case with such tokens?

ao2’s picture

@claudiu.cristea: isn't there a typo s/return/result/ in the patch posted in comment #9 ?

BTW, I also have this one triggered by pathauto with alias pattern for pages set to [manupath-raw].
I am sure your patch will work ok, but I read here this can be worked around also disabling i18nsync, well, I have it disabled in the module list, but the issue is still here, any more steps? Or patching core is the only viable option for now?

Thanks,
Antonio

claudiu.cristea’s picture

Please do not use that patch... It's not solving the issue

claudiu.cristea’s picture

Title: Book & Menu paths tokens not calculated for the translated nodes » Book & Menu paths tokens not calculated on the second node on same request
Status: Active » Postponed (maintainer needs more info)

@Jose,

Don't you think that this must be addressed now in D7 branch? As I mentioned and you agreed "non current language menu items" are hidden now based on the access. This flag is set to FALSE for those menu items. Being in other language doesn't mean unaccessible, it just mean hidden. If we want to access them, we cannot... And, yes, we surely want at least in i18n_sync module.

For this reason I think that we have to contact the menu system developers and fire up this issue and fix this in Drupal 7. My approach it would be to add an additional field (flag) to menu items, something like visible (boolean) that can be used by modules like i18n to hide menu items... (and not to make them inaccessible).

Any thoughts?

claudiu.cristea’s picture

Title: Book & Menu paths tokens not calculated on the second node on same request » Book & Menu paths tokens not calculated for the translated nodes
Version: 6.x-1.0 » master
Status: Postponed (maintainer needs more info) » Active

Changed also the status.

rolfmeijer’s picture

Title: Book & Menu paths tokens not calculated on the second node on same request » Book & Menu paths tokens not calculated for the translated nodes
Status: Postponed (maintainer needs more info) » Active

subscribing

TripleEmcoder’s picture

Subscribing.

colan’s picture

Subscribing.

joseph.olstad’s picture

Version: master » 6.x-1.x-dev
Component: Code » Blocks
Issue summary: View changes
Status: Active » Closed (outdated)

Appears to be a 6.x issue.
Closing;
Please see :
#1303518: Clean up the issue tracker. Close old issues without follow up.