Make WordPress Core

Changeset 61089


Ignore:
Timestamp:
10/30/2025 11:54:22 AM (7 weeks ago)
Author:
wildworks
Message:

Editor: Add auth_callback to _wp_note_status comment meta.

Adds an auth_callback to the _wp_note_status comment meta so that only users with the edit_comment capability can update this meta field via the REST API.

This is necessary to ensure that users can properly resolve or reopen Notes.

Props wildworks, adamsilverstein, westonruter, mamaduka, desrosj.
Fixes #64153.

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/comment.php

    r61036 r61089  
    41304130                ),
    41314131            ),
     4132            'auth_callback' => function ( $allowed, $meta_key, $object_id ) {
     4133                return current_user_can( 'edit_comment', $object_id );
     4134            },
    41324135        )
    41334136    );
    41344137}
    4135 add_action( 'init', 'wp_create_initial_comment_meta' );
  • trunk/src/wp-includes/default-filters.php

    r61088 r61089  
    152152add_action( 'updated_comment_meta', 'wp_cache_set_comments_last_changed' );
    153153add_action( 'deleted_comment_meta', 'wp_cache_set_comments_last_changed' );
     154add_action( 'init', 'wp_create_initial_comment_meta' );
    154155
    155156// Places to balance tags on input.
  • trunk/tests/phpunit/tests/rest-api/rest-comments-controller.php

    r60987 r61089  
    171171        parent::set_up();
    172172        $this->endpoint = new WP_REST_Comments_Controller();
     173        wp_create_initial_comment_meta();
     174
    173175        if ( is_multisite() ) {
    174176            update_site_option( 'site_admins', array( 'superadmin' ) );
     
    38893891        $response = rest_get_server()->dispatch( $request );
    38903892        $this->assertSame( 201, $response->get_status() );
     3893
     3894        $data = $response->get_data();
     3895        $this->assertArrayHasKey( 'meta', $data );
     3896        $this->assertArrayHasKey( '_wp_note_status', $data['meta'] );
     3897        $this->assertSame( $status, $data['meta']['_wp_note_status'] );
    38913898    }
    38923899
Note: See TracChangeset for help on using the changeset viewer.