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.
Comment | File | Size | Author |
---|---|---|---|
#6 | taxonomy_menu-watchdog_error_menu_and_taxonomy_name_mismatch-2160363-6.patch | 1.97 KB | joseph.olstad |
Comments
Comment #1
flyke CreditAttribution: flyke commentedUnfortunatly, this patch did not resolve my Menu and taxonomy name mismatch watchdog errors.
Comment #2
dxx CreditAttribution: dxx commented+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.
Comment #3
dxx CreditAttribution: dxx commentedComment #4
mmtt CreditAttribution: mmtt commentedSame 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.
Comment #5
joseph.olstadcode 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
Comment #6
joseph.olstadHere's a patch based on comment #5 (with some minor cleanup and a few added comments)
Comment #7
joseph.olstadComment #8
sahaj CreditAttribution: sahaj commentedHi, 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?
Comment #9
joseph.olstadHi 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.
Comment #10
joseph.olstadComment #11
Aambro CreditAttribution: Aambro commented#6 worked for me. Thanks!
Comment #12
cmseasy CreditAttribution: cmseasy commentedPatch 6 works on current dev, Thanks.
Why is this a 'needs work' and not a 'needs review'?
Comment #13
Alex Pshegodskyi CreditAttribution: Alex Pshegodskyi commented#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
Comment #14
Vincent_Jo CreditAttribution: Vincent_Jo commentedHi, 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:
... and the menu shows strange behaviour concerning translations.
regards
Vincent Jo