Error: [] operator not supported for strings in claro_preprocess_admin_block_content()

Created on 18 September 2023, about 1 year ago
Updated 8 November 2023, about 1 year ago

Problem/Motivation

Error: [] operator not supported for strings in claro_preprocess_admin_block_content() (line 206 of core\themes\claro\claro.theme).
call_user_func_array('claro_preprocess_admin_block_content', Array) (Line: 285)
Drupal\Core\Theme\ThemeManager->render('admin_block_content', Array) (Line: 433)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 204)
Drupal\Core\Render\Renderer->render(Array) (Line: 477)

Steps to reproduce

I am getting error when click on admin/config link by admin user
Config :Drupal 10.0.10
PHP 8.1.12

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

🐛 Bug report
Status

Postponed: needs info

Version

10.0

Component
Claro 

Last updated about 5 hours ago

Created by

🇮🇳India ashutosh.mishra

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

Comments & Activities

  • Issue created by @ashutosh.mishra
  • 🇮🇳India shiv_yadav

    Hello ashutosh.mishra,
    I install claro theme but I have not got any error. Shared screenshot as well .
    my configuration:
    drupal-10.1.3
    php 8.1.2

  • Status changed to Postponed: needs info about 1 year ago
  • 🇮🇳India viren18febS

    Not able to reproduce the issue!

  • 🇷🇺Russia danny-dee

    We've encountered the same issue on the following page: /en/admin/
    This happens on all environments including production.
    Drupal version we use is 9.5.10.

    I've attached a patch that works for us, it simply negates the issue, but does not address it's root.
    ashutosh.mishra please test this patch

    Thanks

  • 🇪🇸Spain eduardo morales alberti Spain, 🇪🇺

    The attributes options should be an array https://git.drupalcode.org/project/drupal/-/blob/11.x/core/lib/Drupal/Co...

       *   - 'attributes': An associative array of HTML attributes that will be
       *     added to the anchor tag if you use the \Drupal\Core\Link class to make
       *     the link.
    

    So if the getOption returns a string, then the definition of the item is not correct.

     $item['url']->getOption('attributes') ?: [];
    
  • 🇪🇸Spain eduardo morales alberti Spain, 🇪🇺

    In our case, it is because of a view menu tab.

    MariaDB [drupal]> select route_name, url, menu_name, parent, provider from menu_tree where options like '%class";s:0%';
    +---------------------------+-----+-----------+--------------------+-------------------+
    | route_name                | url | menu_name | parent             | provider          |
    +---------------------------+-----+-----------+--------------------+-------------------+
    | view.reporter_news.page_1 |     | admin     | mysite.admin | menu_link_content |
    +---------------------------+-----+-----------+--------------------+-------------------+
    1 row in set (0.001 sec)
    

    Column options unserialized:

    array (
      'attributes' => 
      array (
        'title' => '',
        'id' => '',
        'name' => '',
        'rel' => '',
        'class' => '',
        'style' => '',
        'target' => '',
        'accesskey' => '',
      ),
      'item_attributes' => 
      array (
        'id' => '',
        'class' => '',
        'style' => '',
      ),
      'query' => 
      array (
      ),
    )
    

    We are not sure, why views are saving the class as a string instead of an array.

  • 🇪🇸Spain eduardo morales alberti Spain, 🇪🇺

    After some research seems like like is a custom menu item, and the attributes comes from menu_link_attributes

Production build 0.71.5 2024