[wp-trac] [WordPress Trac] #48377: sql_mode ANSI is incompatible with WP in MySQL 5.7.5+

WordPress Trac noreply at wordpress.org
Mon Dec 20 09:08:27 UTC 2021


#48377: sql_mode ANSI is incompatible with WP in MySQL 5.7.5+
--------------------------+-----------------------------
 Reporter:  jnylen0       |       Owner:  SergeyBiryukov
     Type:  defect (bug)  |      Status:  closed
 Priority:  normal        |   Milestone:  5.4
Component:  Database      |     Version:
 Severity:  normal        |  Resolution:  fixed
 Keywords:                |     Focuses:
--------------------------+-----------------------------

Comment (by sumitjoshi):

 I found this code with my modification to take care of this error if you
 run into it.
 add_action( 'init', 'mysql_set_sql_mode_traditional', -1);
 function mysql_set_sql_mode_traditional() {
 global $wpdb;
 $wpdb->query("SET SESSION sql_mode = 'TRADITIONAL'");
 $wpdb->query("SET SESSION sql_mode = 'NO_ZERO_DATE'");
 $wpdb->query("SET SESSION sql_mode = 'NO_ZERO_IN_DATE'");
 }
 Add it into your function.php theme file or a file in mu-plugin

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


More information about the wp-trac mailing list