[wp-trac] [WordPress Trac] #43589: WPDB Update change NULL values to acceptable values

WordPress Trac noreply at wordpress.org
Sun Mar 25 17:08:13 UTC 2018


#43589: WPDB Update change NULL values to acceptable values
------------------------------------------+------------------------------
 Reporter:  dorianrd                      |       Owner:
     Type:  defect (bug)                  |      Status:  new
 Priority:  normal                        |   Milestone:  Awaiting Review
Component:  Database                      |     Version:  trunk
 Severity:  normal                        |  Resolution:
 Keywords:  needs-patch needs-unit-tests  |     Focuses:
------------------------------------------+------------------------------
Changes (by soulseekah):

 * keywords:  reporter-feedback => needs-patch needs-unit-tests


Comment:

 There actually seems to be a warning being thrown when trying to insert
 with a NULL value, or update with a NULL value in the `$where` parameters.

 {{{
 PHP Notice:  wpdb::prepare was called <strong>incorrectly</strong>. The
 query argument of wpdb::prepare() must have a placeholder. Please see <a
 href="https://codex.wordpress.org/Debugging_in_WordPress">Debugging in
 WordPress</a> for more information. (This message was added in version
 3.9.0.) in wp-includes/functions.php on line 4320
 }}}

 This is with columns that allow NULL to be inserted. Otherwise the rest of
 the behavior seems fine, or at least, yields the correct results.

 With columns where NULL is not allowed, inserting errors out as expected:

 {{{
 WordPress database error Column 'title' cannot be null for query INSERT
 INTO `test2` (`title`) VALUES (NULL)
 }}}

 Updating with a NULL, though, sends in a type-casted value, without
 throwing a database error. This bug is valid. Reproducible on trunk. While
 distantly related to #43578, this seems to stem from one of the internal
 methods in `process_fields`.

 I'd like to work on this. Thanks for the report.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/43589#comment:3>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list