[wp-trac] [WordPress Trac] #15158: wpdb insert & update with null values

WordPress Trac wp-trac at lists.automattic.com
Tue Nov 2 06:10:08 UTC 2010


#15158: wpdb insert & update with null values
--------------------------+-------------------------------------------------
 Reporter:  westi         |       Owner:  sorich87                           
     Type:  defect (bug)  |      Status:  accepted                           
 Priority:  normal        |   Milestone:  3.1                                
Component:  Database      |     Version:  3.0.1                              
 Severity:  normal        |    Keywords:  has-patch needs-testing 2nd-opinion
--------------------------+-------------------------------------------------

Comment(by nacin):

 Code appears to act only on the value being === null. If someone is
 currently passing a value that may end up being null, but is actually
 passing this to %s or with the intention of it being handled by a zero-
 length string, then we'll get an off-by-one error. It's also difficult to
 follow -- the arrays for fields/values and formats should ideally be
 easier to match up from a code review perspective.

 This needs to be explicit, i.e. `array( 'field1' => '1', 'field2' => null,
 'field3' => 3 ), array( '%s', null, '%d' )`.

 Both NULL and 'null' as a case-insensitive string should probably be
 accepted as a format.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/15158#comment:6>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list