Opened 9 years ago
Closed 9 years ago
#34703 closed defect (bug) (invalid)
wp_db->strip_invalid_text problem with NULL varchar(2) fields
Reported by: | TiagoGouvea | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 4.2.4 |
Component: | Database | Keywords: | reporter-feedback |
Focuses: | Cc: |
Description
When I tried to save a record the udpdate fails and looking for the problem I found a possible error in wp_db.
In block :
"$converted_data = $this->strip_invalid_text( $data );
if ( $data !== $converted_data ) {"
If always return false to me, looking closer on strip_invalid_text method, I saw that a field seen to be different in that arrays. The field have null value but, it show value in the $data array as 'NU', because the field are a varchar(2), and then, it consider $data!=$converted_data, when it's not.
- I'm updating another field, but the query include the null field on the update again. I'm not changig that field value.
Change History (3)
#3
@
9 years ago
- Milestone Awaiting Review deleted
- Resolution set to invalid
- Status changed from new to closed
Discussion happened in another ticket - https://core.trac.wordpress.org/ticket/34482#comment:6
@TiagoGouvea was passing a string to $wpdb->update()
and then was filtering the query later to force 'NULL'
to NULL
.
@TiagoGouvea That's just not supported, and won't be in any way. In WordPress 4.4+ passing a literal NULL
does work. If you need to support older versions, don't use $wpdb->update()
and instead do $wpdb->update( "UPDATE .. SET field = NULL" );
.
Thank you for the bug report, @TiagoGouvea!
Could you provide a test case that I can use to reproduce this behaviour?