Skip to content
This repository has been archived by the owner on Sep 8, 2018. It is now read-only.

WSOD when module is enabled #4

Closed
froboy opened this issue Aug 1, 2017 · 1 comment
Closed

WSOD when module is enabled #4

froboy opened this issue Aug 1, 2017 · 1 comment

Comments

@froboy
Copy link
Contributor

froboy commented Aug 1, 2017

Brand new site (tested on D8.2 and 8.3), new subtheme of stable with basically nothing in it, got the following on enabling the module:

AH01071: Got error 'PHP message: Error: Cannot use string offset as an array in /var/www/ama-d8.local/web/modules/contrib/workbench_tabs/src/Element/LocalTasks.php on line 59 #0 [internal function]: Drupal\\workbench_tabs\\Element\\LocalTasks::preRenderLocalTasks(Array)
...

Commenting out that line $element[$key][$tab_key]['#theme'] = 'workbench_tabs_menu_local_task'; makes the site load again.

Dumping out $element before that gives the following:

  "#type" => "workbench_tabs_local_tasks"
  "#pre_render" => array:1 [▶]
  "#theme" => "workbench_tabs_menu_local_tasks"
  "#primary" => "A"
  "#secondary" => ""
  "#defaults_loaded" => true
]

for some elements, and somehow $elements[#primary] is getting a string "A" instead of being empty, which is causing the exception when the string is trying to be overridden by an array.

Adding

        if (!is_array($element[$key])) {
          $element[$key] = [];
        }

fixes things up, but I'm not sure if that's a solution to why there's that random "A" in there in the first place...

@froboy froboy changed the title WSOD on Drupal 8.2 WSOD when module is enabled Aug 1, 2017
@agentrickard
Copy link
Contributor

I think this is a PHP 7 issue.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants