mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-16 23:00:21 +00:00
REST API: Ensure attachments created with WP_REST_Attachments_Controller::create_item() on Windows have a relative path.
Props ocean90, SergeyBiryukov, redcastor. Fixes #40861. git-svn-id: https://develop.svn.wordpress.org/trunk@43529 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -136,7 +136,6 @@ class WP_REST_Attachments_Controller extends WP_REST_Posts_Controller {
|
||||
}
|
||||
|
||||
$attachment = $this->prepare_item_for_database( $request );
|
||||
$attachment->file = $file;
|
||||
$attachment->post_mime_type = $type;
|
||||
$attachment->guid = $url;
|
||||
|
||||
@@ -144,7 +143,8 @@ class WP_REST_Attachments_Controller extends WP_REST_Posts_Controller {
|
||||
$attachment->post_title = preg_replace( '/\.[^.]+$/', '', basename( $file ) );
|
||||
}
|
||||
|
||||
$id = wp_insert_post( wp_slash( (array) $attachment ), true );
|
||||
// $post_parent is inherited from $attachment['post_parent'].
|
||||
$id = wp_insert_attachment( wp_slash( (array) $attachment ), $file, 0, true );
|
||||
|
||||
if ( is_wp_error( $id ) ) {
|
||||
if ( 'db_update_error' === $id->get_error_code() ) {
|
||||
|
||||
Reference in New Issue
Block a user