diff --git a/.changes/unreleased/Fixed-20260115-132538.yaml b/.changes/unreleased/Fixed-20260115-132538.yaml new file mode 100644 index 000000000..3b671b12e --- /dev/null +++ b/.changes/unreleased/Fixed-20260115-132538.yaml @@ -0,0 +1,6 @@ +kind: Fixed +body: 'Fix: acc periods of which user is the referrer should not be included if when the list is filtered by center and none of the participations are part of the center' +time: 2026-01-15T13:25:38.269774735+01:00 +custom: + Issue: "491" + SchemaChange: No schema change diff --git a/src/Bundle/ChillPersonBundle/Export/Helper/FilterListAccompanyingPeriodHelper.php b/src/Bundle/ChillPersonBundle/Export/Helper/FilterListAccompanyingPeriodHelper.php index e631051a0..a86c29d14 100644 --- a/src/Bundle/ChillPersonBundle/Export/Helper/FilterListAccompanyingPeriodHelper.php +++ b/src/Bundle/ChillPersonBundle/Export/Helper/FilterListAccompanyingPeriodHelper.php @@ -44,12 +44,10 @@ final readonly class FilterListAccompanyingPeriodHelper implements FilterListAcc }; // add filtering on confidential accompanying period. The confidential is applyed on the current status of - // the accompanying period (we do not use the 'calc_date' here - $aclConditionsOrX = $qb->expr()->orX( - // either the current user is the refferer for the course - 'acp.user = :list_acp_current_user', - ); - $qb->setParameter('list_acp_current_user', $user); + // the accompanying period (we do not use the 'calc_date' here) + // + // IMPORTANT: we must NOT bypass selected centers just because the current user is the referrer. + $aclConditionsOrX = $qb->expr()->orX(); $i = 0; foreach ($centers as $center) { @@ -93,6 +91,12 @@ final readonly class FilterListAccompanyingPeriodHelper implements FilterListAcc ++$i; } - $qb->andWhere($aclConditionsOrX); + // Prevent invalid/empty WHERE when no conditions were added (e.g., no centers available) + if (method_exists($aclConditionsOrX, 'getParts') && 0 === count($aclConditionsOrX->getParts())) { + // No allowed conditions => return no rows + $qb->andWhere('1 = 0'); + } else { + $qb->andWhere($aclConditionsOrX); + } } }