WordPress.org

Make WordPress Core


Ignore:
Timestamp:
07/24/2018 04:51:09 PM (18 months ago)
Author:
SergeyBiryukov
Message:

REST API: Ensure attachments created with WP_REST_Attachments_Controller::create_item() on Windows have a relative path.

Props ocean90, SergeyBiryukov, redcastor.
Fixes #40861.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/rest-api/rest-attachments-controller.php

    r43462 r43529  
    772772        $attachment = $response->get_data();
    773773        $this->assertEquals( '', $attachment['alt_text'] );
     774    }
     775
     776    /**
     777     * @ticket 40861
     778     */
     779    public function test_create_item_ensure_relative_path() {
     780        wp_set_current_user( self::$author_id );
     781        $request = new WP_REST_Request( 'POST', '/wp/v2/media' );
     782        $request->set_header( 'Content-Type', 'image/jpeg' );
     783        $request->set_header( 'Content-Disposition', 'attachment; filename=canola.jpg' );
     784        $request->set_body( file_get_contents( $this->test_file ) );
     785        $response   = rest_get_server()->dispatch( $request );
     786        $attachment = $response->get_data();
     787        $this->assertNotContains( ABSPATH, get_post_meta( $attachment['id'], '_wp_attached_file', true ) );
    774788    }
    775789
Note: See TracChangeset for help on using the changeset viewer.