WordPress.org

Make WordPress Core

Opened 2 years ago

Last modified 23 months ago

#35256 reopened defect (bug)

$wpdb->insert_id equals 0

Reported by: jmlapam Owned by:
Milestone: Awaiting Review 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

Change History (2)

#1 @jmlapam
23 months ago

  • Resolution set to wontfix
  • Status changed from new to closed

#2 @DrewAPicture
23 months ago

  • Resolution wontfix deleted
  • Status changed from closed to reopened
Note: See TracTickets for help on using tickets.