I'm having a Problem where I have difficulties to get to the bottom of it.
After a deploying process, which ends with a "drush cr" I see randomly fails, where i get this error on a page call:
"Error: Call to undefined method Drupal\menu_link_content\Plugin\Menu\MenuLinkContent::getLanguage() in Drupal\menu_multilingual\Menu\MenuMultilingualLinkTreeModifier->isTranslatedMenuLinkContentMultilingual() (line 263 of modules/contrib/menu_multilingual/src/Menu/MenuMultilingualLinkTreeModifier.php)."
After another cache-clear, this disappers, until maybe the next time. I don't find a pattern. Sometimes every page is available after deploying, sometimes one page has this issue. And not always the same page.
Once I had the chance to get this in my local envoirenment, and saw the error while checking an untranslated menu-item, which is an instance of "MenuLinkContent". Every other menu-item before is an instance of "MenuLinkContentMultilingual" (they are translated).
I added a workaround with "method_exists($link, 'getLanguage')" before line 263 of modules/contrib/menu_multilingual/src/Menu/MenuMultilingualLinkTreeModifier.php, to avoid this from happening. But i can't figure out why the method is not available, only after a cache rebuild.
Anyone a idea what may be the cause of this?
| Comment | File | Size | Author |
|---|---|---|---|
| #5 | undefined-getlanguage-2874792-5.patch | 568 bytes | guncha25 |
Comments
Comment #2
znak commentedComment #3
znak commentedIt works fine on my site. Maybe problems only in your site?
Comment #4
guncha25 commented+1
Comment #5
guncha25 commentedComment #6
maacl commentedThanks! I can not reproduce it right now, even with the filecopy/db-dump from last week, but the change in your patch looks reasonable. Applied it to my code and will see what happens the next days.
Comment #7
rvelhote commentedAlso ran into the same issue as guncha25 and his patch in #5 solved the issue.
I think the patch is correct because
isTranslatedMenuLinkContentMultilingualattempts to callgetLanguageand crashes if it does not exist. Therefore it makes sense to check fornoMethodGetLanguagein the list of callbacks before proceeding.Comment #9
vlad.dancerThanks, folks! Commited.