Skip to content

Commit

Permalink
Merge pull request #433 from humhub/fix/198-integrity-check-memory-usage
Browse files Browse the repository at this point in the history
Fix memory usage on integrity check
  • Loading branch information
luke- authored Nov 16, 2023
2 parents 0f9907b + 6455ec9 commit 2425ba8
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
8 changes: 4 additions & 4 deletions Events.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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();
Expand All @@ -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();
Expand Down
4 changes: 4 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion module.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down

0 comments on commit 2425ba8

Please sign in to comment.