Make WordPress Core


Ignore:
Timestamp:
09/30/2025 03:49:18 PM (4 months ago)
Author:
johnbillion
Message:

REST API: Increase the specificity of capability checks for collections when the edit context is in use.

The edit access in now taken into account for each individual post, term, or user in the response.

Props andraganescu, desrosj, ehti, hurayraiit, iandunn, joehoyle, johnbillion, jorbin, mnelson4, noisysocks, peterwilsoncc, rmccue, timothyblynjacobs, vortfu, whyisjake, zieladam.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php

    r60197 r60814  
    464464
    465465            foreach ( $query_result as $post ) {
    466                 if ( ! $this->check_read_permission( $post ) ) {
     466                if ( 'edit' === $request['context'] ) {
     467                    $permission = $this->check_update_permission( $post );
     468                } else {
     469                    $permission = $this->check_read_permission( $post );
     470                }
     471
     472                if ( ! $permission ) {
    467473                    continue;
    468474                }
Note: See TracChangeset for help on using the changeset viewer.