Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

`OutOfOfficeEventDispatcherJob` is not cleaned up correctly

Aperta Adatta ai principianti
#65,797 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

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
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
php
Ambito
backend

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

1. to develop bug
⚠️ 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.

  1. Clearing an absence cancels the pending jobs of all users
  2. 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

  1. As user alice, set an absence in Personal settings → Availability with a first day in the future, and save.
  2. Confirm two jobs exist for it:
    SELECT id, argument, last_checked FROM oc_jobs WHERE class = 'OCA\\DAV\\BackgroundJob\\OutOfOfficeEventDispatcherJob';
  3. As user bob, set any absence and save, then click "Disable absence".
  4. Run the query from step 2 again: no jobs are left, and alice's start and end jobs are gone too.

Problem 2

  1. As user alice, set an absence from next Monday to next Friday and save.
  2. Confirm the start job for that absence id is scheduled for next Monday 00:00 (user timezone).
  3. Edit the absence so the first day is today, and save.
  4. Run the query again: the start job is still scheduled for next Monday.
  5. Next Monday, the job runs and dispatches OutOfOfficeStartedEvent for 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(): the remove() 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_START and EVENT_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.php for both cases.
Lingua principale
PHP
Stelle
37.2k
Fork
5.3k
Merge medio
2g 5h
PR unite (30g)
666

Preparare l'ambiente

Apri in Codespaces

Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di nextcloud/server

Tutte le issue di nextcloud/server

Issue simili

Altre issue su PHP

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.