Ticket #15158: 15158.diff
| File 15158.diff, 2.0 KB (added by sorich87, 3 years ago) |
|---|
-
wp-includes/wp-db.php
1197 1197 $formats = $format = (array) $format; 1198 1198 $fields = array_keys( $data ); 1199 1199 $formatted_fields = array(); 1200 $real_data = array(); 1200 1201 foreach ( $fields as $field ) { 1202 if ( $data[$field] === null ) { 1203 $formatted_fields[] = 'NULL'; 1204 array_shift( $formats ); 1205 continue; 1206 } 1201 1207 if ( !empty( $format ) ) 1202 1208 $form = ( $form = array_shift( $formats ) ) ? $form : $format[0]; 1203 1209 elseif ( isset( $this->field_types[$field] ) ) … … 1205 1211 else 1206 1212 $form = '%s'; 1207 1213 $formatted_fields[] = $form; 1214 $real_data[] = $data[$field]; 1208 1215 } 1209 1216 $sql = "{$type} INTO `$table` (`" . implode( '`,`', $fields ) . "`) VALUES ('" . implode( "','", $formatted_fields ) . "')"; 1210 return $this->query( $this->prepare( $sql, $ data ) );1217 return $this->query( $this->prepare( $sql, $real_data ) ); 1211 1218 } 1212 1219 1213 1220 /** … … 1237 1244 1238 1245 $formats = $format = (array) $format; 1239 1246 $bits = $wheres = array(); 1247 $real_data = array(); 1240 1248 foreach ( (array) array_keys( $data ) as $field ) { 1249 if ( $data[$field] === null ) { 1250 $bits[] = "`$field` = NULL"; 1251 array_shift( $formats ); 1252 continue; 1253 } 1241 1254 if ( !empty( $format ) ) 1242 1255 $form = ( $form = array_shift( $formats ) ) ? $form : $format[0]; 1243 1256 elseif ( isset($this->field_types[$field]) ) … … 1245 1258 else 1246 1259 $form = '%s'; 1247 1260 $bits[] = "`$field` = {$form}"; 1261 $real_data[] = $data[$field]; 1248 1262 } 1249 1263 1250 1264 $where_formats = $where_format = (array) $where_format; … … 1259 1273 } 1260 1274 1261 1275 $sql = "UPDATE `$table` SET " . implode( ', ', $bits ) . ' WHERE ' . implode( ' AND ', $wheres ); 1262 return $this->query( $this->prepare( $sql, array_merge( array_values( $ data ), array_values( $where ) ) ) );1276 return $this->query( $this->prepare( $sql, array_merge( array_values( $real_data ), array_values( $where ) ) ) ); 1263 1277 } 1264 1278 1265 1279 /**
