Problem

When you add a bean in Panels via the "add content" menu, the panel admin interface for that panel will trigger an error:

Warning: strlen() expects parameter 1 to be string, array given in drupal_validate_utf8() (line 1587 of /Users/xxxxx/workspace/xxxxx/www/includes/bootstrap.inc).
Notice: Array to string conversion in filter_xss() (line 1442 of /Users/xxxxx/workspace/xxxxx/www/includes/common.inc).

How to reproduce

1. Create a new bean
2. Create a new custom page with the ctools page manager
3. Configure it to use Panels
4. On the administration interface for the page, navigate to Variants > Panel > Content
5. Click on a region settings dial and "add content"
6. Select the bean you've created and add it to the region
7. Save the page
8. Notice how PHP warnings/notices are triggered (PHP error_reporting should be E_ALL)

Cause

The bean_block_view() function outputs $return['content'] as an array instead of a rendered string.

Solution

Render $return['content'] before returning the block array.

In bean.module:

function bean_block_view($delta = '') {
  $return = array();
  $bean = bean_load_delta($delta);

  if (bean_access('view', $bean) && $bean) {
    $content = $bean->view($bean->view_mode);
    if (!is_array($content)) {
      $content = array(
        '#markup' => $content,
      );
    }

    $return = array(
      'content' => $content,
      'subject' => isset($bean->title) ? $bean->title : '',
    );
  }

  if (!empty($return['content']) && module_exists('contextual')) {
    $return['content']['#contextual_links']['bean'] = array(
      'block', array($bean->Identifier())
    );
  }

  $return['content'] = render($return['content']);

  return $return;
}

Comments

arithmetric’s picture

Version: 7.x-1.2 » 7.x-1.x-dev
Status: Active » Closed (duplicate)

This is due to a bug in ctools, which did not handle blocks returned as a render array or string. It is now fixed in the development version of ctools, which includes the patch from this issue: #1925018: Adding a renderable-array block to a page gives errors in the admin UI.