- Issue created by @alorenc
- 🇵🇹Portugal dxvargas
I didn't reproduce the problem but just by looking at the code, since
getTranslateRoute()
can return NULL, I will mark this issue and it's MR as RTBC. - 🇨🇦Canada joelpittet Vancouver
Yes
getTranslateRoute
returnsNULL
butMenuLinkBase::isTranslatable()
uses it and casts it to a boolean:https://git.drupalcode.org/project/drupal/-/blob/11.x/core/lib/Drupal/Co...
public function isTranslatable() { return (bool) $this->getTranslateRoute(); }
And, yes, in this case the following overrides that:
https://git.drupalcode.org/project/drupal/-/blob/11.x/core/modules/menu_...public function isTranslatable() { return $this->getEntity()->isTranslatable(); }
It's a bit confusing because the first is doing
isTranslatable
on the MenuLink, and the second is checking the entity referenced by the menu link. Doesn't that seem inherently wrong to anybody else?In any case I am hopeful not to have the assignment inside a condition and second, if we are getting a route of the entity, we should check it, and not the menu link. I will post a proposed suggestion on the code.