After adding the blockswitcher block to a page I am getting the following errors:

    Warning: Invalid argument supplied for foreach() in element_children() (line 6548 of /var/www/html/cmhr.openplus.ca/includes/common.inc).
    Warning: Illegal string offset '#children' in drupal_render() (line 6012 of /var/www/html/cmhr.openplus.ca/includes/common.inc).
    Warning: Illegal string offset '#children' in drupal_render() (line 6022 of /var/www/html/cmhr.openplus.ca/includes/common.inc).
    Warning: Illegal string offset '#children' in drupal_render() (line 6060 of /var/www/html/cmhr.openplus.ca/includes/common.inc).
    Warning: Illegal string offset '#printed' in drupal_render() (line 6067 of /var/www/html/cmhr.openplus.ca/includes/common.inc).

In looking at the code it appears that the error comes from openlayers_plus_behavior_blockswitcher.inc line 69 in the render function when drupal_render($block) is called:

  public function render(&$map) {
    drupal_add_js(drupal_get_path('module', 'openlayers_plus')
      . '/behaviors/openlayers_plus_behavior_blockswitcher.js');
    drupal_add_js('misc/jquery.cookie.js', 'file');
    if ($this->options['enabled']) {
      $block = module_invoke('openlayers_plus', 'block_view', 'blockswitcher');
      $this->options['block'] = drupal_render($block);

I don't think the render function likes the $block array that is being provided. I am not 100% sure, but I think it would make more sense to change this line to this which makes the errors go away and works properly:

$this->options['block'] = drupal_render($block['content']);

If it is agreed that this is the proper solution I would be happy to provide a patch.

CommentFileSizeAuthor
#2 illegal_string_errors-2135387-2.patch697 bytesjoel_osc

Comments

davidserene’s picture

Hi joel_osc, ive tried your solution and it does make the errors go away; we would be happy to receive your patch. Thanks

joel_osc’s picture

StatusFileSize
new697 bytes
joel_osc’s picture

Status: Active » Needs review

Patch uploaded for review.

davidserene’s picture

Thank you, I have pushed the changes to 7.x-3.x

batje’s picture

Status: Needs review » Closed (fixed)