[wp-trac] [WordPress Trac] #32315: $wpdb->insert fails without error msg

WordPress Trac noreply at wordpress.org
Tue Nov 1 03:22:21 UTC 2016


#32315: $wpdb->insert fails without error msg
------------------------------------------+------------------------------
 Reporter:  dlt101                        |       Owner:
     Type:  defect (bug)                  |      Status:  reopened
 Priority:  normal                        |   Milestone:  Awaiting Review
Component:  Database                      |     Version:
 Severity:  normal                        |  Resolution:
 Keywords:  needs-patch needs-unit-tests  |     Focuses:
------------------------------------------+------------------------------

Comment (by mnelson4):

 thanks for the reply @dd32; ya putting error in `$wpdb->last_error` would
 be conveniently simple for client code.

 Now what about `$wpdb->last_query`: should something be put in there when
 this error occurs? No query is ran, and the SQL statement doesn't even get
 generated. But I suspect most folks will still want to check it to see
 what went wrong with their insert or update query.

 So when this error occurs, should we finish generating the SQL, put it in
 `$wpdb->last_query` etc, but not run the query? (I think this would be the
 most helpful to folks, but it might be confusing for someone reading the
 code that we detect a error but wait to abort the process.) Or should
 `$wpdb->last_query` be set to a empty string (indicating no query ran)? or
 should it be set to some sort of descriptive phrase like "WordPress was
 about to insert values(x, y, z) into columns (w,v,r), but column 't' was
 too small" (this has the advantage of allowing us to abort the execution
 right away, but we're not creating actual SQL like we normally would)?

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


More information about the wp-trac mailing list