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

Comments

ashutosh.mishra created an issue. See original summary.

shiv_yadav’s picture

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

ashutosh.mishra’s picture

StatusFileSize
new286.34 KB
ashutosh.mishra’s picture

Issue summary: View changes
viren18febs’s picture

Status: Active » Postponed (maintainer needs more info)

Not able to reproduce the issue!

danny-dee’s picture

StatusFileSize
new800 bytes

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

eduardo morales alberti’s picture

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') ?: [];
eduardo morales alberti’s picture

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 and why all the attributes are empty.

eduardo morales alberti’s picture

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

Version: 10.0.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

smustgrave’s picture

Status: Postponed (maintainer needs more info) » Closed (outdated)
Issue tags: +Bug Smash Initiative

Seems like the finding was bug in the contrib module, but if still an issue in D11 (without the contrib module) please re-open!