When I run the 'Hooks' test on PHP 5.4.6 I get the following notice:
Notice: Array to string conversion in ds_field_attach_view_alter() (line 811 of .../sites/all/modules/contrib/ds/ds.module).
PHP 5.4 always generates a notice when converting an array to a string. This is done because after conversion the string will contain the word 'Array' which usually is not something a developer wants to continue working with.
The test which throws this notice is intentionally feeding invalid data to ds_field_attach_view_alter(). The error message can be suppressed by changing line 811:
- if (!empty($field_value) || (string) $field_value === '0') {
+ if (!empty($field_value) || (!is_array($field_value) && (string) $field_value === '0')) {
But this would probably not be the right approach, as this would actually be a workaround to avoid a test from throwing a notice. The purpose of the notice is to make debugging easier when developers unintentionally pass in an array instead of a string. This should be kept in.
I suppose the right solution would be to simply remove the test case that passes in bad data.
| Comment | File | Size | Author |
|---|---|---|---|
| #1 | 1739796-1-ds-array_to_string_test.patch | 2.02 KB | pfrenssen |
Comments
Comment #1
pfrenssenComment #2
swentel commentedtagging (note, if you're here in munich, we're doing a sprint wednesdayafternoon - or remote is fine as well ;)
Comment #3
pfrenssenI cancelled my trip to Munich because of a looming deadline on an important project, and I'm totally regretting it :-/
I'll never miss a Drupalcon again!!
Comment #4
swentel commentedMakes sense, thanks!
Comment #5
swentel commenteduntagging