diff --git a/src/Collections/TerminusCollection.php b/src/Collections/TerminusCollection.php index 4788fa410..d624d932b 100644 --- a/src/Collections/TerminusCollection.php +++ b/src/Collections/TerminusCollection.php @@ -96,17 +96,18 @@ public function fetch() foreach ($this->getData() as $id => $model_data) { if (!is_object($model_data)) { // For some reason I can't replicate, occasionally $model_data is just a string here. + $bad_data = print_r($model_data, true); + if (is_string($bad_data) && strlen($bad_data) > 250) { + $bad_data = substr($bad_data, 0, 250) . ' ...'; + } + $error_message = "Fetch failed {file}:{line} model_data expected as object but returned as {type}. Unexpected value: {bad_data}"; $trace = debug_backtrace(); - $error_message = "Fetch failed {file}:{line} model_data expected as object but returned as {type}."; $context = [ 'file' => $trace[0]['file'], 'line' => $trace[0]['line'], 'type' => gettype($model_data), + 'bad_data' => $bad_data ]; - if (is_string($model_data)) { - $error_message .= " String value: {string}"; - $context['string'] = strlen($model_data) > 250 ? substr($model_data, 0, 250) . '...' : $model_data; - } $this->logger->error($error_message, $context); break; }