From 40b888eaf30f6c6899134f7fcbfb0705987516e1 Mon Sep 17 00:00:00 2001 From: Loz Calver Date: Mon, 4 Dec 2023 11:44:34 +0000 Subject: [PATCH] FIX: UnsavedRelationList::last() sometimes returned an ID instead of an item --- src/ORM/UnsavedRelationList.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/ORM/UnsavedRelationList.php b/src/ORM/UnsavedRelationList.php index 4a6a702f2..9e078c63e 100644 --- a/src/ORM/UnsavedRelationList.php +++ b/src/ORM/UnsavedRelationList.php @@ -257,6 +257,9 @@ class UnsavedRelationList extends ArrayList implements Relation public function last() { $item = end($this->items) ?: null; + if (is_numeric($item)) { + $item = DataObject::get_by_id($this->dataClass, $item); + } if ($item && !empty($this->extraFields[key($this->items)])) { $item->update($this->extraFields[key($this->items)]); }