From bf81b32171d7b624f880acc6d1e8cd5b0ee6a5c9 Mon Sep 17 00:00:00 2001 From: Yuriy Bakhtin Date: Tue, 9 May 2023 10:01:19 +0200 Subject: [PATCH] Use new content state service --- docs/CHANGELOG.md | 1 + models/CalendarEntry.php | 5 ++--- tests/codeception/unit/recurrence/RecurrenceEditTest.php | 3 +-- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index cfffbd1d..6641bfc3 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -4,6 +4,7 @@ Changelog 1.5.1 (Unreleased) -------------------- - Enh #376: Added support for hidden tasks in stream +- Enh #378: Use new content state service 1.5.0 (May 1, 2023) -------------------- diff --git a/models/CalendarEntry.php b/models/CalendarEntry.php index cfae4a0d..f5f45957 100644 --- a/models/CalendarEntry.php +++ b/models/CalendarEntry.php @@ -403,9 +403,8 @@ public function afterStateChange(?int $newState, ?int $previousState): void $entries = $root->getRecurrenceInstances()->all(); $entries[] = $root; foreach ($entries as $entry) { - if ($entry->content->state != $newState) { - $entry->content->setState($newState); - $entry->content->save(); + if (!$entry->content->getStateService()->is($newState)) { + $entry->content->getStateService()->update($newState); } } } diff --git a/tests/codeception/unit/recurrence/RecurrenceEditTest.php b/tests/codeception/unit/recurrence/RecurrenceEditTest.php index 9ccdd78c..038748d3 100644 --- a/tests/codeception/unit/recurrence/RecurrenceEditTest.php +++ b/tests/codeception/unit/recurrence/RecurrenceEditTest.php @@ -83,8 +83,7 @@ public function testRestoreRecurrentInstance() $allEntries = $this->rootEvent->getRecurrenceInstances()->all(); array_unshift($allEntries, $this->rootEvent); $anyRecurrenceEntry = $allEntries[rand(1, count($allEntries) - 1)]; - $anyRecurrenceEntry->content->setState(Content::STATE_PUBLISHED); - $anyRecurrenceEntry->content->save(); + $anyRecurrenceEntry->content->getStateService()->publish(); // Check root and all child events are restored automatically as well foreach ($allEntries as $entry) {