Opened 9 years ago
Last modified 5 years ago
#35256 reopened defect (bug)
$wpdb->insert_id equals 0
Reported by: | anonymized_10765487 | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 4.2.4 |
Component: | Database | Keywords: | |
Focuses: | Cc: |
Description
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