i18n uses custom_url_rewrite() to give paths language-dependent aliases. This works when a module calls drupal_get_path_alias(). However, the parallel implementation is missing. drupal_get_normal_path() also invokes custom_url_rewrite(). i18n needs to respond, returning the normal path.

To put the case another way: every custom_url_rewrite() implementation should have not just one but two parts:

  1. Respond to an 'alias' request as passed in by drupal_get_path_alias(), to convert an path into a new format.
  2. Do the opposite: given what is potentially an alias, respond to a 'source' request as passed in by drupal_get_normal_path() and return the normal path.

This error has come up e.g., in this bug, http://drupal.org/node/96934.

The fix is easy. We already have the needed function, i18n_get_normal_path(). All we need to do is add a call to this to the custom_url_rewrite() implementation.

Patch attached. This patch fixes the issue in activemenu module.

CommentFileSizeAuthor
i18n-custom_url_rewrite.patch1.06 KBnedjo

Comments

nedjo’s picture

This seems like a fairly straightforward fix. Any questions or issues?

jose reyero’s picture

Status: Needs review » Needs work

Ummm.. yes, there's an issue.

I see what you say makes sense and this will probably fix some other funny issues with the menu system. So I'll be fixing this...

But with this patch, the 'custom_url_rewrite' logic is somehow broken. It needs to return always a path.

jose reyero’s picture

Status: Needs work » Fixed

I've just committed some more polished version of this, also saving some path queries in some cases.

Please, let me know whether this works for you.

Anonymous’s picture

Status: Fixed » Closed (fixed)