Ticket #32315: 32315.diff
File 32315.diff, 3.0 KB (added by , 7 years ago) |
---|
-
src/wp-includes/wp-db.php
1208 1208 * This method DOES NOT support sign, padding, alignment, width or precision specifiers. 1209 1209 * This method DOES NOT support argument numbering or swapping. 1210 1210 * 1211 * Arguments may be passed as individual arguments to the method, or as a single array containing all arguments. A combination 1211 * Arguments may be passed as individual arguments to the method, or as a single array containing all arguments. A combination 1212 1212 * of the two is not supported. 1213 1213 * 1214 1214 * Examples: … … 2064 2064 $conditions = implode( ' AND ', $conditions ); 2065 2065 2066 2066 $sql = "UPDATE `$table` SET $fields WHERE $conditions"; 2067 2067 2068 2068 $this->check_current_query = false; 2069 2069 return $this->query( $this->prepare( $sql, $values ) ); 2070 2070 } … … 2156 2156 $converted_data = $this->strip_invalid_text( $data ); 2157 2157 2158 2158 if ( $data !== $converted_data ) { 2159 $problem_fields = array(); 2160 2161 foreach ( $data as $field => $value ) { 2162 if ( $value !== $converted_data[ $field ] ) { 2163 $problem_fields[] = $field; 2164 } 2165 } 2166 2167 if ( count( $problem_fields ) === 1 ) { 2168 $message = __( 'WordPress Database Error: Processing the value for the following field failed, the supplied value may have been too long or contained invalid data: %s.' ); 2169 } else { 2170 $message = __( 'WordPress Database Error: Processing the values for the following fields failed, the supplied values may have been too long or contained invalid data: %s.' ); 2171 } 2172 2173 $this->last_error = sprintf( $message, implode( ', ', $problem_fields ) ); 2159 2174 return false; 2160 2175 } 2161 2176 -
tests/phpunit/tests/db.php
939 939 } 940 940 941 941 /** 942 * @ticket 32315 943 */ 944 function test_process_fields_too_long() { 945 946 global $wpdb; 947 948 $data = array( 'post_status' => str_repeat( 'a', 21 ) ); 949 950 $this->assertFalse( self::$_wpdb->process_fields( $wpdb->posts, $data, null ) ); 951 $this->assertSame( 952 'WordPress Database Error: Processing the value for the following field failed, the supplied value may have been too long or contained invalid data: post_status.', 953 self::$_wpdb->last_error 954 ); 955 } 956 957 /** 958 * @ticket 32315 959 */ 960 function test_process_fields_too_long_multiple() { 961 962 global $wpdb; 963 964 $data = array( 965 'post_status' => str_repeat( 'a', 21 ), 966 'post_type' => str_repeat( 'a', 21 ), 967 ); 968 969 $this->assertFalse( self::$_wpdb->process_fields( $wpdb->posts, $data, null ) ); 970 $this->assertSame( 971 'WordPress Database Error: Processing the values for the following fields failed, the supplied values may have been too long or contained invalid data: post_status, post_type.', 972 self::$_wpdb->last_error 973 ); 974 } 975 976 /** 942 977 * @ticket 15158 943 978 */ 944 979 function test_null_insert() {