Make WordPress Core

Opened 6 years ago

Closed 6 years ago

#45194 closed enhancement (fixed)

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

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

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 6 years ago.
45194.2.diff (3.3 KB) - added by danielbachhuber 6 years ago.

Download all attachments as: .zip

Change History (10)

@imath
6 years ago

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


6 years ago

#2 @pento
6 years ago

  • Milestone changed from Awaiting Review to 5.0

#3 @danielbachhuber
6 years ago

  • Keywords has-unit-tests added
  • Type changed from defect (bug) to enhancement

#4 @danielbachhuber
6 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
6 years ago

  • Owner set to danielbachhuber
  • Resolution set to fixed
  • Status changed from new to 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
6 years ago

  • Keywords fixed-5.0 added
  • Resolution fixed deleted
  • Status changed from closed to reopened

#7 @danielbachhuber
6 years ago

Reopened for merge to trunk.

#8 @pento
6 years ago

  • Resolution set to fixed
  • Status changed from reopened to 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.

Note: See TracTickets for help on using tickets.