The patch #2151147: 'Display number of items': calculation only for current language is discover a mistake in comparison from code https://drupal.org/comment/5739384#comment-5739384 (generating "Menu and taxonomy name mismatch" watchdog errors)
It compared "not translated menu item" with "partially translated taxonomy term":
Menu and taxonomy name mismatch: Auto (1) != Auto (0)
("partially translated" means we have translated only count of nodes)
So, we have "not translated menu item" such as "Some menu item (126)", and to be sure the appropriate term is exists (why is that need, by the way? is it anachronism?) we should compare not translated menu item without count of nodes and not translated taxonomy term's name. Here is the code:
instead of this code:

if ($item['title'] != $term->name . $display_num) {

i writed a new one:

$menu_item_name = preg_replace('/\s\(\d+\)$/i', '', $item['title']);
if ($menu_item_name != ($term->name)) {

It solves the problem with that error for me. When the setting "Display number of items" is not checked for some vocabulary, this code works fine too.
Appropriate patch is attached.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

flyke’s picture

Unfortunatly, this patch did not resolve my Menu and taxonomy name mismatch watchdog errors.

dxx’s picture

+1 for #1 confirmed with an Commerce Kickstart 2.x distribution with two languages.

I simply edited (opened, saved) the menu item and they translations in error and now have no errors into logs.

dxx’s picture

Status: Needs review » Needs work
mmtt’s picture

Same here. But the patch and way from #2 did not work for me. Unfortunatly not only the watchdog errors but look not nice but even the whole taxonomy menu disapears at the same time.

joseph.olstad’s picture

            if ($item['title'] != ($term->name . $display_num)) {
              // Return the tid from link_path which should be in the format taxonomy/term/99
              $tid = substr($item['link_path'], strrpos($item['link_path'], '/') + 1);
              // compare tid
              if ($tid == $term->tid ) {
                $numlangs = count($term->name_field);
                if ($numlangs == 2) {
                  $testterm = $term->name_field;
                  $testterm = array_shift($testterm);
                  $testterm = array_shift($testterm);
                  $testterm = array_shift($testterm);
                  if ($item['title'] != $testterm) {
                    // Should not happen
                    watchdog('error', 'Menu and taxonomy name mismatch: @title != @name', array('@title' => $item['title'], '@name' => $term->name . $display_num));
                  }
                } else {
                  // Should not happen
                  watchdog('error', 'Menu and taxonomy name mismatch: @title != @name', array('@title' => $item['title'], '@name' => $term->name . $display_num));
                }
              } else {
                // Should not happen
                watchdog('error', 'Menu and taxonomy name mismatch: @title != @name', array('@title' => $item['title'], '@name' => $term->name . $display_num));
              }
            }

code works for site with two languages where the name is the translated equivalent the watchdog is not written otherwise it is if the terms are not matching.

SEE PATCH 6 BELOW

joseph.olstad’s picture

Here's a patch based on comment #5 (with some minor cleanup and a few added comments)

joseph.olstad’s picture

Status: Needs work » Needs review
sahaj’s picture

Hi, I'm getting the following error message after applying the patch #6:

Notice: Undefined property: stdClass::$name_field in taxonomy_menu_translated_menu_link_alter() (line 1180 of ../profiles/commerce_kickstart/modules/contrib/taxonomy_menu/taxonomy_menu.module).

Any idea if this is something specific to Commerce Kickstart?

joseph.olstad’s picture

Hi Sahaj, hmm, I'd have to debug this a bit more closely and look a bit deeper, had another look at the patch and I cannot recall what name_field is , if it's a configuration for the taxonomy , maybe something not default, so probably have to do an isset on that to check to see first if its set before using it.

joseph.olstad’s picture

Status: Needs review » Needs work
Aambro’s picture

#6 worked for me. Thanks!

cmseasy’s picture

Patch 6 works on current dev, Thanks.
Why is this a 'needs work' and not a 'needs review'?

Alex Pshegodskyi’s picture

#6 does not work either on the 7.x-1.6 or on the 7.x-1.x-dev.
Notice: Undefined property: stdClass::$name_field in ***\sites\all\modules\taxonomy_menu\taxonomy_menu.module on line 1256
also errors Menu and taxonomy name mismatch still in wathdog

Vincent_Jo’s picture

Hi, confirming that patch #6 is not working (7.x-1.6).
Thought that error is gone, but after "rebuild menu" from taxonomy module, the error occurs again.

Like so:

Error: Menu and taxonomy name mismatch: (9) != Česká republika (9)

... and the menu shows strange behaviour concerning translations.

regards

Vincent Jo