From 37ff5d98de778bdf32de6b6b86e5910c5c1be972 Mon Sep 17 00:00:00 2001 From: Jan-Hendrik Willms <tleilax+studip@gmail.com> Date: Fri, 31 May 2024 08:10:40 +0000 Subject: [PATCH] fixes #4233 Closes #4233 Merge request studip/studip!3066 --- lib/models/SimpleORMap.class.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/models/SimpleORMap.class.php b/lib/models/SimpleORMap.class.php index 359dbe86a39..09f67b499dc 100644 --- a/lib/models/SimpleORMap.class.php +++ b/lib/models/SimpleORMap.class.php @@ -1555,6 +1555,13 @@ class SimpleORMap implements ArrayAccess, Countable, IteratorAggregate } $this->setValue($options['foreign_key'], $assoc_foreign_key_value); } + } elseif ( + $value === null + && $this->db_fields()[$options['foreign_key']]['null'] === 'YES' + ) { + $this->resetRelation($field); + $this->setValue($options['foreign_key'], null); + } else { throw new InvalidArgumentException(sprintf('relation %s expects object of type: %s', $field, $options['class_name'])); } -- GitLab