I've seen a few of these in the PHP logs:

PHP Fatal error: Cannot use string offset as an array in ..\sites\all\modules\ui_cache_clear\ui_cache_clear.module on line 172

Here's the offending line:

$data['content']['#contextual_links']['ui_cache_clear'] = array(
'admin/structure/block/ui_cache_clear',
array($block->module, $block->delta),
);

So probably at some time either $data['content'] or $data['content']['#contextual_links'] ar holding a string instead of an array.

The cause for that being not an array is sure related to something else than this module, but I'm posting this for the record. I'll investigate if we can asume that $data['content']['#contextual_links'] is always an array (it should because we're altering a renderable array for the block..).

Comments

kalabro’s picture

I guess $data['content']['#contextual_links'] is string in your case (just because we ensure that $data['content'] is array on lines 165-171.
I think we can add one more check...

kalabro’s picture

So @david_garcia any news? Have you found the reason of the bug? Your feedback will be very helpful.

david_garcia’s picture

@kalabro thanks for the interest. I am still figuring out why is this happening, unluckily I am unable to catch the error "in-situ" and the only clue is in the fatal error logs, that have no stack trace.

david_garcia’s picture

The error happens when $data is a string with markup.

Of course, this is a bug somewhere else, but amazingly Drupal is rendering correctly that block!

$data is supposed to be an array with a "content" and "subject" key as the Block API mandates, but we could modifiy the module to exhibit a warning instead of a fatal error.

  • kalabro committed 87bf3f9 on 7.x-1.x
    Issue #2428751 by david_garcia, kalabro: Fixed Cannot use string offset...
kalabro’s picture

Status: Active » Needs review

Well, this commit should fix it. Could you please check is the error still exists?

david_garcia’s picture

I didn't test, but reading through the code I can confirm this will not work :(

$data['content'] = array('#markup' => $output);

If $data is a string, then doing $data['content'] will not convert $data into an array. (I'm not sure if a warning is being thrown).

This needs some refactoring, i'll be proposing a patch when I find some time.

Greetings and thanks!

david_garcia’s picture

Status: Needs review » Needs work

  • kalabro committed 4ffae7c on 7.x-1.x
    Issue #2428751 by david_garcia, kalabro: Fixed Cannot use string offset...
kalabro’s picture

Status: Needs work » Needs review

One more try :)

kalabro’s picture

Status: Needs review » Fixed

I released 7.x-1.0-beta6 now. Feel free to reopen this issue if error still exists.

david_garcia’s picture

Sorry for not giving feedback on this, I've been very bussy lately :(

The issue is gone with last changes.

Thank you very much!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.