I think PHP 5.4 now throws warnings/noticed when arrays are unexpectedly converted to strings. Looks like we have a few tests which are broken...

I haven't checked all of them, but this is the list that failed with exceptions when running tests with my patch from #1187726: Add caching for configuration / rework config object loading (Was: Memory usage and i/o from config objects) locally. Tried config import and contact tests and both were because of this. Others, especially those with fails too might be related to the other issue but need to be checked.

Import configuration 38 passes, 0 fails, and 20 exceptions
Import UI 45 passes, 1 fail, and 12 exceptions
Site-wide contact form 240 passes, 4 fails, and 7 exceptions
Entity Test Translation UI 68 passes, 0 fails, and 22 exceptions
Module dependencies 137 passes, 26 fails, and 2 exceptions
Node translation UI 106 passes, 0 fails, and 18 exceptions
Enable/disable modules 1149 passes, 620 fails, and 60 exceptions
Taxonomy term translation UI 99 passes, 0 fails, and 22 exceptions
Tracker 228 passes, 0 fails, and 2 exceptions
Field: Base 206 passes, 0 fails, and 1 exception
Cache 12 passes, 0 fails, and 18 exceptions
Handler test 110 passes, 0 fails, and 28 exceptions
Row: UI 28 passes, 2 fails, and 1 exception
Style: UI 28 passes, 2 fails, and 1 exception
Tag 23 passes, 0 fails, and 8 exceptions

the category tests are obvious:

watchdog('contact', 'Category %label has been updated.', array('%label' => $category->label()), WATCHDOG_NOTICE, l(t('Edit'), $category->uri() . '/edit'));

$category->uri() returns an array...

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Berdir’s picture

Status: Active » Needs review
FileSize
3.8 KB

Ok, first patch.

This fixes the following from the list above:

Tag 23 passes, 0 fails, and 8 exceptions
Site-wide contact form 240 passes, 4 fails, and 7 exceptions
Tracker 228 passes, 0 fails, and 2 exceptions
Field: Base 206 passes, 0 fails, and 1 exception

All trivial and kinda fun stuff ;)

These are a bit more involving:

Import configuration 38 passes, 0 fails, and 20 exceptions
Import UI 45 passes, 1 fail, and 12 exceptions
Cache 12 passes, 0 fails, and 18 exceptions (hint: this is views plugin)

They throw notices because we pass nested arrays to array_diff_assoc(), something that it doesn't support, see: http://ch1.php.net/array_diff_assoc: "Note: This function only checks one dimension of a n-dimensional array. Of course you can check deeper dimensions by using, for example, array_diff_assoc($array1[0], $array2[0]);.". What it doesn't say is that it throws a warning when you do. Not sure what to do with these?

These are fixed in #1831530: Entity translation UI in core (part 2):

Entity Test Translation UI 68 passes, 0 fails, and 22 exceptions
Node translation UI 106 passes, 0 fails, and 18 exceptions
Taxonomy term translation UI 99 passes, 0 fails, and 22 exceptions

These actually don't seem to have failures without the cache storage chain patch, so can be Ignored I think.

Module dependencies 137 passes, 26 fails, and 2 exceptions
Row: UI 28 passes, 2 fails, and 1 exception
Style: UI 28 passes, 2 fails, and 1 exception
Enable/disable modules 1149 passes, 620 fails, and 60 exceptions
Handler test 110 passes, 0 fails, and 28 exceptions

Which leaves us with the array_diff_assoc() problem... That might even indicate possible actual bugs?

Berdir’s picture

+++ b/core/modules/tracker/lib/Drupal/tracker/Tests/TrackerTest.phpundefined
@@ -164,7 +164,7 @@ function testTrackerNewComments() {
     $node = $this->drupalCreateNode(array(
       'comment' => 2,
-      'title' => array(LANGUAGE_NOT_SPECIFIED => array(array('value' => $this->randomName(8)))),
+      'title' => $this->randomName(8),

This one is awesome.

This was changed back in 2009 when fields were converted to a field (yes, I had to check). And then, we forgot to change it back when this was reverted because it didn't fail, just converted this to "Array". Nothing that unusual, happens.. The fun part about is that we changed the constant twice without noticing ;)

Berdir’s picture

Actually, Handler test fails as well, with this:

Array to string conversion	Notice	admin.inc	1339	views_ui_add_item_form()
catch’s picture

Priority: Major » Critical

Bumping to critical, while we don't have PHP 5.4 on the test bots lots of people develop locally with that.

Berdir’s picture

Interesting, looks like the recent views changes fixed some of the views specific exceptions, like the Cache ones.

Also, there is now #1856546: config import should use array_diff_key that should take care of the config import related ones.

I've executed all views tests in the UI (yes, this is now actually a doable tasks thanks to the test performance improvements!) and fixed the remaining test failures.

I'm not 100% sure if the array_filter code in views_ui/admin.inc is correct, someone from the views team should probably have a look at it, not sure how good the test coverage there is.

Berdir’s picture

Uh, wrong patch.

Berdir’s picture

Discussed with @timplunkett that doing a foreach and just replacing the method might be easier to understand but we weren't sure if there is always a standardSubmit that can be replaced.

Patch in #6 needed a re-roll anyway, so here is one version with foreach and one with array_filter(). Both seem to pass the tests, whatever that means.

xmacinfo’s picture

@Berdir: This bug #1859536: Testing/Aggregator module warning: Requirements check comparison output two 'strings' (cURL) as an array may be related; string comparison for requirements shows a warning when the cURL comparison encounters an array.

dawehner’s picture

Status: Needs review » Reviewed & tested by the community
+++ b/core/modules/views/views_ui/admin.incundefined
@@ -1336,7 +1336,9 @@ function views_ui_add_item_form($form, &$form_state) {
+  $form['buttons']['submit']['#submit'] = array_filter($form['buttons']['submit']['#submit'], function($var) {
+    return !(is_array($var) && isset($var[1]) && $var[1] == 'standardSubmit');
+  });

This is so much better then before! In general array_filter() seems to easier to understand then foreach(

Dries’s picture

Status: Reviewed & tested by the community » Fixed

Committed to 8.x. Thanks.

Status: Fixed » Closed (fixed)

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