Call to a member function getOption() on string

Created on 3 October 2024, about 1 month ago

Problem/Motivation

Error : Call to a member function getOption() on string in Drupal\menu_firstchild\MenuItemParser->enabled() (line 157 of /web/modules/contrib/menu_firstchild/src/MenuItemParser.php).

Steps to reproduce

Use Gin admin theme and "New Drupal Navigation, Test integration" navigation toolbar.

πŸ› Bug report
Status

Active

Version

2.1

Component

Code

Created by

πŸ‡«πŸ‡·France slayne40

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @slayne40
  • πŸ‡«πŸ‡·France slayne40

    In protected function enabled, test if $item['url'] is an instance of Url.

  • πŸ‡ΊπŸ‡ΈUnited States pingevt

    @slayne40 - could you provide more details tot eh steps to reproduce? Which modules enabled, and actions and pages to reproduce the error, and if you have the full backtrace. Currently I can't reproduce the error.

    Overall, I don't see any reason not to have the change, so I'll add, I'd just like to understand how you got to the error.

    • pingevt β†’ committed 8d57571c on 2.x
      Issue #3478467 by slayne40: Call to a member function getOption() on...
  • πŸ‡«πŸ‡·France tostinni

    We also encounter the error, it was simply by enabling the new option from Gin theme "New Drupal Navigation, Test integration" and having menu_firstchild 2.1.0 enabled.
    I will instantly break all the pages of the site as the admin menu is visible everywhere.
    We have many modules enabled but this happened on various sites, so not sure if the list is relevant, but here are the menu modules that we have.

    $ drush pml --status=enabled  | grep menu
      Core             Custom Menu Links (menu_link_content)                                    Enabled   10.3.7         
      Core             Menu UI (menu_ui)                                                        Enabled   10.3.7         
      Other            Menu Block (menu_block)                                                  Enabled   8.x-1.10       
      Other            Menu Breadcrumb (menu_breadcrumb)                                        Enabled   2.0.0-alpha0   
      Menu             Menu Firstchild (menu_firstchild)                                        Enabled   2.1.0          
      Menu             Menu Item Extras (menu_item_extras)                                      Enabled   3.0.2          
      Other            Menu Link Attributes (menu_link_attributes)                              Enabled   8.x-1.4      

    Here is a backtrace.

    Error: Call to a member function getOption() on string in Drupal\menu_firstchild\MenuItemParser->enabled() (line 157 of modules/contrib/menu_firstchild/src/MenuItemParser.php).
    Drupal\menu_firstchild\MenuItemParser->parse() (Line: 134)
    menu_firstchild_preprocess_menu()
    call_user_func_array() (Line: 261)
    Drupal\Core\Theme\ThemeManager->render() (Line: 491)
    Drupal\Core\Render\Renderer->doRender() (Line: 504)
    Drupal\Core\Render\Renderer->doRender() (Line: 248)
    Drupal\Core\Render\Renderer->render() (Line: 475)
    Drupal\Core\Template\TwigExtension->escapeFilter() (Line: 101)
    __TwigTemplate_2335ff9fd92523ff22dd3c49fead835b->doDisplay() (Line: 360)
    Twig\Template->yield() (Line: 47)
    __TwigTemplate_7c97adda2d483fd8bf6f3ce8c72cfadf->doDisplay() (Line: 360)
    Twig\Template->yield() (Line: 335)
    Twig\Template->render() (Line: 38)
    Twig\TemplateWrapper->render() (Line: 33)
    twig_render_template() (Line: 348)
    Drupal\Core\Theme\ThemeManager->render() (Line: 491)
    Drupal\Core\Render\Renderer->doRender() (Line: 504)
    Drupal\Core\Render\Renderer->doRender() (Line: 248)
    Drupal\Core\Render\Renderer->render() (Line: 475)
    Drupal\Core\Template\TwigExtension->escapeFilter() (Line: 84)
    __TwigTemplate_3891a37b75e98d70a9d4abec65591d88->doDisplay() (Line: 360)
    Twig\Template->yield() (Line: 335)
    Twig\Template->render() (Line: 38)
    Twig\TemplateWrapper->render() (Line: 33)
    twig_render_template() (Line: 348)
    Drupal\Core\Theme\ThemeManager->render() (Line: 491)
    Drupal\Core\Render\Renderer->doRender() (Line: 248)
    Drupal\Core\Render\Renderer->render() (Line: 158)
    Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}() (Line: 638)
    Drupal\Core\Render\Renderer->executeInRenderContext() (Line: 159)
    Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse() (Line: 90)
    Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray()
    call_user_func() (Line: 111)
    Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch() (Line: 186)
    Symfony\Component\HttpKernel\HttpKernel->handleRaw() (Line: 76)
    Symfony\Component\HttpKernel\HttpKernel->handle() (Line: 53)
    Drupal\Core\StackMiddleware\Session->handle() (Line: 48)
    Drupal\Core\StackMiddleware\KernelPreHandle->handle() (Line: 28)
    Drupal\Core\StackMiddleware\ContentLength->handle() (Line: 32)
    Drupal\big_pipe\StackMiddleware\ContentLength->handle() (Line: 106)
    Drupal\page_cache\StackMiddleware\PageCache->pass() (Line: 85)
    Drupal\page_cache\StackMiddleware\PageCache->handle() (Line: 50)
    Drupal\ban\BanMiddleware->handle() (Line: 48)
    Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle() (Line: 51)
    Drupal\Core\StackMiddleware\NegotiationMiddleware->handle() (Line: 36)
    Drupal\Core\StackMiddleware\AjaxPageState->handle() (Line: 51)
    Drupal\Core\StackMiddleware\StackedHttpKernel->handle() (Line: 741)
    Drupal\Core\DrupalKernel->handle() (Line: 19)
    
  • πŸ‡ΊπŸ‡ΈUnited States pingevt

    @tostinni - have you tried either applying the patch above to 2.1.0 version, or upgrading to the 2.2.x version?

    I have a 2.1.1 ready to release, I was just waiting on any feedback before releasing.

    If applying the patch works for you, I can make the 2.1.1 release

  • πŸ‡«πŸ‡·France tostinni

    Yes, I forgot this point but yes, applying the patch here has fixed the issue for us.
    Thank you.

    PS : have you been able to reproduce and understand the issue ?

  • πŸ‡ΊπŸ‡ΈUnited States pingevt

    Awesome to hear, I'll make that release in a few minutes.

    And no, I haven't found the root of it yet. (of all my side projects, unfortunately this is pretty low), Your back trace and module list gives me some good starts. I'm curious if Menu Item Extras or Menu Link Attributes alters that url object as well. Regardless this actually gives me a starting point.

    I'll keep this issue in RTC for the moment, but I'll also create the release for 2.1.1

    Thanks for your input!

  • πŸ‡«πŸ‡·France tostinni

    I disabled all contrib menu module except menu_firstchild and the error is still there so I guess it's more related to Gin than other modules.

Production build 0.71.5 2024