Some field types that have a compound storage like list_text will return an array for its item labels. ctools_entity_field_value_ctools_access_summary() expects $conf[$conf_key] to be a string but with list fields this is not the case, and thus when it passes $values onto t() it causes a PHP array to string notice (and leaves summary parts of pages with empty values).

I've encountered this with Panels Everywhere so the bug may lie in its usage of ctools' function calls but as the documentation of ctools_entity_field_value_ctools_access_summary() is basically non-existant I don't know if the $conf parameter is set wrong but looking at debug_backtrace() I would think this is a fare usage by Panels Everywhere.

Steps to reproduce

Install Panels Everywhere and configure a theme for it. Make a variation that depends on Node context being present.
Create a Node content type with a list_text field and set it up with a few values. In my case I used it to control visibility of panel panes on the page. E.g. field_disable_page_content:

sidebars|Sidebars
title|Page title
breadcrumb|Breadcrumb

Go back to Panels Everywhere page editor (e.g. Default site template) and configure a panel pane's visibility to hide based on the value of the list_text field created earlier.

Save and the page and panels will behave as expected. Visiting the site template editor again and going to the variation's content editor will trigger the error. This is because $conf contains values similar to:

Array
(
    [field_disable_page_content] => Array
        (
            [und] => Array
                (
                    [0] => Array
                        (
                            [value] => title
                        )

                )

        )

    [field_disable_page_content_value] => Array
        (
            [title] => title
            [sidebars] => 
            [breadcrumb] => 
        )

)

Solution

I doubt this is a proper solution (hence no patch at this time) but it does handle such cases better. In entity_field_value.inc ctools_entity_field_value_ctools_access_summary() within the foreach ($field['columns'] as $column => $attributes) loop (around line 213) change it from:

  foreach ($field['columns'] as $column => $attributes) {
    $conf_key = _field_sql_storage_columnname($field_name, $column);
    if (count($field['columns']) > 1) {
      // Add some sort of handling for compound fields
    }
    else {
      if (isset($conf[$conf_key])) {
        $entity->{$field_name}[LANGUAGE_NONE][] = array($column => $conf[$conf_key]);
      }
    }
    $string .= " @{$column} equals @{$column}_value";
    $keys['@' . $column] = $column;
    $values["@{$column}_value"] = $conf[$conf_key];
  }

to

  foreach ($field['columns'] as $column => $attributes) {
    $conf_key = _field_sql_storage_columnname($field_name, $column);
    if (count($field['columns']) > 1) {
      // Add some sort of handling for compound fields
    }
    else {
      if (isset($conf[$conf_key])) {
        $entity->{$field_name}[LANGUAGE_NONE][] = array($column => $conf[$conf_key]);
      }
    }
    $string .= " @{$column} equals @{$column}_value";
    $keys['@' . $column] = $column;
    if (is_array($conf[$conf_key])) {
      $str = '';
      foreach ($conf[$conf_key] as $key => $value) {
         // Might not be a good idea if '0' is an expected valid value.
         if (!empty($value)) {
            $str .= $key . ': ' . $value . ', ';
         }
      }
      $conf[$conf_key] = substr($str, 0, -2);
    }
    $values["@{$column}_value"] = $conf[$conf_key];
  }

That will generate a more useful message in the pane visibility summary and fix the PHP warning.

Closing as duplicate of #1630820.

Comments

maximpodorov’s picture

@magicmyth, could you try to apply this patch
https://drupal.org/comment/8434651#comment-8434651
and share your experience?
This patch provides the complete rewritten plugin which tries to keep compatibility with the old sites. If your problem is not fixed by the patch, I suggest to fix it, not the broken plugin.

magicmyth’s picture

Issue summary: View changes
Status: Active » Closed (duplicate)
Related issues: +#1630820: entity_field_value is completely broken

Thanks for the patch maximpodorov. Just go round to trying it out and it seems so far to resolve the problem. I'm going to take a stab a re-rolling it against HEAD and if successful will put the patch on #8434651.

magicmyth’s picture

Issue summary: View changes