From 9e3e2f96b2e4467ebfc7da5c73edc8f4a73949b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C5=91cze=20Bence?= Date: Mon, 1 May 2023 16:16:57 +0200 Subject: [PATCH] make left joins really work --- src/PersistentData/PersistentDataManager.php | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/PersistentData/PersistentDataManager.php b/src/PersistentData/PersistentDataManager.php index 0a75214..5932f06 100644 --- a/src/PersistentData/PersistentDataManager.php +++ b/src/PersistentData/PersistentDataManager.php @@ -227,12 +227,16 @@ class PersistentDataManager implements IPersistentDataManager next($data); } else if (substr($key, 0, strlen($relation . '__')) === $relation . '__') { - $relationType = current($relations); - $relationModel = new $relationType(); - $this->fillWithData($data, $relationModel, $withRelations, $relation); + if ($data[$relation . '__id'] !== null) { + $relationType = current($relations); + $relationModel = new $relationType(); + $this->fillWithData($data, $relationModel, $withRelations, $relation); - $method = 'set' . str_replace('_', '', ucwords($relation, '_')); - $model->$method($relationModel); + $method = 'set' . str_replace('_', '', ucwords($relation, '_')); + $model->$method($relationModel); + } else { + next($data); + } next($relations); } else {