Support from Acquia helps fund testing for Drupal Acquia logo

Comments

dawehner’s picture

Some links: #1338282: Fix php notice in menu_link_save() and https://gist.github.com/1987034

The proper way to fix that would be to write a recursive version of array_diff_assoc

johnv’s picture

Issue tags: -PHP 5.4

Line numbers have changed due to #1530740-4: views cache adds all css/js on hits unnecessarily,
So for better reference, this is the line to blame, causing the Notice:
if ($settings_diff = array_diff_assoc($js['settings']['data'], $start['settings']['data'])) {

Code has changed, so notice may not be applicable in -dev version.

deepbluesolutions’s picture

Im seeing this error as well, when the browser cache is empty, i see many

Notice: Array to string conversion in views_plugin_cache->gather_headers() (line 205 of /var/www/html/sites/all/modules/views/plugins/views_plugin_cache.inc).
Notice: Array to string conversion in views_plugin_cache->gather_headers() (line 205 of /var/www/html/sites/all/modules/views/plugins/views_plugin_cache.inc).
Notice: Array to string conversion in views_plugin_cache->gather_headers() (line 205

but when a page refresh occurs they disappear and dont reappear until the browser cache gets old.
I can reproduce, by clearing the browsers cache and revisiting the page.

im also seeing a similar situation when on a panels page, again a page refresh clears them

Notice: Array to string conversion in panels_cache_object->cache() (line 178 of /var/www/html/sites/all/modules/panels/includes/plugins.inc).
Notice: Array to string conversion in panels_cache_object->cache() (line 178 of /var/www/html/sites/all/modules/panels/includes/plugins.inc).
Notice: Array to string conversion in panels_cache_object->cache() (line 178 of /var/www/html/sites/all/modules/panels/includes/plugins.inc).
.... at least 100 repeats, also showing on line 183

confirmed 5.4 array_diff_assoc implementation issue as mentioned above.

related issue holding up features.

rodrigoaguilera’s picture

Issue tags: +PHP 5.4

I confirm the problem and add the tag

MGParisi’s picture

same problem:( WAMP server!

davidmac’s picture

Issue tags: +PHP 5.4

The amendment to PHP5.4

Array to String Conversion Notice

is designed to correct the random appearance of the word "Array" which pops up from time to time on rendered pages. You may have seen this when trying to output an array directly. The change is that now PHP5.4 assumes that this is most probably a bug, and issues a notice for it.

The problem with the notices, is that there are a lot of them, and as they get generated they impact page load speed (in Drupal 7 anyhow).

I've seen this today with a clients site which doesn't have control over the version of PHP installed on the server as it is a hybrid shared-host/VPS in this case. The hosting Co. updated to PHP5.4 yesterday and now each page load generates 30 notices of the following:

Notice: Array to string conversion in views_plugin_cache->gather_headers() (line 216 of ...sites/all/modules/views/plugins/views_plugin_cache.inc

and

Notice: Array to string conversion in views_plugin_cache->gather_headers() (line 211 of ...sites/all/modules/views/plugins/views_plugin_cache.inc

While I'm looking to patch this, I thought it was worth posting about here.

Installation of latest dev version of views today didn't help and I was wondering if there's any patch available?

davidmac’s picture

Forgot to mention that this is an issue cropping up across various modules and may need to be addressed at core level.

migmedia’s picture

It's a common problem: http://www.php.net/manual/en/function.array-diff-assoc.php#73972

Using something like this (from drupal core) should solve the problem.

function array_diff_assoc_recursive($array1, $array2) { 
    foreach ($array1 as $key => $value) { 
        if (is_array($value)) { 
              if (!isset($array2[$key]) || !is_array($array2[$key])) { 
                  $difference[$key] = $value; 
              } else { 
                  $new_diff = array_diff_assoc_recursive($value, $array2[$key]); 
                  if ($new_diff != FALSE) { 
                        $difference[$key] = $new_diff; 
                  } 
              } 
          } elseif (!isset($array2[$key]) || $array2[$key] != $value) { 
              $difference[$key] = $value; 
          } 
    } 
    return !isset($difference) ? 0 : $difference; 
} 
deepbluesolutions’s picture

thought seemed to helped, but doesnt seem to be available in core, views_plugin_cache.inc,

I also made sure cache was fully cleared, by restarting varnish and apache between any code changes.

if ($settings_diff = array_diff_assoc($js['settings']['data'], $start['settings']['data'])) {

So I have tried amending array_diff_assoc to array_diff_assoc_recursive and initially thought it had working, however since an update or gui cache clear, rather than drush, this function is not available. So I took your function and added it to my themes php library, but no joy, have tried also hacking views_plugin_cache.inc and place it in there but no joy, where would this function live in a drupal install.
This notice is driving me bonkers, I cant seem to stop it

with some debug

if (is_array($css)){
dsm($css)
}
if (is_array($css_start)){
dsm($css_start)
}

Im getting the Notice: Array to string conversion in views_plugin_cache->gather_headers() on each array_diff_assoc call in views_plugin_cache.inc

but variables supplied are arrays and from what i can see look the same, both arrays have 41 elements. Any one have any suggestions on how to stop this error ?

(Array, 41 elements)
sites/sitetest.co.uk/themes/sitetest/style.css (Array, 8 elements)
sites/sitetest.co.uk/themes/sitetest/custom.css (Array, 8 elements)
sites/sitetest.co.uk/themes/sitetest/buttons.css (Array, 8 elements)
misc/ui/jquery.ui.core.css (Array, 8 elements)
misc/ui/jquery.ui.theme.css (Array, 8 elements)
misc/ui/jquery.ui.accordion.css (Array, 8 elements)
sites/all/modules/accordion_blocks/accordion_init.css (Array, 8 elements)
sites/all/libraries/colorbox/example5/colorbox.css (Array, 8 elements)
sites/all/modules/comment_notify/comment_notify.css (Array, 8 elements)
sites/all/modules/ctools/css/ctools.css (Array, 8 elements)
sites/all/modules/dhtml_menu/dhtml_menu.css (Array, 8 elements)
modules/overlay/overlay-parent.css (Array, 8 elements)
sites/all/modules/panels/css/panels.css (Array, 8 elements)
misc/ui/jquery.ui.slider.css (Array, 8 elements)
sites/all/modules/simplenews/simplenews.css (Array, 8 elements)
modules/system/system.base.css (Array, 8 elements)
modules/system/system.menus.css (Array, 8 elements)
modules/system/system.messages.css (Array, 8 elements)
modules/system/system.theme.css (Array, 8 elements)
modules/aggregator/aggregator.css (Array, 8 elements)
modules/comment/comment.css (Array, 8 elements)
sites/all/modules/date/date_api/date.css (Array, 8 elements)
sites/all/modules/date/date_popup/themes/datepicker.1.7.css (Array, 8 elements)
sites/all/modules/date/date_repeat_field/date_repeat_field.css (Array, 8 elements)
modules/field/theme/field.css (Array, 8 elements)
sites/all/modules/motors/motors.css (Array, 8 elements)
modules/node/node.css (Array, 8 elements)
modules/poll/poll.css (Array, 8 elements)
modules/search/search.css (Array, 8 elements)
modules/user/user.css (Array, 8 elements)
sites/all/modules/video_filter/video_filter.css (Array, 8 elements)
modules/forum/forum.css (Array, 8 elements)
sites/all/modules/views/css/views.css (Array, 8 elements)
sites/all/modules/views_slideshow/views_slideshow.css (Array, 8 elements)
sites/all/modules/views_slideshow_xtra/views_slideshow_xtra.css (Array, 8 elements)
sites/all/modules/extlink/extlink.css (Array, 8 elements)
sites/all/modules/devel/devel.css (Array, 8 elements)
sites/all/modules/panels/plugins/layouts/flexible/flexible.css (Array, 8 elements)
modules/contextual/contextual.css (Array, 8 elements)
sites/all/modules/views_slideshow/contrib/views_slideshow_cycle/views_slideshow_cycle.css (Array, 8 elements)
public://ctools/css/4424943ae60642295ebbefc005a9b9c8.css (Array, 8 elements)
Krumo version 0.2.1a | http://krumo.sourceforge.net Called from /var/www/html/sites/all/modules/views/plugins/views_plugin_cache.inc, line 203

(Array, 41 elements)
sites/sitetest.co.uk/themes/sitetest/style.css (Array, 8 elements)
sites/sitetest.co.uk/themes/sitetest/custom.css (Array, 8 elements)
sites/sitetest.co.uk/themes/sitetest/buttons.css (Array, 8 elements)
misc/ui/jquery.ui.core.css (Array, 8 elements)
misc/ui/jquery.ui.theme.css (Array, 8 elements)
misc/ui/jquery.ui.accordion.css (Array, 8 elements)
sites/all/modules/accordion_blocks/accordion_init.css (Array, 8 elements)
sites/all/libraries/colorbox/example5/colorbox.css (Array, 8 elements)
sites/all/modules/comment_notify/comment_notify.css (Array, 8 elements)
sites/all/modules/ctools/css/ctools.css (Array, 8 elements)
sites/all/modules/dhtml_menu/dhtml_menu.css (Array, 8 elements)
modules/overlay/overlay-parent.css (Array, 8 elements)
sites/all/modules/panels/css/panels.css (Array, 8 elements)
misc/ui/jquery.ui.slider.css (Array, 8 elements)
sites/all/modules/simplenews/simplenews.css (Array, 8 elements)
modules/system/system.base.css (Array, 8 elements)
modules/system/system.menus.css (Array, 8 elements)
modules/system/system.messages.css (Array, 8 elements)
modules/system/system.theme.css (Array, 8 elements)
modules/aggregator/aggregator.css (Array, 8 elements)
modules/comment/comment.css (Array, 8 elements)
sites/all/modules/date/date_api/date.css (Array, 8 elements)
sites/all/modules/date/date_popup/themes/datepicker.1.7.css (Array, 8 elements)
sites/all/modules/date/date_repeat_field/date_repeat_field.css (Array, 8 elements)
modules/field/theme/field.css (Array, 8 elements)
sites/all/modules/motors/motors.css (Array, 8 elements)
modules/node/node.css (Array, 8 elements)
modules/poll/poll.css (Array, 8 elements)
modules/search/search.css (Array, 8 elements)
modules/user/user.css (Array, 8 elements)
sites/all/modules/video_filter/video_filter.css (Array, 8 elements)
modules/forum/forum.css (Array, 8 elements)
sites/all/modules/views/css/views.css (Array, 8 elements)
sites/all/modules/views_slideshow/views_slideshow.css (Array, 8 elements)
sites/all/modules/views_slideshow_xtra/views_slideshow_xtra.css (Array, 8 elements)
sites/all/modules/extlink/extlink.css (Array, 8 elements)
sites/all/modules/devel/devel.css (Array, 8 elements)
sites/all/modules/panels/plugins/layouts/flexible/flexible.css (Array, 8 elements)
modules/contextual/contextual.css (Array, 8 elements)
sites/all/modules/views_slideshow/contrib/views_slideshow_cycle/views_slideshow_cycle.css (Array, 8 elements)
public://ctools/css/4424943ae60642295ebbefc005a9b9c8.css (Array, 8 elements)

deepbluesolutions’s picture

Version: 7.x-3.3 » 7.x-3.x-dev

I am also seeing this problem with the dev version

deepbluesolutions’s picture

ok, have got a working fix, not sure its the best way but it solves my problem for the moment.

so my changes were to views_plugin_cache.inc

[root@webnetwork plugins]# diff views_plugin_cache.inc /var/www/html/sites/all/modules/views/plugins/views_plugin_cache.inc

206d205
<     $this->storage['css'] = array_diff_assoc($css, $css_start);
207a207
>     $this->storage['css'] = array_diff_assoc_recursive($css, $css_start);
213,214c213
<     $this->storage['js'] = array_diff_assoc($js, $js_start);
<
---
>     $this->storage['js'] = array_diff_assoc_recursive($js, $js_start);
218c217
<     $this->storage['js']['settings'] = array_diff_assoc($settings, $settings_start);
---
>     $this->storage['js']['settings']['data'] = array_diff_assoc_recursive($settings, $settings_start);
221c220
<     $this->storage['headers'] = array_diff_assoc(drupal_get_http_header(), $this->storage['headers']);
---
>     $this->storage['headers'] = array_diff_assoc_recursive(drupal_get_http_header(), $this->storage['headers']);
232a232
>       if (isset($args['data'])){
233a234
>       }
238a240
>         if (isset($args['data'])){
239a242
>         }
268c271,273
<           $build_info[$index] = (string) $build_info[$index];
---
>           $query = clone $build_info[$index];
>           $query->preExecute();
>           $build_info[$index] = (string)$query;

and the array_diff_assoc_recursive function, taken from the php docs and placed in my themes common_methods file, which isnt correct i know but at least is working for me at the moment.

function array_diff_assoc_recursive($array1, $array2)
{
    foreach($array1 as $key => $value)
    {
        if(is_array($value))
        {
              if(!isset($array2[$key]))
              {
                  $difference[$key] = $value;
              }
              elseif(!is_array($array2[$key]))
              {
                  $difference[$key] = $value;
              }
              else
              {
                  $new_diff = array_diff_assoc_recursive($value, $array2[$key]);
                  if($new_diff != FALSE)
                  {
                        $difference[$key] = $new_diff;
                  }
              }
          }
          elseif(!isset($array2[$key]) || $array2[$key] != $value)
          {
              $difference[$key] = $value;
          }
    }
    return !isset($difference) ? 0 : $difference;
}
pfrenssen’s picture

@deepbluesolutions: Tip: if you paste code you can use <?php ?> or <code> tags to preserve the formatting.

deepbluesolutions’s picture

thanks for the tip.

bendev’s picture

#12 worked for me as well. Thanks !
let us know if the is a better way.

mvc’s picture

i've submitted this as a bug against drupal core: #1850798: Add a recursive version of array_diff_assoc()

once patched for drupal 8, it can be backported to drupal 7, then used by views.

grahl’s picture

FileSize
1.61 KB

Attached is deepbluesolutions' patch in a more readily usable form.

I still see "Undefined index: data in views_plugin_cache->restore_headers()" though, so this might not be complete, at least it's now one error messages instead of several dozen (in my case).

myselfhimself’s picture

Hello I have applied the patch here and do get "Undefined index: data in views_plugin_cache->restore_headers()" in watchdog which originates from here :

  function restore_headers() {
    if (!empty($this->storage['head'])) {
      drupal_add_html_head($this->storage['head']);
    }
    if (!empty($this->storage['css'])) {
      foreach ($this->storage['css'] as $args) {
        drupal_add_css($args['data'], $args);
      }
    }
    if (!empty($this->storage['js'])) {
      foreach ($this->storage['js'] as $key => $args) {

        if ($key != 'settings') { //quickfix : && !empty($args['data'])
          drupal_add_js($args['data'], $args); // <== HERE
        }
        else {
          foreach ($args as $setting) {
            drupal_add_js($setting, 'setting');
          }
        }
      }
    }
  }

Is this coming from the new array_diff_assoc_recursive implementation or from other views code ?

Take care

Tharna’s picture

Here is a patch that applies to current stable version (3.5).

JamesOakley’s picture

Status: Active » Needs review

Status: Needs review » Needs work

The last submitted patch, 0001-Add-array_diff_assoc_recursive.patch, failed testing.

kclarkson’s picture

So will this patch remove the errors ?

@myselfhimself stated that he still received an error message after applying.

Thanks,
K

dawehner’s picture

+++ b/plugins/views_plugin_cache.incundefined
@@ -307,7 +307,25 @@ class views_plugin_cache extends views_plugin {
+function array_diff_assoc_recursive($array1, $array2) {

If we just need this method on that object you should probably put it as static method on that one.

Jorrit’s picture

I think the suggested array_diff_assoc_recursive() function is not working properly. When there is a NULL value in the array, it is interpreted as a difference because isset() returns false for NULL values.

I use this version and it works for me. Also, the function returns an empty array when there is no difference.

function array_diff_assoc_recursive($array1, $array2) {
  foreach ($array1 as $key => $value) {
    if (is_array($value)) {
      if (!isset($array2[$key])) {
        $difference[$key] = $value;
      } elseif (!is_array($array2[$key])) {
        $difference[$key] = $value;
      } else {
        $new_diff = array_diff_assoc_recursive($value, $array2[$key]);
        if (count($new_diff) > 0) {
          $difference[$key] = $new_diff;
        }
      }
    } elseif (!array_key_exists($key, $array2) || $array2[$key] != $value) {
      $difference[$key] = $value;
    }
  }
  return !isset($difference) ? array() : $difference;
}

Also, I think the function should not return the difference for sub-arrays, but complete subarrays, so it becomes:

function array_diff_assoc_recursive($array1, $array2) {
  foreach ($array1 as $key => $value) {
    if (is_array($value)) {
      if (!isset($array2[$key])) {
        $difference[$key] = $value;
      } elseif (!is_array($array2[$key])) {
        $difference[$key] = $value;
      } else {
        $new_diff = array_diff_assoc_recursive($value, $array2[$key]);
        if (count($new_diff) > 0) {
          $difference[$key] = $value;
        }
      }
    } elseif (!array_key_exists($key, $array2) || $array2[$key] != $value) {
      $difference[$key] = $value;
    }
  }
  return !isset($difference) ? array() : $difference;
}

But I haven't tested that.

damiankloip’s picture

Version: 7.x-3.x-dev » 8.x-3.x-dev
Status: Needs work » Postponed

We should fix this in 8.x first.

This issue is blocking it: #1850798: Add a recursive version of array_diff_assoc()

mike27’s picture

Subscribing for Drupal 7

damiankloip’s picture

There is a big green button at the top of the issue you can use :)

fledev.com’s picture

Had to work around a bit and used the following code (changes due missing $this->array_diff_assoc_recursive):

 /**
   * Gather out of band data, compare it to what we started with and store the difference.
   */
  function gather_headers() {
    // Simple replacement for head
    if (isset($this->storage['head'])) {
      $this->storage['head'] = str_replace($this->storage['head'], '', drupal_add_html_head());
    }
    else {
      $this->storage['head'] = '';
    }

    // Slightly less simple for CSS:
    $css = drupal_add_css();
    $css_start = isset($this->storage['css']) ? $this->storage['css'] : array();
    //$this->storage['css'] = array_diff_assoc($css, $css_start);
    $this->storage['css'] = $this->array_diff_assoc_recursive($css, $css_start);

    // Get javascript after/before views renders.
    $js = drupal_add_js();
    $js_start = isset($this->storage['js']) ? $this->storage['js'] : array();
    // If there are any differences between the old and the new javascript then
    // store them to be added later.
    // $this->storage['js'] = array_diff_assoc($js, $js_start);
    $this->storage['js'] = $this->array_diff_assoc_recursive($js, $js_start);
    
    // Special case the settings key and get the difference of the data.
    $settings = isset($js['settings']['data']) ? $js['settings']['data'] : array();
    $settings_start = isset($js_start['settings']['data']) ? $js_start['settings']['data'] : array();

    $settings = is_array($settings) ? $settings : array();
    $settings_start = is_array($settings_start) ? $settings_start : array();

    $this->storage['js'] = is_array($this->storage['js']) ? $this->storage['js'] : array();

    //$this->storage['js']['settings'] = array_diff_assoc($settings, $settings_start);
    $this->storage['js']['settings'] = $this->array_diff_assoc_recursive($settings, $settings_start);
    // Get difference of HTTP headers.
    $this->storage['headers'] = array_diff_assoc(drupal_get_http_header(), $this->storage['headers']);
  }

  
  /* complementary function due PHP 5.4 issue 1511396 */
  function array_diff_assoc_recursive($array1, $array2) {
    foreach ($array1 as $key => $value) {
      if (is_array($value)) {
        if (!isset($array2[$key])) {
          $difference[$key] = $value;
        } elseif (!is_array($array2[$key])) {
          $difference[$key] = $value;
        } else {
          $new_diff = $this->array_diff_assoc_recursive($value, $array2[$key]);
          if ($new_diff != FALSE) {
            $difference[$key] = $new_diff;
          }
        }
      } elseif (!isset($array2[$key]) || $array2[$key] != $value) {
        $difference[$key] = $value;
      }
    }
    return !isset($difference) ? 0 : $difference;
  }

Just replace the function with the upper two functions. Unfortunately the bug is not out even from the actual 7.3.dev version.

manicato’s picture

Version: 8.x-3.x-dev » 7.x-3.x-dev

I tried #28, but now I get this errors:
Warning: Invalid argument supplied for foreach() in drupal_array_merge_deep_array() (line 2064 of /htdocs/includes/bootstrap.inc).
Notice: Undefined index: data in views_plugin_cache->restore_headers() (line 268 of /htdocs/sites/all/modules/views/plugins/views_plugin_cache.inc).

Has anybody an Idea why this drupal_array_merge_deep_array is coming up?

pfrenssen’s picture

Version: 7.x-3.x-dev » 8.x-3.x-dev

#1850798: Add a recursive version of array_diff_assoc() is now RTBC, I would encourage to wait until that patch lands instead of posting new patches. The code in that issue has been reviewed by multiple people and conforms to Drupal standards.

Setting this back to 8.x, needs to be fixed first in that version.

SebaSOFT’s picture

Version: 8.x-3.x-dev » 7.x-3.x-dev

This is TRUE for D7

damiankloip’s picture

Version: 7.x-3.x-dev » 8.x-3.x-dev

Setting this back to 8.x, needs to be fixed first in that version.

Did you read that part? :) I guess not. We make changes to 8.x THEN backport.

pmol123’s picture

Version: 8.x-3.x-dev » 7.x-3.6
Priority: Normal » Major

I was asked if this was still happening after upgrading to 3.6.

Yes, since,this error is from a few minutes ago.

Notice: Array to string conversion in views_plugin_cache->gather_headers() (line 206 of /var/www/drupal/sites/all/modules/views/plugins/views_plugin_cache.inc). Backtrace:
array_diff_assoc(Array, Array) views_plugin_cache.inc:206
views_plugin_cache->gather_headers() views_plugin_cache.inc:100
views_plugin_cache->cache_set('output') view.inc:1266
view->render() views_plugin_display.inc:2677
views_plugin_display->preview() view.inc:1368
view->preview() views-view--category-listing--p-category-search.tpl.php:80
include('/var/www/drupal/sites/expert/ew_prod/themes/views/category-listing/p-category-search/views-view--category-listing--p-category-search.tpl.php') theme.inc:1495
theme_render_template('sites/expert/expertwitness.com/themes/at_biz/templates/views/category-listing/p-category-search/views-view--category-listing--p-category-search.tpl.php', Array) theme.inc:1185
theme(Array, Array) views_plugin_display.inc:2605
views_plugin_display->render() view.inc:1264
view->render() views_plugin_display_page.inc:229
views_plugin_display_page->execute() view.inc:1345
view->execute_display('p_category_search', Array) views.module:528
views_page('category_listing', 'p_category_search', 'B', 'Business') 
call_user_func_array('views_page', Array) menu.inc:517
menu_execute_active_handler() index.php:27
dawehner’s picture

The issue summary could indeed describe how to reproduce the issue.

I'm open to fix it either in 7.x-3.x or 8.x, as you know it's better fixed then lying around in the core queue for months.

pmol123’s picture

I understand they prefer to backport, however, there are far more production installs/sites on and running D7 as compared to that D8. If the ramp up for D8 is anything like D7 it will take another year before D8 is anything close to where D7 is today. I would think the fix is likely to be somewhat similar for both versions.

I would appreciate if it was fixed in D7 for PHP 5.4.12 and PHP 5.5 as I already upgraded my database to MySQL 5.6.10 and cannot not go backwards.

Thank you.

dawehner’s picture

Discussing whether to backport or forward port are pointless, as there are always arguments for both sides.
The patch is fixed in 8.x, so please help on backport #1850798: Add a recursive version of array_diff_assoc() wait for a core release and then we can fix it in views.

pmol123’s picture

I applied the core patch

FROM items #50 and #12 on
http://drupal.org/node/1525176

as instructed on :

Posted by drupalion on April 8, 2013 at 4:36am
Thanks. #12 1525176-fix_entity_conditions-D7-do-not-test.patch works on drupal 7.22

For:

Using array_diff_assoc() for multilevel arrays in DrupalDefaultEntityController->cacheGet()

I now get =>

 778229  09/Apr 10:05  notice  php  Notice: Array to string conversion in views_plugin_cache->gather_headers() (line 218 of /var/www/drupal/sites/all/modules/views/plugins/views_plugin_cache.inc). Backtrace:array_diff_assoc(Array, Array) views_plugin_cache.inc:218
views_plugin_cache->gather_headers() views_plugin_cache.inc:100
views_plugin_cache->cache_set('output') view.inc:1266
view->render() views_plugin_display.inc:2677
views_plugin_display->preview() view.inc:1368
view->preview() views-view--category-listing--p-category-search.tpl.php:80
include('/var/www/drupal/sites/expert/ew_prod/themes/subbs/templates/category-listing/p-category-search/views-view--category-listing--p-category-search.tpl.php') theme.inc:1505
theme_render_template('sites/expert/expertwitness.com/themes/subbs/templates/category-listing/p-category-search/views-view--category-listing--p-category-search.tpl.php', Array) theme.inc:1189
theme(Array, Array) views_plugin_display.inc:2605
views_plugin_display->render() view.inc:1264
view->render() views_plugin_display_page.inc:229
views_plugin_display_page->execute() view.inc:1345
view->execute_display('p_category_search', Array) views.module:528
views_page('category_listing', 'p_category_search', 'B', 'Business') 
call_user_func_array('views_page', Array) menu.inc:517
menu_execute_active_handler() index.php:27

Does this Patch vix the Views portion ?

Patrick

pmol123’s picture

Status: Postponed » Active

When you point me at this patch, I am not sure which I should be grabbing or messing around with.

You can see the page that is having this error at
http://www.expertwitness.com/categories/B/Business

Patrick

pmol123’s picture

Version: 7.x-3.6 » 7.x-3.7

Just for grins I upgraded to Views 3.7, the problem/issue also in views v3.7.
( no surprised as the release notes did not make mention of this issue)

Patrick

damiankloip’s picture

Version: 7.x-3.7 » 7.x-3.x-dev
Status: Active » Postponed

See #36, Isn't this postponed on that? Once that patch is ported, this can be fixed.

pmol123’s picture

Title: php 5.4 and "Notice: Array to string conversion" » php 5.4 and "Notice: Array to string conversion" - POSSIBLE FIX
Version: 7.x-3.x-dev » 7.x-3.7
Priority: Major » Critical
Status: Postponed » Active

OK, I wrote a two-array version of the PHP function "array_diff_assoc". I prefixed it with my initials "pmol_" as shown in the code section below.
(Humbly, I have to admit that I am not the programmer that many of you are. please entend me some grace)

I added this function to the top of "views_plugin_cache.inc" and the called it from the problem areas.

This code I implemented seems to be working on my production http://www.ExpertWitness.com site/server.

If the code is acceptable, perhaps someone could help me get this solution (directly or indirectly) into the distribution.

(No pride here, just wanting a solution, not tied to the code or coding standards.)

Patrick

//****************************************************************
//****************************************************************

function pmol_array_diff_assoc( $needle, $haystack )
{
    $tmp_needle = $needle;

    foreach( $tmp_needle as $tmp_needle_key => $tmp_needle_value )
      {
        foreach( $haystack as $haystack_key => $haystack_value )
          {
             if( $tmp_needle_key == $haystack_key )
                if( $tmp_needle_value == $haystack_value )
                    unset( $tmp_needle[ $tmp_needle_key ]  );

          }
      }

    return( $tmp_needle );
}

//****************************************************************
//****************************************************************
pmol123’s picture

Yes, it is, but it is blowing up constantly every time a view (with parameters) is accessed for the first time and this bringing my load levels way up on my server.
(If I restart Varnish, clear the cache or if the cache expires, I get a new create / first-time event which causes a blow up)

Patrick

geerlingguy’s picture

Version: 7.x-3.7 » 7.x-3.x-dev
Status: Active » Postponed

@pmol123 - please leave this issue postponed (and for 3.x-dev) until #1850798: Add a recursive version of array_diff_assoc() is fixed and backported to Drupal 7. Until then, this issue will not be dealt with by the Views maintainers.

To prevent the 'blowing up' from occurring on your site, just leave your patched code in Views until this issue is marked as fixed :)

damiankloip’s picture

Yep, any temporary fixes will not be committed :)

Also, your function is not recursive, I think it needs to be. See the dependent issue. Can't you just use @array_diff_assoc() for now anyway?

pmol123’s picture

OK, that works for me, thank you.

Patrick

damiankloip’s picture

Title: php 5.4 and "Notice: Array to string conversion" - POSSIBLE FIX » php 5.4 and "Notice: Array to string conversion"
pmol123’s picture

OK, its been a few days since I put in my patch that I have above (#41).

After a day, I turned the views query cache on for various views that are executed frequently.

Its now been a fews days since that change, my load levels on the server have been cut in half.

Patrick

tom friedhof’s picture

Posting this patch up here for anyone looking for a temporary solution. You must also apply a core patch here: http://drupal.org/node/1850798#comment-7146506 otherwise you'll like white screen with a php error.

geerlingguy’s picture

FYI, #1850798: Add a recursive version of array_diff_assoc() is currently at needs review - if someone could take a look at it and get it to RTBC, that would unblock this issue and make PHP 5.4 users everywhere happier :)

aidanlis’s picture

Here's the patch in #48 but with the correct function name for the patch in #49.

dawehner’s picture

Status: Postponed » Needs review

Status: Needs review » Needs work

The last submitted patch, 1511396-views-array_diff_assoc-48.patch, failed testing.

pmol123’s picture

Seems to be all good here.

NOTE: You need to have the "drupal_array_diff_assoc_recursive" function in your drupal core first though.

So, I applied the patch #68 at issue

http://drupal.org/node/1850798

to get the "drupal_array_diff_assoc_recursive" in place on my production drupal.

THEN, I applied the patch at #50, #52 above on THIS ISSUE.

Again, all seems good here (since this morning) on

==> http://www.ExpertWitness.com

Patrick

JamesOakley’s picture

Status: Needs work » Postponed

This is not to put down the good work that's been done working on a patch and testing it. But,... marking as postponed again. (See #49).

#1850798: Add a recursive version of array_diff_assoc() is now RTBC, but it's not yet committed to core. That means that the patch there could yet change, so we can't be sure if we're making the correct assumptions about core while we're patching Views. It also means that any automated tests on patches here will fail, because the patches here will use features in core that don't yet exist.

By all means keep working on and testing a patch for this issue. That will speed up getting this issue fixed once #1850798: Add a recursive version of array_diff_assoc() is committed.

bendev’s picture

I could solve the "Notice: Array to string conversion" with the
"drupal_array_diff_assoc_recursive"

Now I also get the :

"Notice : Undefined index: data dans views_plugin_cache->restore_headers() (ligne 233 dans /var/www/mysite/sites/all/modules/views/plugins/views_plugin_cache.inc)."

like mentioned in #17 and #18. Should we open another issue for this one ?

Volx’s picture

I think in this case simply replacing array_diff_assoc with a recursive version is not the complete answer. Currently with array_diff_assoc Views only compares the first level, so it essentially compares the array keys and adds any new item into the storage, since array_diff_assoc returns the full nested array. That might be the correct behavior, but it does not take into account changes in existing items, which might be desired, which would mean that the current caching is broken in some cases.
Now with drupal_array_diff_assoc_recursive all nested arrays are compared as well, but that also means that only the differences in the nested arrays are returned, not the full value on the first level, so the cache does not contain the full js or css items anymore and the subsequent call to drupal_add_css/js in restore_headers fails.
So there are two possible solution I can think of, one would replicate the current behavior and only compare array keys on the first level, the other would do a full recursive array diff and add the full item whenever there is a difference. What the correct solution is depends on what was originally intended, I leave that decision to someone with more in depth knowledge of Views :)

Edit: The first patch does not depend on #1850798: Add a recursive version of array_diff_assoc() anymore, so if that is the right way to go, we could go ahead and fix this issue now.

colan’s picture

Status: Postponed » Needs review

Fixing status as per #56:

The first patch does not depend on #1850798: Add a recursive version of array_diff_assoc() anymore, so if that is the right way to go, we could go ahead and fix this issue now.

Status: Needs review » Needs work

The last submitted patch, views-recursive_diff-1511396-56.patch, failed testing.

gali11’s picture

Is there a solution to the problem of message "Notice: Array to string conversion in views_plugin_cache->gather_headers", because it is already common in Drupal sites. When I looked for a decision, appeared a lot of sites with this message, which means that Google has indexed them so that's not good.

JamesOakley’s picture

@gali11 - that is what this issue is all about. It's an incompatibility between Views and PHP 5.4.

If Google has indexed the errors, it means that people have been running production sites with Home > Administration > Configuration > Development > Logging and Errors not set to "none"

mvc’s picture

fwiw #1850798: Add a recursive version of array_diff_assoc() has now been committed to 7.x core, so no reason to wait before implementing either of the approaches in #56

dgtlmoon’s picture

Status: Needs work » Needs review

I applied the second patch from #56 after checking #1850798: Add a recursive version of array_diff_assoc() is in my codebase, things seem to work ok for me ( PHP Version => 5.4.16-1~dotdeb.1 ) no errors/warnings in the watchdog and my views appearing to be functioning OK, is there any more specific detail on why that patch failed? i guess because #1850798 is not in the codebase that it was tested against?

JamesOakley’s picture

JamesOakley’s picture

So both patches in #56 passed tests now that #1850798: Add a recursive version of array_diff_assoc() is in core.

As for which patch is needed, I got slightly lost following the argument in #56. But it seems to me that this issue should only be about resolving the PHP 5.4 incompatibility, and not about trying to improve the way that Views handles cache checking. Any improvements should go into their own issue - so that this one isn't complicated by functionality changes and can be committed as soon as possible.

dgtlmoon’s picture

@JamesOakley pretty sure that's all the second patch in #56 does, handle the structure with the recursive diff instead

Phizes’s picture

From #1

The proper way to fix that would be to write a recursive version of array_diff_assoc

So I think the second patch in #56 would be correct.

The second patch in #56 works for me, naturally with the patch from #1850798: Add a recursive version of array_diff_assoc() applied as well.

Anthony Fok’s picture

mstef’s picture

#56 works but gives me: Warning: Invalid argument supplied for foreach() in views_plugin_cache->gather_headers() (line 224 of /var/www/sites/all/modules/contrib/views/plugins/views_plugin_cache.inc).

JamesOakley’s picture

@mstef - then #56 doesn't work for you - that is the error this issue is trying to fix.

There are two patches in #56, taking different approaches. Which one did you apply?

mstef’s picture

Forgot there were 2 patches: I used views-recursive_diff-1511396-56.patch.

I meant worked as in regarding the issue this thread was originally started for.

mstef’s picture

Status: Needs review » Needs work

Alright, looks like I was completely wrong. The patch from #56 (views-recursive_diff-1511396-56.patch) does cause more problems than just that error. Check out this issue that I mistakenly opened for another Views module - #2052015: Slideshow isn't present if View is cached. This patch breaks the View if the output is cached (none of the JS is added so the slideshow doesn't work at all).

Phizes’s picture

mstef: Could you please provide steps to reproduce? Additionally, what versions of views etc are you using?

mstef’s picture

I'm using 3.7 (not dev). I can re-test this with dev (I actually thought I was using dev)..

Simply install views_slideshow and bxslider_views_slideshow and set up a View using it. Turn on caching (whichever plugin you want) for both the query and results. And that should do it.

I'm not sure exactly what's going wrong here or who is to blame -- I'm just reporting what I'm getting. I unfortunately don't have time to help out debugging this one.

maximpodorov’s picture

Drupal includes drupal_array_diff_assoc_recursive() in 7.23, so it's time to commit the fix in Views and create a release.

pfrenssen’s picture

Priority: Critical » Normal

This is not a critical issue. Critical issues are reserved for really bad problems, such as functionality that is totally broken, or data loss. This is just a notice.

As maximpodorov mentioned, #1850798: Add a recursive version of array_diff_assoc() has been released in Drupal Core, so this can now be picked up. Mind that this issue will increase the minimum required version of Core to 7.23.

pfrenssen’s picture

Status: Needs work » Needs review
FileSize
1.99 KB

Something like this :) Does this need a test?

mstef’s picture

Getting this with patch #76, 3.x-dev, and D7.23: Notice: Undefined index: data in views_plugin_cache->restore_headers() (line 239 of /var/www/sites/all/modules/contrib/views/plugins/views_plugin_cache.inc).

pjcdawkins’s picture

I confirm the patch in #76 nearly works - I have the same error mentioned in #77.

pjcdawkins’s picture

And with the patch in #76 I sometimes get:

Notice: Array to string conversion in views_arg_load() (line 475 of sites/all/modules/views/views.module)

svefre’s picture

#76 works fine for me :)

Elin Yordanov’s picture

After applying the patch #76 the notices are disappeared.

JamesOakley’s picture

Status: Needs review » Reviewed & tested by the community

So: RTBC?

Are the messages in #77 and #79 a different issue?

pjcdawkins’s picture

Status: Reviewed & tested by the community » Needs work

The patch in #76 needs work; after applying it you still get the errors in #77 and #79, which seem like they are very similar problems to the OP.

Elin Yordanov’s picture

I'm not sure that the notices in #77 and #79 are relevant to this issue or patch. I have applied the patch #76 on 2 different systems and sites, ant the previous notices are disappeared. This issue is about the following notices, which the patch in #76 solves them:

Notice: Array to string conversion in views_plugin_cache->gather_headers() (line 216 of /***/views/plugins/views_plugin_cache.inc).

I'd suggest to open another issue for the other notices, to get this patch committed, since it solves the original problem.

JamesOakley’s picture

@pc-wurm I'd be inclined to agree.

It all depends on whether the other notices people are getting are a direct cause of applying this patch, or whether those notices were there anyway. If they were there anyway, let's not try to solve two problems in one issue. If they are caused by this patch, then resolving them belongs here, because we cannot "solve" one problem by creating another.

havran’s picture

FileSize
105.34 KB

I have same problem as #77. Here is screenshot from function gather_headers() - part which cause problem in function restore_headers().

    // at the end of function gather_headers()
    dpm($js, 'raw js');
    dpm($this->storage, 'storage');
joachim’s picture

I'm seeing the warning here too:

Notice: Array to string conversion in views_handler_filter->admin_summary

Though it might be simpler to fix these in separate issues?

Yazzbe’s picture

#76 works for me. no error notices (drupal 7.23 & views 3.7).

ParisLiakos’s picture

Status: Needs work » Reviewed & tested by the community

#76 fixes OP (and to be honest thats the only place i see this notice)
so lets open new issues for other locations that need updating. or what #84 said

ParisLiakos’s picture

bendev’s picture

#76 works for me

pipep’s picture

just updated got the same Notice: Array to string conversion en views_plugin_cache->gather_headers() (line 206 /D723/sites/all/modules/views/plugins/views_plugin_cache.inc).

sibiru’s picture

Status: Reviewed & tested by the community » Needs work

Im on PHP 5.4 and using #76 patch but still not fix

"Array to string conversion in views_plugin_cache->gather_headers() (line 218"

das-peter’s picture

Status: Needs work » Reviewed & tested by the community

@sibiru Please ensure that you've patched the code properly (search for array_diff_assoc( in your views code - this shouldn't be found) and that you've refreshed the page multiple times. Sometimes error messages get "stuck" and are displayed on the following request.
It would be very strange if you're the only left that experiences this issue after we've got that many positive feedbacks. Further line 218 is definitely one of the patched lines ($this->storage['js']['settings']).

I'm bold enough to set this back to RTBC as I really can't imagine that we've missed something.

CSoft’s picture

#76 works for me, thanks! :)

markbannister’s picture

#76 Not working for me. Updated to 7.x-3.7+10-dev
Patch seems to already be applied.

Notice: Array to string conversion in panels_cache_object->cache() (line 183 of ../profiles/commons/modules/contrib/panels/includes/plugins.inc).

sibiru’s picture

Status: Reviewed & tested by the community » Needs work

I still have the same problem too even I upgrade Views to 7.x-3.7+10-dev

I hide the php error message but it is not convenient for logging

ParisLiakos’s picture

Status: Needs work » Reviewed & tested by the community

@#96 this is clearly a message from panels module, not views

@#97 upgrading to latest dev is not enough, the patch is not yet committed. apply #76 and then check

Devin Carlson’s picture

@sibiru, you need to apply the patch in #76 to a git checkout of Views 7.x-3.x.

steinmb’s picture

PHP 5.4.16 (cli) (built: Jul 3 2013 03:20:43)
Drupal version: 7.23
Server version: 5.5.31-MariaDB

git apply --index views-1511396-76-array_diff_recursive.patch -v
Checking patch plugins/views_plugin_cache.inc...
Checking patch views.info...
Applied patch plugins/views_plugin_cache.inc cleanly.
Applied patch views.info cleanly.

Tested and remove all the array to strings warnings I was getting, about 60 on a page created by page manger gathering different views.

Notice: Array to string conversion in views_plugin_cache->gather_headers() (line 206 of /drupal/sites/all/modules/views/plugins/views_plugin_cache.inc).
Notice: Array to string conversion in views_plugin_cache->gather_headers() (line 213 of /drupal/sites/all/modules/views/plugins/views_plugin_cache.inc).
Notice: Array to string conversion in views_plugin_cache->gather_headers() (line 218 of /drupal/sites/all/modules/views/plugins/views_plugin_cache.inc).
......

RTBC from me.

das-peter’s picture

Status: Reviewed & tested by the community » Needs review
FileSize
1.97 KB

As discussed with Daniel, here's an even more unobtrusive approach that doesn't force to upgrade core.
If you experience the errors you've to upgrade core, otherwise everything works as before.
Maybe we could add a hook_requirements() to check proactive.

JamesOakley’s picture

I've not tested it. But that's a good idea - why should we introduce a core minor-version compatibility issue when this problem with Views only affects people who use PHP 5.4?

dawehner’s picture

@JamesOakley
It would be cool if you find some time to test it, so I can be sure when I commit it.

JamesOakley’s picture

I would love to - but I'm running PHP 5.4 and Views, and I don't have this problem. I can't remember whether I did something to mitigate or whether my site has never tripped the error. In short - if I could reproduce it I'd gladly test it!

pjcdawkins’s picture

#101 works for me. I still have very similar errors but those come from Panels.

pjcdawkins’s picture

Status: Needs review » Needs work
  1. +++ b/plugins/views_plugin_cache.inc
    @@ -200,25 +200,28 @@ class views_plugin_cache extends views_plugin {
    +    $array_mapping_func = (function_exists('drupal_array_diff_assoc_recursive')) ? 'drupal_array_diff_assoc_recursive' : 'array_diff_assoc';
    

    The brackets around function_exists() are redundant.

  2. +++ b/plugins/views_plugin_cache.inc
    @@ -200,25 +200,28 @@ class views_plugin_cache extends views_plugin {
    +    $this->storage['css'] = call_user_func_array($array_mapping_func, array($css, $css_start));
    

    This should be just $array_mapping_func($param, $param2) instead of call_user_func_array().

edvanleeuwen’s picture

Tested it.
Error which occurred afterwards which was described by #77 has been solved by https://drupal.org/node/2083151#comment-7905923

das-peter’s picture

Status: Needs work » Needs review
FileSize
1.86 KB

Next patch.

Status: Needs review » Needs work

The last submitted patch, views-1511396-108-array_diff_recursive.patch, failed testing.

das-peter’s picture

Status: Needs work » Needs review
FileSize
1.86 KB

Darn! Missed a parenthesis...

ssoulless’s picture

Hi i have the 7.x-3.7 version of views, i have the same problem:

Notice: Array to string conversion en views_plugin_cache->gather_headers() (línea 206 de /home/vhosts/www.ribsinternational.com/sites/all/modules/views/plugins/views_plugin_c...).

Notice: Array to string conversion en views_plugin_cache->gather_headers() (línea 213 de /home/vhosts/www.ribsinternational.com/sites/all/modules/views/plugins/views_plugin_c...).

Notice: Array to string conversion en views_plugin_cache->gather_headers() (línea 218 de /home/vhosts/www.ribsinternational.com/sites/all/modules/views/plugins/views_plugin_c...).

It just appear once i open the page the first time, when i reaload it desappears, this very weard....

the #110 works just for the Views - 7.x-3.x? or can i apply it to the 7.x-3.7 version?

ssoulless’s picture

Status: Needs review » Needs work

I applied patch #110 and it does not work for me...

das-peter’s picture

@ssoulless And you really updated core to at least 7.23?

pjcdawkins’s picture

Patch #110 looks good.

I vote RTBC although #112/#113 needs to be resolved first.

ssoulless’s picture

Status: Needs work » Reviewed & tested by the community

Yes srry, i just updated the core of drupal to 7.23 and know it works, think now it is working well, the notices disapeared.

marvil07’s picture

kenorb’s picture

Tested as well #110, seems to work.

k.skarlatos’s picture

Status: Reviewed & tested by the community » Needs work

I still get restore_headers() notices...

PHP 5.4.20 (cli) (built: Sep 18 2013 19:55:33)
MariaDB Server 5.5.33a-MariaDB-log
Drupal 7.23
Views latest 7.x.3.x-dev from git

Notice: Undefined index: data in views_plugin_cache->restore_headers() (line 242 of /var/www/clients/client1/web2/web/sites/all/modules/views/plugins/views_plugin_cache.inc).
|Notice: Undefined index: data in views_plugin_cache->restore_headers() (line 236 of /var/www/clients/client1/web2/web/sites/all/modules/views/plugins/views_plugin_cache.inc).

JamesOakley’s picture

@k.skarlatos - You say you used views latest 7.x-3.x-dev from git.

Which patch in this issue did you apply that meant you saw the errors you reported?

Also, the error in this issue is Notice: Array to string conversion in views_plugin_cache->gather_headers() (line 216 of /***/views/plugins/views_plugin_cache.inc). Your error looks different to me - are you sure that the patch you've applied hasn't fixed this issue (even if there are others)?

ssoulless’s picture

Status: Needs work » Fixed

Thats a different issue k.skarlatos, open another issue fot it. Think it is done... it works for all my sites normally.

JamesOakley’s picture

Status: Fixed » Reviewed & tested by the community

"Fixed" is slightly over-ambitious, ssoulless - k.skalatos changed the status from RTBC.

I'd want to see a patch committed before this is marked as fixed. ;-)

k.skarlatos’s picture

Hi all,
The patch i used was #110. It fixed the gather_headers issue, but it didn't fix the restore_headers one. I saw restore_headers mentioned on many comments here, so i thought the issue wasn't limited to the gather_headers notice... Nevermind, i will open a new issue when i get back home

dawehner’s picture

Status: Reviewed & tested by the community » Fixed

Committed and pushed to 7.x-3.x

ssoulless’s picture

Status: Fixed » Closed (fixed)
JamesOakley’s picture

Status: Closed (fixed) » Fixed

@ssoulless - this should be left on "fixed" until 2 weeks has elapsed, at which point the issue is automatically set to closed. This helps people (who may only search on open issues) find the issue for a short period after the fix has been applied, before it is formally closed.

Laz5530’s picture

I had this problem too, but in profiles/commons/modules/contrib/panels/includes/plugin.inc.

Notice: Array to string conversion in panels_cache_object->cache() (line 178 of MYROOT/profiles/commons/modules/contrib/panels/includes/plugins.inc)

If somebody has the same error:
I fixed it using the patch #110 as example and edited plugin.inc like this(around line 180):

...
    $start = $this->js;
    $this->js = array();

    // Check if the advanced mapping function of D 7.23 is available.
    $array_mapping_func = function_exists('drupal_array_diff_assoc_recursive') ? 'drupal_array_diff_assoc_recursive' : 'array_diff_assoc';
    
    // If there are any differences between the old and the new javascript then
    // store them to be added later.
    #if ($diff = array_diff_assoc($js, $start)) {
    if ($diff = $array_mapping_func($js, $start)) {
      $this->js = $diff;
    }


    // Special case the settings key and get the difference of the data.
    #if ($settings_diff = array_diff_assoc($js['settings']['data'], $start['settings']['data'])) {
    if ($settings_diff = $array_mapping_func($js['settings']['data'], $start['settings']['data'])) {
      $this->js['settings'] = $settings_diff;
    }

    // And for tokens:
    $tokens = ctools_set_page_token();
    foreach ($this->tokens as $token => $argument) {
    ...
pjcdawkins’s picture

csotlac: that's an issue with Panels not Views. The relevant thread is #1762290: PHP 5.4 Issue with array_diff_assoc in plugins.inc

joshuautley’s picture

Patch #110 worked for me as well.

lmeurs’s picture

Patch from #110 works for me too, thanks a lot!

cedewey’s picture

FWIW, the patch in #110 did not work for me. Also, I tried clearing cache via drush and the UI.

MrHaroldA’s picture

@cedewey And you really updated core to at least 7.23?

If so, please copy/paste the exact message.

Elin Yordanov’s picture

@cedewey Are you sure you have also updated Drupal Core to 7.23? This patch only works with Drupal Version 7.23 (or greater).

cedewey’s picture

@MrHaroldA and @pc-wurm, My apologies. Drupal Core was not at 7.23. Patch works like a charm.

lauriii’s picture

#110 fixed the problem for me

pjcdawkins’s picture

Issue summary: View changes

This issue is fixed, i.e. the patch in #110 has already been committed to Views 7.x-3.x-dev (on 10/10/2013). There is no need to provide further reviews.

CyberSkull’s picture

Running Drupal 7.23 with PHP 5.4 FastCGI and I'm getting this error with Views caching enabled.

lauriii’s picture

What version did you use?

CyberSkull’s picture

Oh, sorry, Views 7.x-3.7.

JamesOakley’s picture

You need 7.x-3.x-dev, because this fix was committed after 7.x-3.7 was generated. It will be included whenever 7.x-3.8 is released.

Status: Fixed » Closed (fixed)

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

FiNeX’s picture

hi, I've updated to -dev version (and cleared the cache) but I'm still experiencing this error.

JamesOakley’s picture

What Drupal core do you have? Could you paste the exact errors you're getting?

FiNeX’s picture

I'm using 7.22 (I will upgrade to the latest stable release on the next weeks). The error is:

Notice: Array to string conversion in views_plugin_cache->gather_headers() (line 221 of /var/www/vhosts/domain.name/sites/all/modules/contrib/views/plugins/views_plugin_cache.inc).
JamesOakley’s picture

I'm using 7.22

Then there's your problem. The fix for this issue in Views only solves the problem when Drupal core includes the fix in the core issue #1850798: Add a recursive version of array_diff_assoc()

That fix first appeared in Drupal 7.23. So unless you're using 7.23 or newer, the fix in Views (which you've got by using the --dev release of Views) won't solve the problem.

FiNeX’s picture

Thanks JamesOakley, I'll upgrade the website soon!

selpe’s picture

Status: Closed (fixed) » Needs review

Status: Needs review » Needs work

The last submitted patch, 110: views-1511396-110-array_diff_recursive.patch, failed testing.

Elin Yordanov’s picture

Status: Needs work » Closed (fixed)

This patch is already committed to the dev version and the issue is fixed.

stormpat’s picture

Same problem, PHP 5.5.3, Drupal 7.26, Views 7.x-3.7

Elin Yordanov’s picture

@stormpat
The fix for this is included in dev-Version of Views. You need either to install the latest dev-Version, or apply the patch at #110 manually.

imoreno’s picture

#110 worked for me, messages are gone.

cameron prince’s picture

Updated core and all modules to current release version and applied patch from #110. Errors are now gone. Thanks.

sagitta’s picture

at the views advance setting page set Caching: to none, the errors disappear, hope the latest update will fix the problem.

pcdesign’s picture

#110 works well for me, IF you also apply the patch here: https://drupal.org/node/2018737#comment-8522075

Solving the problem with patch #110 results in another error, that is resolved in there latest patch.

Regards,
Peter

podarok’s picture

#110 works for me too
Working on php 5.5

cmedina’s picture

#110 and then #21 from https://drupal.org/node/2018737 , works for me too.

thanks.

mamanerd’s picture

#110 and then #21 from https://drupal.org/node/2018737 worked for me as well.

philsward’s picture

Issue has was addressed in the dev version back in Nov 2013. Try the latest dev before applying any patches. Latest dev cleared up the problem for me.

TechNikh’s picture

Updating to Views version 7.x-3.8 fixed it for me.

Drupaltarzen’s picture

I got this, yesterday ,
Notice: Array to string conversion in panels_cache_object->cache() (line 178 of C:\xampp\htdocs\drupal\sites\all\modules\panels\includes\plugins.inc).

what to do ? :/

FMB’s picture

Drupaltarzen: looks more like a Panels issue to me.

JamesOakley’s picture

@Drupaltarzen - as long as you're using at least Drupal 7.23, and at least Views 7.x-3.8, this issue has been fixed, so whatever you're experiencing won't be caused by this issue.

(If you're not using up to date versions of Drupal core, Views and Panels, then your next step should be to upgrade core and all contributed modules and try again)

Drupaltarzen’s picture

Thanks for your reply @FMB & @JamesOakley

I updated the updates , on updating the core i get
"The file drupal-7.36.tar.gz could not be saved, because it exceeds 2 MB, the maximum allowed size for uploads"

While on updates i get..following..

The following updates returned messages

panels module

Update #7302
Failed: PDOException: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'drupal.cache_panels' doesn't exist: DELETE FROM {cache_panels} WHERE (cid LIKE :db_condition_placeholder_0 ESCAPE '\\') ; Array ( [:db_condition_placeholder_0] => panels\_simple\_cache:6% ) in cache_clear_all() (line 167 of C:\xampp\htdocs\drupal\includes\cache.inc).

Drupaltarzen’s picture

I restarted the server and tried again after the updates , it got fixed ! Thanks have a great day :-)