WordPress.org

Make WordPress Core


Ignore:
Timestamp:
07/24/2018 04:53:17 PM (2 years 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.
Merges [43529] to the 4.9 branch.
Fixes #40861.

Location:
branches/4.9
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/4.9

  • branches/4.9/src/wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php

    r43489 r43530  
    137137
    138138        $attachment = $this->prepare_item_for_database( $request );
    139         $attachment->file = $file;
    140139        $attachment->post_mime_type = $type;
    141140        $attachment->guid = $url;
     
    145144        }
    146145
    147         $id = wp_insert_post( wp_slash( (array) $attachment ), true );
     146        // $post_parent is inherited from $attachment['post_parent'].
     147        $id = wp_insert_attachment( wp_slash( (array) $attachment ), $file, 0, true );
    148148
    149149        if ( is_wp_error( $id ) ) {
Note: See TracChangeset for help on using the changeset viewer.