Changes between Initial Version and Version 1 of Ticket #32315, comment 17
- Timestamp:
- 11/01/2016 12:45:47 AM (8 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #32315, comment 17
initial v1 1 1 I`ve been looking into this over the weekend and found the following: 2 2 3 When you call the insert() or update() routine in wpdb, it's calling process_fields().3 When you call the `insert()` or `update()` routine in wpdb, it's calling `process_fields()`. 4 4 5 Inside of process_fields(), it calls strip_invalid_text()which removes invalid characters, and also truncates the data to the field length.5 Inside of `process_fields()`, it calls `strip_invalid_text()` which removes invalid characters, and also truncates the data to the field length. 6 6 7 When strip_invalid_text() returns the amended $data, the following code is run:7 When `strip_invalid_text()` returns the amended `$data`, the following code is run: 8 8 9 9 {{{ … … 13 13 }}} 14 14 15 This compares the original $data with the $converted_data returned from the strip_invalid_text() function, and if anything has been changed it returns false.15 This compares the original `$data` with the `$converted_data` returned from the `strip_invalid_text()` function, and if anything has been changed it returns `false`. 16 16 17 17 This stops the operation from occuring, without an error message. So if any invalid characters are removed, or the field is truncated, everything stops. … … 21 21 >>You realize how much extra code an insert would require if you error? Every insert var would have to be checked for length prior to insert. 22 22 23 This is already happening, each insert var string passes through process_field_lengths which gets the size of the database field. strip_invalid_text()then uses this to truncate the field if necessary.23 This is already happening, each insert var string passes through `process_field_lengths()` which gets the size of the database field. `strip_invalid_text()` then uses this to truncate the field if necessary. 24 24 25 I `m not not sure of the best way to handle this. It would be possible to run through the $data array and compare it to the $converted_data array returned from strip_invalid_text(), which would allow a list of any fields with data thats been changed. But what would be the best way to display this information to the user?25 I'm not not sure of the best way to handle this. It would be possible to run through the `$data` array and compare it to the `$converted_data array` returned from `strip_invalid_text()`, which would allow a list of any fields with data that's been changed. But what would be the best way to display this information to the user? 26 26 27 27 Would it be worth creating a variable to hold internal errors, for errors in functions that occur before a database operation?