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?

CommentFileSizeAuthor
#5 undefined-getlanguage-2874792-5.patch568 bytesguncha25

Comments

maacl created an issue. See original summary.

znak’s picture

Assigned: Unassigned » znak
znak’s picture

Assigned: znak » Unassigned
Status: Active » Postponed

It works fine on my site. Maybe problems only in your site?

guncha25’s picture

+1

guncha25’s picture

StatusFileSize
new568 bytes
maacl’s picture

Thanks! 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.

rvelhote’s picture

Also ran into the same issue as guncha25 and his patch in #5 solved the issue.

I think the patch is correct because isTranslatedMenuLinkContentMultilingual attempts to call getLanguage and crashes if it does not exist. Therefore it makes sense to check for noMethodGetLanguage in the list of callbacks before proceeding.

  • vlad.dancer committed bfaf8d1 on 8.x-1.x authored by guncha25
    Issue #2874792 by guncha25: Random Error: Call to undefined method...
vlad.dancer’s picture

Status: Postponed » Fixed

Thanks, folks! Commited.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.