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

Abierto
#845 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
70/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
javascript, wordpress
Área
backend

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

[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.

Lenguaje dominante
JavaScript
Estrellas
29
Forks
6
Merge medio
2 d 1 h
PR fusionados (30 d)
76

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de wordpress-mobile/GutenbergKit

Todos los issues de wordpress-mobile/GutenbergKit

Issues similares

Más issues de JavaScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.