FIX: UnsavedRelationList::last() sometimes returned an ID instead of an item

This commit is contained in:
Loz Calver 2023-12-04 11:44:34 +00:00
parent e28af9a5a7
commit 40b888eaf3

View File

@ -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)]);
}