[v4] A scheduled unpublish only unpublishes the default locale when `_status` is localized

Aperta
#19,674 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@lazerg ci sta già lavorando.

Dal 17/11/2026.

  • #19679 di @lazerg — aperta

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
25/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Ferma
Stack tecnologico
next.js, typescript
Ambito
backend, database

Direzione di ricerca

Start with packages/payload/src/versions/schedule/job.ts, especially the schedulePublish task and its update and updateGlobal calls. The issue reports that scheduled unpublishing leaves non-default locales published when _status is localized. Check how locale-wide publish options are passed through those calls; done means the reproduction ends with both en and de in draft. An open linked pull request (#19679) is already addressing this issue.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

area: core Bug Payload OSS
Describe the Bug

v4 turns on localizeStatus for collections with drafts and localized fields, so _status is stored per locale. A scheduled unpublish of such a document only unpublishes the default locale. Every other locale stays published.

The schedule drawer shows its locale picker only for publishing (picker, locale), so an unpublish is always queued without a locale. The schedulePublish task reads a missing locale as "all locales", but passes that on only when publishing: it sets publishAllLocales: _status === 'published' && isPublishAllLocales and never unpublishAllLocales. The update then acts on the default locale only.

Suggested fix (we run this as a patch on beta.9): pass unpublishAllLocales: _status === 'draft' && isPublishAllLocales next to publishAllLocales, in both the update and the updateGlobal call. With it, the reproduction below ends with both locales in draft.

Link to the code that reproduces this issue

https://github.com/fabian-michael-asi/payload-v4-issue-repros

Reproduction Steps
  1. Clone, cp .env.example .env (set DATABASE_URL and PAYLOAD_SECRET), pnpm install.
  2. Publish a post in both locales, queue the unpublish the way the schedule drawer does, and run it (section 5 of the README):
ID=$(pnpm -s payload createDocuments --slug posts --draft --locale en --documents '[{"data":{"title":"Hello"}}]' --json | jq -r '.result.docs[0].id')
pnpm payload updateDocument --slug posts --id "$ID" --locale de --draft --data '{"title":"Hallo"}'
pnpm payload updateDocument --slug posts --id "$ID" --locale en --publish-all-locales --data '{"_status":"published"}'
pnpm payload createDocuments --slug payload-jobs --documents "[{\"data\":{\"taskSlug\":\"schedulePublish\",\"input\":{\"type\":\"unpublish\",\"doc\":{\"relationTo\":\"posts\",\"value\":\"$ID\"}}}}]"
pnpm payload jobs:run
pnpm -s payload findDocuments --slug posts --id "$ID" --locale all --select '{"_status":true}' --json | jq -c '.result._status'
  1. The last command prints {"en":"draft","de":"published"}. Expected: {"en":"draft","de":"draft"}.
Which area(s) are affected?

area: core

Environment Info
Relevant Packages:
  payload: 4.0.0-beta.9
  next: 16.4.2
  @payloadcms/db-mongodb: 4.0.0-beta.9
  @payloadcms/richtext-lexical: 4.0.0-beta.9
  @payloadcms/ui/shared: 4.0.0-beta.9
  react: 19.3.1
Node: 24.22.2, pnpm: 12.18.0, darwin arm64
Lingua principale
TypeScript
Stelle
45.8k
Fork
4.4k
Merge medio
3g 4h
PR unite (30g)
210

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 payloadcms/payload

Tutte le issue di payloadcms/payload

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.