Skip to content

Consider removing the native media delete relay #860

Open

Description

@dcalhoun

What problem does this address?

#594 sends the media upload orphan cleanup (DELETE /wp/v2/media/<id>) through native code: the Android loopback upload server and the iOS upload scheme. It did so because a cross-origin editor couldn't send that request: api-fetch sends DELETE as a POST with X-HTTP-Method-Override, and the CORS preflight rejects that header.

#841 sends cross-origin writes with their real method, which the preflight allows. With that in place the relay may no longer be needed. Both native routes only forward the request; neither does any bookkeeping of its own.

What is your proposed solution?

Consider removing the relay and letting the editor send the deletion directly:

  • nativeMediaDelete in src/utils/api-fetch.js
  • The DELETE /media/<id> route in MediaUploadServer.kt
  • The …/media/<id>/delete route in MediaUploadSchemeHandler.swift. iOS deletions would go through the REST relay, as they already do after stopMediaHandling().
  • Their tests

To verify, use #594's media failure simulator to exhaust the post-process retries. Then check that the orphaned attachment is deleted on an Android site whose REST API is on another origin, on a same-origin Android site, and on iOS.

Depends on #841.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    [Type] Code QualityIssues or PRs that relate to code quality

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions