[wp-trac] [WordPress Trac] #23064: support str_to_date on $wpdb->prepare

WordPress Trac noreply at wordpress.org
Fri Dec 28 05:25:06 UTC 2012

#23064: support str_to_date on $wpdb->prepare
 Reporter:  jperelli                  |       Owner:
     Type:  defect (bug)              |      Status:  closed
 Priority:  normal                    |   Milestone:
Component:  Database                  |     Version:  3.4.2
 Severity:  normal                    |  Resolution:  invalid
 Keywords:  needs-patch dev-feedback  |
Changes (by dd32):

 * status:  new => closed
 * resolution:   => invalid
 * milestone:  Awaiting Review =>


 The issue isn't that STR_TO_DATE is present, but because STR_TO_DATE()
 uses the same place holder syntax that wpdb::prepare() uses.

 You'll need to escape the %'s in the call as such for it to pass through
 $wpdb->prepare("select STR_TO_DATE('200442 Monday', '%%X%%V %%W');")
 $wpdb->prepare("select STR_TO_DATE('200442 Monday', %s);", '%X%V %W' )

 However, wpdb::prepare() should NOT be called with only a SQL string, it's
 only designed for inserting parameters into the string, See this post for
 details: http://make.wordpress.org/core/2012/12/12/php-warning-missing-

Ticket URL: <http://core.trac.wordpress.org/ticket/23064#comment:1>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software

More information about the wp-trac mailing list