From 6455ec9af3df9e58dbd66333964ad2db32220033 Mon Sep 17 00:00:00 2001 From: Yuriy Bakhtin Date: Wed, 15 Nov 2023 15:44:09 +0100 Subject: [PATCH] Fix memory usage on integrity check --- Events.php | 8 ++++---- docs/CHANGELOG.md | 4 ++++ module.json | 2 +- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/Events.php b/Events.php index b1c908c9..cada145d 100644 --- a/Events.php +++ b/Events.php @@ -306,7 +306,7 @@ public static function onIntegrityCheck($event) $integrityController = $event->sender; $integrityController->showTestHeadline("Calendar Module (" . CalendarReminder::find()->count() . " reminder entries)"); - foreach (CalendarReminder::find()->all() as $reminder) { + foreach (CalendarReminder::find()->each() as $reminder) { if ($reminder->isEntryLevelReminder() && !Content::findOne(['id' => $reminder->content_id])) { if ($integrityController->showFix("Delete calendar reminder " . $reminder->id . " without existing entry relation!")) { $reminder->delete(); @@ -316,7 +316,7 @@ public static function onIntegrityCheck($event) $integrityController->showTestHeadline("Calendar Module (" . CalendarReminderSent::find()->count() . " reminder sent entries)"); - foreach (CalendarReminderSent::find()->all() as $reminderSent) { + foreach (CalendarReminderSent::find()->each() as $reminderSent) { if(!Content::findOne(['id' => $reminderSent->content_id])) { if ($integrityController->showFix("Delete calendar reminder sent" . $reminderSent->id . " without existing entry relation!")) { $reminderSent->delete(); @@ -332,13 +332,13 @@ public static function onIntegrityCheck($event) ->groupBy('parent_event_id, recurrence_id') ->having('COUNT(*) > 1')->asArray(true); - foreach ($duplicatedRecurrences->all() as $duplicatedRecurrenceArr) { + foreach ($duplicatedRecurrences->each() as $duplicatedRecurrenceArr) { $duplicateQuery = CalendarEntry::find() ->where(['recurrence_id' => $duplicatedRecurrenceArr['recurrence_id']]) ->andWhere(['parent_event_id' => $duplicatedRecurrenceArr['parent_event_id']]) ->andWhere(['<>', 'id', $duplicatedRecurrenceArr['id']]); - foreach ($duplicateQuery->all() as $duplicate) { + foreach ($duplicateQuery->each() as $duplicate) { if(RecurrenceHelper::isRecurrentInstance($duplicate) && $duplicate->id !== $duplicatedRecurrenceArr['id']) { if ($integrityController->showFix('Delete duplicated recurrent event instance ' . $duplicate->id . '!')) { $duplicate->hardDelete(); diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 65156ff4..53f788a9 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -1,6 +1,10 @@ Changelog ========= +1.5.7 (Unreleased) +-------------------------- +- Fix #433: Fix memory usage on integrity check + 1.5.6 (October 26, 2023) -------------------------- - Enh #429: Add additional data to participant export diff --git a/module.json b/module.json index 08673a7e..463af842 100644 --- a/module.json +++ b/module.json @@ -3,7 +3,7 @@ "name": "Calendar", "description": "Calendar for spaces or user profiles.", "keywords": ["calendar"], - "version": "1.5.6", + "version": "1.5.7", "humhub": { "minVersion": "1.14" },