WordPress.org

Make WordPress Core

Ticket #44750: 44570.patch

File 44570.patch, 1.6 KB (added by TimothyBlynJacobs, 2 years ago)
  • src/wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php

    diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php
    index 90ab518..2a216d0 100644
    a b class WP_REST_Attachments_Controller extends WP_REST_Posts_Controller { 
    372372
    373373                // Wrap the data in a response object.
    374374                $response = rest_ensure_response( $data );
    375                 $response->add_links( $links );
     375
     376                foreach ( $links as $rel => $rel_links ) {
     377                        foreach ( $rel_links as $link ) {
     378                                $response->add_link( $rel, $link['href'], $link['attributes'] );
     379                        }
     380                }
    376381
    377382                /**
    378383                 * Filters an attachment returned from the REST API.
  • tests/phpunit/tests/rest-api/rest-attachments-controller.php

    diff --git a/tests/phpunit/tests/rest-api/rest-attachments-controller.php b/tests/phpunit/tests/rest-api/rest-attachments-controller.php
    index 79c76a6..174a7fa 100644
    a b class WP_Test_REST_Attachments_Controller extends WP_Test_REST_Post_Type_Control 
    13781378                $links    = $response->get_links();
    13791379
    13801380                $this->assertArrayHasKey( 'self', $links );
     1381                $this->assertArrayHasKey( 'author', $links );
     1382
     1383                $this->assertCount( 1, $links['author'] );
     1384                $this->assertArrayHasKey( 'embeddable', $links['author'][0] );
     1385                $this->assertTrue( $links['author'][0]['embeddable'] );
    13811386        }
    13821387
    13831388        public function test_publish_action_ldo_not_registered() {