Make WordPress Core

Opened 8 years ago

Closed 8 years ago

Last modified 6 months ago

#45194 closed enhancement (fixed)

[Gutenberg] Preload wp/v2/media using the OPTIONS method to manage `upload_files` capability

Reported by: imath Owned by: danielbachhuber
Priority: normal Milestone: 5.0
Component: Editor Version: 5.0
Severity: normal Keywords: has-patch has-unit-tests fixed-5.0
Cc: Focuses: rest-api

Description

Hi.

As @aduth explained in this ​PR, it will be needed to update preloaded paths so that they include the wp/v2/media endpoint (using the OPTIONS method). This way of checking the upload_files caps using the Allow header of the result of the endpoint request has been advised by @danielbachhuber.

The Media blocks UI/Featured image section of the document sidebar when the user has the contributor role should be improved.

As this role cannot upload_files the Upload / Drag and drop controls & the Media Library shouldn't be available.

The attached patch makes sure it's possible to preload this specific path using the OPTIONS method without editing the other paths (eg: grouping them into a GET array attribute)

Attachments (2)

45194.patch​ (2.8 KB ) - added by imath 8 years ago.
45194.2.diff​ (3.3 KB ) - added by danielbachhuber 8 years ago.

Download all attachments as: .zip

Change History (11)

This ticket was mentioned in ​Slack in #core-restapi by danielbachhuber. ​View the logs.


8 years ago

#2 @pento
8 years ago

  • Milestone Awaiting Review → 5.0

#3 @danielbachhuber
8 years ago

  • Keywords has-unit-tests added
  • Type defect (bug) → enhancement

#4 @danielbachhuber
8 years ago

In 45194.2.diff:

  • Apply a block_editor_preload_paths filter to allow plugins / themes to preload additional paths.
  • Enforce strict format of $path with is_array( $path ) && 2 === count( $path ).

#5 @danielbachhuber
8 years ago

  • Owner set to danielbachhuber
  • Resolution → fixed
  • Status new → closed

In 43833:

Block Editor: Preload wp/v2/media with OPTIONS for caps check.

Also introduces a block_editor_preload_paths filter for plugins and themes to preload additional data.

Props imath, mattheu.
Fixes #45194.

#6 @danielbachhuber
8 years ago

  • Keywords fixed-5.0 added
  • Resolution fixed
  • Status closed → reopened

#7 @danielbachhuber
8 years ago

Reopened for merge to trunk.

#8 @pento
8 years ago

  • Resolution → fixed
  • Status reopened → closed

In 44172:

Block Editor: Preload wp/v2/media with OPTIONS for caps check.

Also introduces a block_editor_preload_paths filter for plugins and themes to preload additional data.

Merges [43833] from the 5.0 branch to trunk.

Props imath, mattheu, danielbachhuber.
Fixes #45194.

#9 @westonruter
6 months ago

Follow-up: #65215, which goes beyond allowing the method to be specified to also allow non-OK responses to be sent to the preload middleware.

Note: See TracTickets for help on using tickets.