Make wp_insert_attachment() MySQL 5 strict mode compliant. fixes #2115

git-svn-id: http://svn.automattic.com/wordpress/trunk@3353 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2005-12-24 05:32:49 +00:00
parent 5df9400ad9
commit d0ff0c9315
1 changed files with 11 additions and 2 deletions

View File

@ -283,6 +283,14 @@ function wp_insert_attachment($object, $file = false, $post_parent = 0) {
if ( !isset($post_password) ) if ( !isset($post_password) )
$post_password = ''; $post_password = '';
if ( isset($to_ping) )
$to_ping = preg_replace('|\s+|', "\n", $to_ping);
else
$to_ping = '';
if ( ! isset($pinged) )
$pinged = '';
if ($update) { if ($update) {
$wpdb->query( $wpdb->query(
"UPDATE $wpdb->posts SET "UPDATE $wpdb->posts SET
@ -298,6 +306,7 @@ function wp_insert_attachment($object, $file = false, $post_parent = 0) {
post_password = '$post_password', post_password = '$post_password',
post_name = '$post_name', post_name = '$post_name',
to_ping = '$to_ping', to_ping = '$to_ping',
pinged = '$pinged',
post_modified = '$post_date', post_modified = '$post_date',
post_modified_gmt = '$post_date_gmt', post_modified_gmt = '$post_date_gmt',
post_parent = '$post_parent', post_parent = '$post_parent',
@ -308,9 +317,9 @@ function wp_insert_attachment($object, $file = false, $post_parent = 0) {
} else { } else {
$wpdb->query( $wpdb->query(
"INSERT INTO $wpdb->posts "INSERT INTO $wpdb->posts
(post_author, post_date, post_date_gmt, post_content, post_title, post_excerpt, post_status, comment_status, ping_status, post_password, post_name, to_ping, post_modified, post_modified_gmt, post_parent, menu_order, post_mime_type, guid) (post_author, post_date, post_date_gmt, post_content, post_title, post_excerpt, post_status, comment_status, ping_status, post_password, post_name, to_ping, pinged, post_modified, post_modified_gmt, post_parent, menu_order, post_mime_type, guid)
VALUES VALUES
('$post_author', '$post_date', '$post_date_gmt', '$post_content', '$post_title', '$post_excerpt', '$post_status', '$comment_status', '$ping_status', '$post_password', '$post_name', '$to_ping', '$post_date', '$post_date_gmt', '$post_parent', '$menu_order', '$post_mime_type', '$guid')"); ('$post_author', '$post_date', '$post_date_gmt', '$post_content', '$post_title', '$post_excerpt', '$post_status', '$comment_status', '$ping_status', '$post_password', '$post_name', '$to_ping', '$pinged', '$post_date', '$post_date_gmt', '$post_parent', '$menu_order', '$post_mime_type', '$guid')");
$post_ID = $wpdb->insert_id; $post_ID = $wpdb->insert_id;
} }