[wp-trac] [WordPress Trac] #35256: $wpdb->insert_id equals 0

WordPress Trac noreply at wordpress.org
Tue Dec 29 19:54:41 UTC 2015


#35256: $wpdb->insert_id equals 0
--------------------------+-----------------------------
 Reporter:  jmlapam       |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Database      |    Version:  4.2.4
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 Hi, reading this https://make.wordpress.org/core/2015/04/02/the-
 utf8mb4-upgrade/

 Ok then cool.

 But I've had this weird bug with the table posts : collation utf8_mb4 was
 not set properly for this table (I do not really know why). As a result
 everytime `$wpdb->insert_id` was used it just inserted posts with ID `0` !

 For example, each upload just failed and because an AJAX grid layout is
 used in admin (media library page) it just failed to load anything !

 Took me some time to realize this was related to a database issue and not
 my php code that uses `wp_insert_post()`.

 My question is : would it be safer to prevent WordPress from inserting
 posts with ID `0` in any case ? I'm refering to this line
 https://core.trac.wordpress.org/browser/tags/4.4/src/wp-
 includes/post.php#L2926

--
Ticket URL: <https://core.trac.wordpress.org/ticket/35256>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list