From e7c6d7c2e41cfda5dad05d010feb3d18d160b2a7 Mon Sep 17 00:00:00 2001 From: thierrydallacroce Date: Wed, 18 Dec 2019 15:49:59 -0800 Subject: [PATCH] Improve data type checking before dereferencing, log if unexpected (#274) --- modules/custom/dkan_data/src/ValueReferencer.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/modules/custom/dkan_data/src/ValueReferencer.php b/modules/custom/dkan_data/src/ValueReferencer.php index 44dd8ea7e..cad265791 100644 --- a/modules/custom/dkan_data/src/ValueReferencer.php +++ b/modules/custom/dkan_data/src/ValueReferencer.php @@ -282,9 +282,18 @@ protected function dereferenceProperty(string $property_id, $data) { if (is_array($data)) { return $this->dereferenceMultiple($property_id, $data); } - else { + elseif (is_string($data)) { return $this->dereferenceSingle($property_id, $data); } + else { + Drupal::logger('value_referencer')->error( + 'Unexpected data type when dereferencing property_id @property_id with data "@data"', + [ + '@property_id' => property_id, + '@$data' => var_export($data, TRUE), + ] + ); + } } /**