WSDOT / wsdot-website

Codebase for WSDOT's public Drupal 7 website hosted on Acquia.
0 stars 4 forks source link

Contributed modules update #481

Closed waynedyck closed 4 years ago

waynedyck commented 4 years ago

The following modules have been identified as having an update available:

Name Installed version Recommended version
Link 7.x-1.6 7.x-1.7 (Release notes)
Services Views 7.x-1.3 7.x-1.4 (Release notes)
waynedyck commented 4 years ago

Need to revert Services Views module back to version 7.x-1.3

Before the module update a record of the JSON feed would have appeared like so,

{"id":"1818","title":"I-90 Barker to Harvard","cities":["Liberty Lake","Spokane","Spokane Valley"],"counties":["Spokane"],"division":"","funding":["CWA"],"funding_table":"","highways":["I-90"],"path":"/projects/i90/barker-harvard/home","phase":"Planning","pin_report":"","regions":["Eastern"],"status":"Active"}

And after the update we have this:

{"id":"1818","title":"I-90 Barker to Harvard","cities":["Liberty Lake","Spokane","Spokane Valley"],"counties":["Spokane"],"division":[""],"funding":["CWA"],"funding_table":[""],"highways":["I-90"],"path":"/projects/i90/barker-harvard/home","phase":"Planning","pin_report":[""],"regions":["Eastern"],"status":"Active"}

The original feed treats some empty values as a string, like this, "division":"" and the new feed has changed it to an empty array, "division":[""]

I’m trying to determine within Drupal the difference in fields that would cause this to appear in the original feed,

cities: [ ], counties: [ ], division: "",

versus this in the updated feed,

cities: [ ], counties: [ ], division: [""],

Need to determine if the new JSON format is valid considering the Drupal fields or if we need to open a bug report. Either way, folks will need to time to update their code to deal with the new format.

waynedyck commented 4 years ago

The For empty or no values, Service Views returns empty array issue was created back in September 2018.

On April 25th, the following patch was submitted which fixes the bug identified here.

diff --git a/services_views.resource.inc b/services_views.resource.inc
index 1efe281..84f5574 100644
--- a/services_views.resource.inc
+++ b/services_views.resource.inc
@@ -178,12 +178,15 @@ 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 = array('');
+          $output[$index]->$target_key = '';
         }
         $obj = &$output[$index]->$target_key;
         $format = ($field->options['type'] == 'services') ? 'raw' : 'rendered';

         foreach ($row->$f_key as $idx => $res) {
+          if ($idx == 0) {
+            $obj = [];
+          }

           if (isset($res[$format])) {
             $data = $res[$format];

I will manually apply this patch to version 7.x-1.4 until such time as an official update comes out.