Lowercase `post` media uploads skip the draft post ID strip

Aperta
#845 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à
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
70/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
javascript, wordpress
Ambito
backend

Direzione di ricerca

Read src/utils/api-fetch.js and trace middleware registration order, especially stripDraftPostIdMiddleware and the wrapper around core's mediaUploadMiddleware. Check the existing tests for api-fetch middleware behavior, then verify that lowercase method: 'post' is uppercased before the draft ID is stripped and that the wrapper's duplicate conversion can be removed. Done means the request no longer sends post=-1.

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

Descrizione

[Type] Bug

A media upload sent with a lowercase method: 'post' keeps the placeholder post=-1 field. stripDraftPostIdMiddleware is meant to remove it before the request reaches WordPress.

Follow-up from #594. The behavior is the same on trunk, so it wasn't introduced there.

What happens

stripDraftPostIdMiddleware in src/utils/api-fetch.js only acts when options.method === 'POST'. A plugin calling apiFetch( { path: '/wp/v2/media', method: 'post', body } ) skips it, and WordPress receives post=-1.

Gutenberg's own uploads send POST, so this only affects third-party code.

Suggested fix

Uppercase options.method in a small middleware registered so it runs before every other GutenbergKit middleware. #594 already uppercases the method inside its wrapper around core's mediaUploadMiddleware (fcf8f0300), but that wrapper runs after stripDraftPostIdMiddleware. Moving the uppercasing up would cover both, and the wrapper's copy could then be removed.

fetch uppercases the standard methods itself, so nothing further down sees a difference.

Lingua principale
JavaScript
Stelle
29
Fork
6
Merge medio
2g 1h
PR unite (30g)
76

Preparare l'ambiente

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 wordpress-mobile/GutenbergKit

Tutte le issue di wordpress-mobile/GutenbergKit

Issue simili

Altre issue su JavaScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.