on line 791 (file i18n_menu.module) add condition

$query->condition('m.path', 'IS NOT NULL');

CommentFileSizeAuthor
#4 i18n_menu_fix_sql-1203224-4705144.patch527 bytesXaber

Comments

Xaber’s picture

Version: 7.x-1.0-beta7 » 7.x-1.0-beta6
jose reyero’s picture

Status: Patch (to be ported) » Postponed (maintainer needs more info)

Why? Where? (line does not exist)

Xaber’s picture

Version: 7.x-1.0-beta6 » 7.x-1.0-beta7

Now in my file i18n_menu.module on the end of file a have this code

/**
 * Load menu item by path, language
 */
function i18n_menu_link_load($path, $langcode) {
  $query = db_select('menu_links', 'ml');
  $query->leftJoin('menu_router', 'm', 'm.path = ml.router_path');
  $query->fields('ml');
  // Weight should be taken from {menu_links}, not {menu_router}.
  $query->addField('ml', 'weight', 'link_weight');
  $query->fields('m');
  $query->condition('ml.link_path', $path);
  $query->condition('ml.language', $langcode);
  $query->condition('m.path', 'IS NOT NULL'); // <--- fix here
  if ($item = $query->execute()->fetchAssoc()) {
    $item['weight'] = $item['link_weight'];
    _menu_link_translate($item);
    return $item;
  }
}

What is the problem?

If you add more than one language (in my case 4: English, French, German and Russian), and by default not English, there is a problem switching to a language which is set as the default language.

When selecting from the database returns a string, from which eventually formed the wrong URL, which is required in reality.

For example, when I'm on the home page, activate the English version of the site - I'm staying on the main page, with English translation of an activated interface. If I try to change to another language, except for the default language - everything will be fine (although to be honest - a stress test were not satisfied). And if I want to switch to the default language does not get home, and some or the other (usually the 1st page of the menu).

Xaber’s picture

StatusFileSize
new527 bytes
jose reyero’s picture

Sorry but I still don't understand the issue. Would you mind filling your example with real data? (paths, links, menu items, etc)

Also, about the patch, looks like it would be the same as replacing the LEFT JOIN with an INNER JOIN (so no null rows are returned from the second table) and I'm not sure that would work for all cases.

jose reyero’s picture

Status: Postponed (maintainer needs more info) » Closed (cannot reproduce)