From 0c584d2e69ffdfd389ca93adfd87291d09960f06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antti-Jussi=20Nyg=C3=A5rd?= Date: Thu, 22 Feb 2024 10:29:23 +0200 Subject: [PATCH] Fix error when creating a new Section --- OpenAIREPlugin.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/OpenAIREPlugin.php b/OpenAIREPlugin.php index fc2aa31..90ffa8d 100644 --- a/OpenAIREPlugin.php +++ b/OpenAIREPlugin.php @@ -109,8 +109,10 @@ public function initDataSectionFormFields($hookName, $args) { $request = Application::get()->getRequest(); $context = $request->getContext(); $contextId = $context ? $context->getId() : CONTEXT_ID_NONE; - $section = Repo::section()->get($sectionForm->getSectionId()); - if ($section) $sectionForm->setData('resourceType', $section->getData('resourceType')); + if ($sectionForm->getSectionId()) { + $section = Repo::section()->get($sectionForm->getSectionId()); + if ($section) $sectionForm->setData('resourceType', $section->getData('resourceType')); + } } /**