From f6ffc2e15c29e98a40c69895163407c549b6f721 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Philipp=20Sch=C3=BCle?=
Date: Wed, 5 Feb 2025 14:31:48 +0100
Subject: [PATCH] fix(Tinebase/Update/18.3): make sure that notes are not
touched before update script
---
tests/tine20/Addressbook/ControllerTest.php | 3 ---
tine20/Tinebase/Controller/Record/Abstract.php | 4 ++--
tine20/Tinebase/Setup/Update/18.php | 12 ++++++------
3 files changed, 8 insertions(+), 11 deletions(-)
diff --git a/tests/tine20/Addressbook/ControllerTest.php b/tests/tine20/Addressbook/ControllerTest.php
index cd92066bc8..4bdd6d20fa 100644
--- a/tests/tine20/Addressbook/ControllerTest.php
+++ b/tests/tine20/Addressbook/ControllerTest.php
@@ -468,9 +468,6 @@ public function testUseNotes()
$this->assertTrue($newcontact1->has('notes'));
$this->assertEquals($compStr, $newcontact1->notes[0]->note);
-
- $this->expectException('Tinebase_Exception_NotFound');
- $this->objects['contact']->notes[0]->note = 'note';
}
/**
diff --git a/tine20/Tinebase/Controller/Record/Abstract.php b/tine20/Tinebase/Controller/Record/Abstract.php
index 5a52f27a36..6301f3801f 100644
--- a/tine20/Tinebase/Controller/Record/Abstract.php
+++ b/tine20/Tinebase/Controller/Record/Abstract.php
@@ -652,7 +652,7 @@ protected function _getRelatedData($record)
if ($record->has('attachments') && Tinebase_Core::isFilesystemAvailable()) {
Tinebase_FileSystem_RecordAttachments::getInstance()->getRecordAttachments($record);
}
- if ($record->has('notes')) {
+ if ($record->has('notes') && $this->useNotes()) {
$record->notes = Tinebase_Notes::getInstance()->getNotesOfRecord($this->_modelName, $record->getId());
}
if (!empty($record::getConfiguration()->jsonExpander)) {
@@ -2473,7 +2473,7 @@ protected function _deleteRecord(Tinebase_Record_Interface $_record)
*/
protected function _deleteLinkedObjects(Tinebase_Record_Interface $_record)
{
- if ($_record->has('notes')) {
+ if ($_record->has('notes') && $this->useNotes()) {
Tinebase_Notes::getInstance()->deleteNotesOfRecord($this->_modelName, $this->_getBackendType(), $_record->getId());
}
diff --git a/tine20/Tinebase/Setup/Update/18.php b/tine20/Tinebase/Setup/Update/18.php
index 4dc41211eb..30e59561e0 100644
--- a/tine20/Tinebase/Setup/Update/18.php
+++ b/tine20/Tinebase/Setup/Update/18.php
@@ -18,8 +18,13 @@ class Tinebase_Setup_Update_18 extends Setup_Update_Abstract
protected const RELEASE018_UPDATE002 = __CLASS__ . '::update002';
protected const RELEASE018_UPDATE003 = __CLASS__ . '::update003';
-
static protected $_allUpdates = [
+ self::PRIO_TINEBASE_BEFORE_EVERYTHING => [
+ self::RELEASE018_UPDATE003 => [
+ self::CLASS_CONST => self::class,
+ self::FUNCTION_CONST => 'update003',
+ ],
+ ],
self::PRIO_TINEBASE_STRUCTURE => [
self::RELEASE018_UPDATE001 => [
self::CLASS_CONST => self::class,
@@ -29,10 +34,6 @@ class Tinebase_Setup_Update_18 extends Setup_Update_Abstract
self::CLASS_CONST => self::class,
self::FUNCTION_CONST => 'update002',
],
- self::RELEASE018_UPDATE003 => [
- self::CLASS_CONST => self::class,
- self::FUNCTION_CONST => 'update003',
- ],
],
self::PRIO_NORMAL_APP_UPDATE => [
self::RELEASE018_UPDATE000 => [
@@ -89,5 +90,4 @@ public function update003()
$this->addApplicationUpdate(Tinebase_Config::APP_NAME, '18.3', self::RELEASE018_UPDATE003);
}
-
}