From bdf53f5bbbfffa6db1ee7e24195c50829533f2e8 Mon Sep 17 00:00:00 2001 From: gevorgmansuryan Date: Sun, 26 Oct 2025 03:38:31 +0400 Subject: [PATCH 1/7] Issue - Fix sidebar widget issue --- interfaces/event/AbstractCalendarQuery.php | 34 +++++++++++++--------- models/CalendarEntryQuery.php | 16 +++++++--- 2 files changed, 32 insertions(+), 18 deletions(-) diff --git a/interfaces/event/AbstractCalendarQuery.php b/interfaces/event/AbstractCalendarQuery.php index 516c16a0..25d08713 100644 --- a/interfaces/event/AbstractCalendarQuery.php +++ b/interfaces/event/AbstractCalendarQuery.php @@ -21,6 +21,7 @@ use yii\base\Component; use yii\db\ActiveQuery; use yii\db\ActiveRecord; +use yii\db\Query; /** * Created by PhpStorm. @@ -785,11 +786,7 @@ protected function setupCriteria() } } - /** - * Sets up the date interval filter with respect to the openRange setting. - * This will also include all recurrent event roots if $expand is true and recurrence evets are supported - */ - protected function setupDateCriteria() + protected function createDateCriteriaQuery(Query $query = null) { if ($this->_from) { $fromTime = clone $this->_from; @@ -805,21 +802,21 @@ protected function setupDateCriteria() //Search for all dates with start and/or end within the given range if ($this->dateQueryType === static::DATE_QUERY_TYPE_DATE) { - $this->_query->andFilterWhere(['or', + $query->andFilterWhere(['or', ['and', $this->getStartCriteria($this->_from, '<'), $this->getEndCriteria($this->_to, '>')], ['and', $this->getStartCriteria($this->_from, '>='), $this->getStartCriteria($this->_to, '<')], ['and', $this->getEndCriteria($this->_from, '>'), $this->getEndCriteria($this->_to, '<=')], $this->isRecurrenceRootCondition(), ]); } elseif ($this->dateQueryType === static::DATE_QUERY_TYPE_TIME) { - $this->_query->andFilterWhere(['or', + $query->andFilterWhere(['or', ['and', $this->getStartCriteria($fromTime, '<'), $this->getEndCriteria($toTime, '>')], ['and', $this->getStartCriteria($fromTime, '>='), $this->getStartCriteria($toTime, '<')], ['and', $this->getEndCriteria($fromTime, '>'), $this->getEndCriteria($toTime, '<=')], $this->isRecurrenceRootCondition(), ]); } elseif ($this->dateQueryType === static::DATE_QUERY_TYPE_MIXED) { - $this->_query->andFilterWhere( + $query->andFilterWhere( ['or', ['or', ['and', @@ -846,11 +843,11 @@ protected function setupDateCriteria() } else { if ($this->_from) { if ($this->dateQueryType === static::DATE_QUERY_TYPE_DATE) { - $this->_query->andWhere(['or', $this->getStartCriteria($this->_from, '>='), $this->isRecurrenceRootCondition()]); + $query->andWhere(['or', $this->getStartCriteria($this->_from, '>='), $this->isRecurrenceRootCondition()]); } elseif ($this->dateQueryType === static::DATE_QUERY_TYPE_TIME) { - $this->_query->andWhere(['or', $this->getStartCriteria($fromTime, '>='), $this->isRecurrenceRootCondition()]); + $query->andWhere(['or', $this->getStartCriteria($fromTime, '>='), $this->isRecurrenceRootCondition()]); } elseif ($this->dateQueryType === static::DATE_QUERY_TYPE_MIXED) { - $this->_query->andWhere( + $query->andWhere( ['or', ['and', [$this->allDayField => 0], $this->getStartCriteria($fromTime, '>=')], ['and', [$this->allDayField => 1], $this->getStartCriteria($this->_from, '>=')], @@ -862,11 +859,11 @@ protected function setupDateCriteria() if ($this->_to) { if ($this->dateQueryType === static::DATE_QUERY_TYPE_DATE) { - $this->_query->andWhere(['or', $this->getEndCriteria($this->_to, '<='), $this->isRecurrenceRootCondition()]); + $query->andWhere(['or', $this->getEndCriteria($this->_to, '<='), $this->isRecurrenceRootCondition()]); } elseif ($this->dateQueryType === static::DATE_QUERY_TYPE_TIME) { - $this->_query->andWhere(['or', $this->getEndCriteria($toTime, '<='), $this->isRecurrenceRootCondition()]); + $query->andWhere(['or', $this->getEndCriteria($toTime, '<='), $this->isRecurrenceRootCondition()]); } elseif ($this->dateQueryType === static::DATE_QUERY_TYPE_MIXED) { - $this->_query->andWhere( + $query->andWhere( ['or', ['and', [$this->allDayField => 0], $this->getEndCriteria($toTime, '<=')], ['and', [$this->allDayField => 1], $this->getEndCriteria($this->_to, '<=')], @@ -879,6 +876,15 @@ protected function setupDateCriteria() } } + /** + * Sets up the date interval filter with respect to the openRange setting. + * This will also include all recurrent event roots if $expand is true and recurrence evets are supported + */ + protected function setupDateCriteria() + { + $this->createDateCriteriaQuery($this->_query); + } + /** * Returns a sql condition filtering recurrent root events if supported. Returns empty string if not supported. * diff --git a/models/CalendarEntryQuery.php b/models/CalendarEntryQuery.php index 3e308093..e9ac41c6 100644 --- a/models/CalendarEntryQuery.php +++ b/models/CalendarEntryQuery.php @@ -5,6 +5,7 @@ use humhub\modules\calendar\interfaces\recurrence\AbstractRecurrenceQuery; use humhub\modules\content\components\ContentContainerActiveRecord; use DateTime; +use yii\db\Query; /** * CalendarEntryQuery class can be used for creating filter queries for [[CalendarEntry]] models. @@ -95,10 +96,17 @@ public function filterIsParticipant() public function filterOrIsParticipant() { $this->participantJoin(); - $this->_query->orWhere(['calendar_entry_participant.participation_state' => [ - CalendarEntryParticipant::PARTICIPATION_STATE_ACCEPTED, - CalendarEntryParticipant::PARTICIPATION_STATE_MAYBE, - ]]); + $onlyParticipatingQuery = new Query(); + $this->createDateCriteriaQuery($onlyParticipatingQuery); + + $this->_query->orWhere([ + 'AND', + ['IN', 'calendar_entry_participant.participation_state', [ + CalendarEntryParticipant::PARTICIPATION_STATE_ACCEPTED, + CalendarEntryParticipant::PARTICIPATION_STATE_MAYBE, + ]], + $onlyParticipatingQuery->where + ]); } private function participantJoin() From 5f2699fa63f9dc6f78bec6622dcab2c7bc2e72c4 Mon Sep 17 00:00:00 2001 From: gevorgmansuryan Date: Sun, 26 Oct 2025 03:51:30 +0400 Subject: [PATCH 2/7] Issue - Fix sidebar widget issue --- docs/CHANGELOG.md | 4 ++++ module.json | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index e5fc0396..1dbf4771 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -1,6 +1,10 @@ Changelog ========= +1.8.5 (Unreleased) +------------------------ +- Fix #630: Fix sidebar widget issue + 1.8.4 (October 23, 2025) ------------------------ - Fix #609: Fix for PHP 8.4 diff --git a/module.json b/module.json index eb587db0..69f77aec 100644 --- a/module.json +++ b/module.json @@ -3,7 +3,7 @@ "name": "Calendar", "description": "Create one-time or recurring events, invite and manage attendees, and keep track of all your events with the Calendar module.", "keywords": ["calendar"], - "version": "1.8.4", + "version": "1.8.5", "humhub": { "minVersion": "1.18" }, From f3aed1703f41558e3f2182ff5ef830e873b342fb Mon Sep 17 00:00:00 2001 From: gevorgmansuryan Date: Mon, 27 Oct 2025 19:32:57 +0400 Subject: [PATCH 3/7] Issue - Fix sidebar widget issue --- tests/codeception/_support/CalendarUnitTest.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tests/codeception/_support/CalendarUnitTest.php b/tests/codeception/_support/CalendarUnitTest.php index eebaf0ba..fab0c057 100644 --- a/tests/codeception/_support/CalendarUnitTest.php +++ b/tests/codeception/_support/CalendarUnitTest.php @@ -70,8 +70,14 @@ protected function createEntry($from, $days, $title, $container = null, $visibil if ($container) { $entry->content->container = $container; } +$a = $entry->save(); + $this->assertTrue($a); + + if (!$a) { + + var_dump($entry->getFirstErrors());die; + } - $this->assertTrue($entry->save()); return $entry; } } From 1ae9364539a7e27c8deb544b7fc0a456b3f82e76 Mon Sep 17 00:00:00 2001 From: gevorgmansuryan Date: Mon, 27 Oct 2025 20:53:14 +0400 Subject: [PATCH 4/7] Issue - Fix sidebar widget issue --- tests/codeception/_support/CalendarUnitTest.php | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/tests/codeception/_support/CalendarUnitTest.php b/tests/codeception/_support/CalendarUnitTest.php index fab0c057..6d0d6e8b 100644 --- a/tests/codeception/_support/CalendarUnitTest.php +++ b/tests/codeception/_support/CalendarUnitTest.php @@ -70,13 +70,9 @@ protected function createEntry($from, $days, $title, $container = null, $visibil if ($container) { $entry->content->container = $container; } -$a = $entry->save(); - $this->assertTrue($a); - if (!$a) { - - var_dump($entry->getFirstErrors());die; - } + $result = $entry->save(); + $this->assertTrue($result); return $entry; } From 96ab33e06876fe559a527ce5b1e8b3375108d29a Mon Sep 17 00:00:00 2001 From: gevorgmansuryan Date: Mon, 27 Oct 2025 21:03:15 +0400 Subject: [PATCH 5/7] Issue - Fix sidebar widget issue --- tests/codeception/_support/CalendarUnitTest.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tests/codeception/_support/CalendarUnitTest.php b/tests/codeception/_support/CalendarUnitTest.php index 6d0d6e8b..eebaf0ba 100644 --- a/tests/codeception/_support/CalendarUnitTest.php +++ b/tests/codeception/_support/CalendarUnitTest.php @@ -71,9 +71,7 @@ protected function createEntry($from, $days, $title, $container = null, $visibil $entry->content->container = $container; } - $result = $entry->save(); - $this->assertTrue($result); - + $this->assertTrue($entry->save()); return $entry; } } From 65d0d07dc97c020b50af1aed98ac1ac7355fb97d Mon Sep 17 00:00:00 2001 From: gevorgmansuryan Date: Mon, 27 Oct 2025 22:36:49 +0400 Subject: [PATCH 6/7] Issue - Fix sidebar widget issue --- interfaces/event/AbstractCalendarQuery.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interfaces/event/AbstractCalendarQuery.php b/interfaces/event/AbstractCalendarQuery.php index 25d08713..f39f5249 100644 --- a/interfaces/event/AbstractCalendarQuery.php +++ b/interfaces/event/AbstractCalendarQuery.php @@ -786,7 +786,7 @@ protected function setupCriteria() } } - protected function createDateCriteriaQuery(Query $query = null) + protected function createDateCriteriaQuery(Query $query) { if ($this->_from) { $fromTime = clone $this->_from; From 8527892e788718f7ea73fc40f08b5b878ce66dfb Mon Sep 17 00:00:00 2001 From: gevorgmansuryan Date: Mon, 27 Oct 2025 22:36:49 +0400 Subject: [PATCH 7/7] Issue - Fix sidebar widget issue --- interfaces/event/AbstractCalendarQuery.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interfaces/event/AbstractCalendarQuery.php b/interfaces/event/AbstractCalendarQuery.php index 25d08713..f39f5249 100644 --- a/interfaces/event/AbstractCalendarQuery.php +++ b/interfaces/event/AbstractCalendarQuery.php @@ -786,7 +786,7 @@ protected function setupCriteria() } } - protected function createDateCriteriaQuery(Query $query = null) + protected function createDateCriteriaQuery(Query $query) { if ($this->_from) { $fromTime = clone $this->_from;