[wp-trac] [WordPress Trac] #32318: Upload fails, wp_insert_attachment returned 0
WordPress Trac
noreply at wordpress.org
Fri May 8 22:34:12 UTC 2015
#32318: Upload fails, wp_insert_attachment returned 0
--------------------------+-----------------------------
Reporter: programmin | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Upload | Version: 4.1.5
Severity: normal | Keywords:
Focuses: |
--------------------------+-----------------------------
One specific mp3 file was failing to attach, and it seems
wp_insert_attachment is breaking with 0 returned, breaking update-
attachment-metadata:
wp-admin/includes/media.php, line 360:
{{{
// Save the data
$id = wp_insert_attachment($attachment, $file, $post_id);
if ( !is_wp_error($id) ) {
wp_update_attachment_metadata( $id,
wp_generate_attachment_metadata( $id, $file ) );
}
}}}
id = 0, caused by these lines in wp-includes/post.php, around line 3351:
{{{
if ( false === $wpdb->insert( $wpdb->posts, $data ) ) {
if ( $wp_error ) {
return new WP_Error('db_insert_error', __('Could not
insert post into the database'), $wpdb->last_error);
} else {
return 0;
}
}
}}}
In this case the documentation is wrong, it didn't return the post id.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/32318>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list