I have the same issue described in https://www.drupal.org/project/services_views/issues/2198951 using the latest dev version and PHP 7.1.
This is a regression bug from the PHP 7.1 fixes done in https://www.drupal.org/project/services_views/issues/2910966.
In my case I needed empty string instead of array, I did a small hack to get it.
--- a/services_views.resource.inc
+++ b/services_views.resource.inc
@@ -178,13 +178,13 @@ function services_views_execute_view($view_info, $view = NULL, $display_id = NUL
// Create helper variables.
$output[$index]->$target_key = array();
if ($field->field_info['cardinality'] == 1) {
- $output[$index]->$target_key[] = '';
+ $output[$index]->$target_key = '';
}
$obj = &$output[$index]->$target_key;
$format = ($field->options['type'] == 'services') ? 'raw' : 'rendered';
foreach ($row->$f_key as $idx => $res) {
-
+ $obj = array();
if (isset($res[$format])) {
$data = $res[$format];
Is there are any other better way to get this done?
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | 2997446-6.patch | 845 bytes | lawxen |
| #3 | services_views-empty_field_to_array_with_empty_field_conversion-2997446-3-D7.patch | 1.27 KB | dmitrii |
| #2 | empty-string-array-2997446-2.patch | 804 bytes | zuhair_ak |
Comments
Comment #2
zuhair_akHacky way to get empty string instead of array.
Comment #3
dmitrii commented@zhhair_ak we cannot user $obj = array(); since it overwrites multi value fields.
Moved the cardinality check of a field outside of the foreach to count on empty fields.
See patch.
Comment #4
zuhair_ak@dmitrii You are correct, it will not display mulitvalue fields, in my specific case I needed empty string if there is no value, so I just changed my patch to check for multivalue fields -
Thanks for the patch.
Comment #5
lawxen commented#3 can't be applied to newest services_views, if I write the code by hand through the patch, don't work either
Comment #6
lawxen commentedComment #7
roman_l commented#6 is the way to go to solve the empty array issue (annoying when we expect a string).
Thanks @lawxen !
Comment #8
rajeev_drupal commented#6 worked for me. Thanks
Comment #9
rajeev_drupal commentedComment #10
WayneDyck commentedI can confirm #6 worked for me as well. I originally opened issue #3096315 because of the empty arrays being generated where a empty string used to be.
Also, my opinion, however, I don't think we should be making changes to accommodate PHP 5.6 at this point. Support for PHP 5.6 ended on December 31, 2018.
Comment #11
jeremyvdm commentedHi I just want to report that I have got this issues with the newest version 1.4 had to go back to the 1.2 because I didn't have this issue with the 1.2 and unfortunately the patch of #6 didn't work I kept having skipped patches
Comment #12
alison#6 worked great to fix the empty array problem for us!! Thank you!!
PHP 7.2.28
Core 7.72
services_views 7.x-1.4
(I realize it didn't work for one person, but it did work for 4 of us... so I'm marking RTBC for now -- obviously, feel free to overrule me :) )
-------
@jeremyvdm - Are you saying that the patch on #6 didn't apply to version 1.2, or it didn't apply even after you updated to 1.4?
(Also, did you also see the warning on the project page about upgrading to 1.3? -- did you go right from 1.2 to 1.4, and did you update your endpoints first?)
Comment #14
generalredneckThanks all for all the testing and work through the multiple issues.