`OutOfOfficeEventDispatcherJob` is not cleaned up correctly
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 78/100
Direzione di ricerca
Leggi apps/dav/lib/Service/AbsenceService.php, concentrandoti su clearAbsence() e createOrUpdateAbsence(), e verifica come IJobList::remove() confronta gli argomenti dei job. Poi esamina apps/dav/tests/unit/Service/AbsenceServiceTest.php e aggiungi test per la cancellazione di una singola assenza e la modifica delle date a date passate. Il lavoro è completato quando vengono rimossi solo i job di quell’assenza e non rimane in coda alcun job con data di inizio o fine passata.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
⚠️ This issue respects the following points: ⚠️
- This is not a troubleshooting question, general support matter, or webserver/proxy problem, but likely a bug.
- This issue is not already reported on Github OR solved at the Community Help Forum (I've searched!).
- I'm using a maintained major version of Nextcloud Server and tested against the latest patch level.
- I agree to follow Nextcloud's Code of Conduct.
- I've tried my best to provide clear reproduction steps that someone unfamiliar with this bug could use to reproduce it.
Bug description
The OutOfOfficeEventDispatcherJob background jobs, which dispatch OutOfOfficeStartedEvent
and OutOfOfficeEndedEvent, are not cleaned up correctly in OCA\DAV\Service\AbsenceService.
- Clearing an absence cancels the pending jobs of all users
- Editing an absence so a start or end time is already past leaves the old job queued
Clearing an absence cancels the pending jobs of all users
AbsenceService::clearAbsence() calls:
$this->jobList->remove(OutOfOfficeEventDispatcherJob::class);
IJobList::remove() with no argument deletes every job of that class, not only the
jobs of the cleared absence. So one user clearing their absence cancels the queued start and
end jobs of every other user's upcoming or running absence. Those users never get
OutOfOfficeStartedEvent / OutOfOfficeEndedEvent for their absence.
Listeners on those events, such as an app that acts when an absence starts or ends, silently
miss them. user_status is partly protected because UserStatusAutomation also schedules
itself from the absence dates.
Editing an absence so a start or end time is already past leaves the old job queued
AbsenceService::createOrUpdateAbsence() only calls IJobList::scheduleAfter() when the
new start or end time is still in the future. scheduleAfter() updates an existing job with
the same class and arguments (['id' => <absence id>, 'event' => 'start'|'end']), so moving
an absence to other future dates works. But if an edit moves the start (or end) to now or
earlier, no scheduleAfter() call happens and the old job stays queued at its previous time.
When it runs, it loads the absence by id and dispatches a stray OutOfOfficeStartedEvent
(or OutOfOfficeEndedEvent) at the wrong time.
Impact of (2) is low. user_status and Mail just recompute their state from the current
absence data, but listeners that act on the event itself get a stray event.
Steps to reproduce
Problem 1
- As user
alice, set an absence in Personal settings → Availability with a first day in the future, and save. - Confirm two jobs exist for it:
SELECT id, argument, last_checked FROM oc_jobs WHERE class = 'OCA\\DAV\\BackgroundJob\\OutOfOfficeEventDispatcherJob'; - As user
bob, set any absence and save, then click "Disable absence". - Run the query from step 2 again: no jobs are left, and alice's start and end jobs are gone too.
Problem 2
- As user
alice, set an absence from next Monday to next Friday and save. - Confirm the
startjob for that absence id is scheduled for next Monday 00:00 (user timezone). - Edit the absence so the first day is today, and save.
- Run the query again: the
startjob is still scheduled for next Monday. - Next Monday, the job runs and dispatches
OutOfOfficeStartedEventfor an absence that
started days earlier.
Expected behavior
- Clearing an absence only removes the start and end jobs of that absence.
- After editing an absence, no start or end job stays queued for a time that is already past.
Nextcloud Server version
36 (master). Same code on stable32, stable33, stable34 and stable35.
Operating system
Not environment specific (logic bug in apps/dav)
PHP engine version
Not environment specific
Web server
Not environment specific
Database engine version
Not environment specific
Is this bug present after an update or on a fresh install?
Fresh Nextcloud Server install (present since the feature was added in Nextcloud 28)
Are you using the Nextcloud Server Encryption module?
Not relevant
What user-backends are you using?
- Default user-backend (database) (not backend specific)
Configuration report
Not relevant
List of activated Apps
dav, user_status (default)
Nextcloud Signing status
Not relevant
Nextcloud Logs
Nothing is logged; both problems are silent.
Additional info
Affected code: apps/dav/lib/Service/AbsenceService.php
clearAbsence(): theremove()call without an argument.createOrUpdateAbsence(): start and end jobs are only scheduled when the time is in the future.
Proposed fix: always remove jobs with their exact arguments, for example:
$this->jobList->remove(OutOfOfficeEventDispatcherJob::class, [
'id' => $absence->getId(),
'event' => OutOfOfficeEventDispatcherJob::EVENT_START,
]);
- In
clearAbsence(): remove both jobs (EVENT_STARTandEVENT_END) of the deleted absence. - In
createOrUpdateAbsence(): if the new start or end time is not in the future, remove that job. - Add unit tests in
apps/dav/tests/unit/Service/AbsenceServiceTest.phpfor both cases.
- Lingua principale
- PHP
- Stelle
- 37.2k
- Fork
- 5.3k
- Merge medio
- 2g 5h
- PR unite (30g)
- 666
Preparare l'ambiente
Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di nextcloud/server
-
0. Needs triage 35-feedback bug team: Files
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
I maintainer di solito rispondono entro 1 giorno
-
[Bug]: SnowflakeGenerator passes arguments in wrong order to ISequence, causing duplicate IDs in Nextcloud 35Forse già presa @backportbot l’ha presa 10 giorni fa. Aperta0. Needs triage 35-feedback bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
nextcloud/server#65434 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
0. Needs triage 35-feedback bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
I maintainer di solito rispondono entro 1 giorno
-
34-feedback
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
I maintainer di solito rispondono entro 1 giorno
-
Add a default limit to the results of the `occ taskprocessing:list` commandForse già presa @Sahas2711 l’ha presa 14 giorni fa. Apertaenhancement feature: TaskProcessing good first issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
nextcloud/server#65243 · 1 reazione ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di nextcloud/server
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 64/100
WINBIGFOX/TimeScribe#143 ·
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
I maintainer di solito rispondono entro 3 giorni
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 66/100
verbb/formie#3045 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100