From d1022ad42981a210199a9dd47bc8d9ce7222c397 Mon Sep 17 00:00:00 2001 From: dereuromark Date: Sun, 26 Mar 2017 19:23:41 +0200 Subject: [PATCH] Fix additional data coming from right table. --- src/Model/Behavior/VersionBehavior.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Model/Behavior/VersionBehavior.php b/src/Model/Behavior/VersionBehavior.php index f37a53d..1eab487 100644 --- a/src/Model/Behavior/VersionBehavior.php +++ b/src/Model/Behavior/VersionBehavior.php @@ -294,11 +294,15 @@ public function groupVersions($results) $versionData = [ $versionField => $versionId ]; + + /* @var \Cake\Datasource\EntityInterface $versionRow */ + $versionRow = $grouped->match(['version_id' => $versionId])->first(); + foreach ($this->_config['additionalVersionFields'] as $mappedField => $field) { if (!is_string($mappedField)) { $mappedField = 'version_' . $field; } - $versionData[$mappedField] = $row->get($field); + $versionData[$mappedField] = $versionRow->get($field); } $version = new $entityClass($keys + $versionData, [