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

Đang mở
#845 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
70/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
javascript, wordpress
Lĩnh vực
backend

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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

Ngôn ngữ chính
JavaScript
Star
29
Fork
6
Merge trung bình
2 ngày 1 giờ
Pull request đã merge (30 ngày)
76

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của wordpress-mobile/GutenbergKit

Tất cả issue của wordpress-mobile/GutenbergKit

Issue tương tự

Thêm issue về JavaScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.