Download & Extend

php 5.4 and "Notice: Array to string conversion"

Project:Views
Version:7.x-3.x-dev
Component:Code
Category:bug report
Priority:critical
Assigned:Unassigned
Status:postponed
Issue tags:PHP 5.4

Issue Summary

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

Comments

#1

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

#2

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.

#3

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.

#4

I confirm the problem and add the tag

#5

same problem:( WAMP server!

#6

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?

#8

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

#9

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.

<?php
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;
}
?>

#10

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)

#11

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

I am also seeing this problem with the dev version

#12

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;
}

#13

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

#14

thanks for the tip.

#15

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

#16

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.

#17

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).

AttachmentSizeStatusTest resultOperations
1511396-12.patch1.61 KBIdleFAILED: [[SimpleTest]]: [MySQL] Unable to apply patch 1511396-12.patch. Unable to apply patch. See the log in the details link for more information.View details | Re-test

#18

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 :

<?php
 
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

#19

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

AttachmentSizeStatusTest resultOperations
0001-Add-array_diff_assoc_recursive.patch2.11 KBIdleFAILED: [[SimpleTest]]: [MySQL] 1,603 pass(es), 0 fail(s), and 5 exception(s).View details | Re-test

#20

Status:active» needs review

#21

Status:needs review» needs work

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

#22

So will this patch remove the errors ?

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

Thanks,
K

#23

+++ 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.

#24

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.

#25

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()

#26

Subscribing for Drupal 7

#27

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

#28

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.

#29

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?

#30

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.

#31

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

This is TRUE for D7

#32

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.

#33

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

#34

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.

#35

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.

#36

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.

#37

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

#38

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

#39

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

#40

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.

#41

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 );
}

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

#42

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

#43

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 :)

#44

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?

#45

OK, that works for me, thank you.

Patrick

#46

Title:php 5.4 and "Notice: Array to string conversion" - POSSIBLE FIX» php 5.4 and "Notice: Array to string conversion"

#47

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

#48

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.

AttachmentSizeStatusTest resultOperations
1511396-views-array_diff_assoc-48.patch1.63 KBIdleFAILED: [[SimpleTest]]: [MySQL] 1,615 pass(es), 1 fail(s), and 0 exception(s).View details | Re-test

#49

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 :)

#50

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

AttachmentSizeStatusTest resultOperations
1511396-views-array_diff_assoc-50.patch.txt1.66 KBIgnored: Check issue status.NoneNone

#51

Status:postponed» needs review

#52

Status:needs review» needs work

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

#53

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

#54

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.

#55

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 ?

nobody click here