[wp-trac] [WordPress Trac] #57385: Disable foreign key checks when dropping tables inside wp_uninitialize_site() function

WordPress Trac noreply at wordpress.org
Fri Jan 12 18:07:05 UTC 2024


#57385: Disable foreign key checks when dropping tables inside
wp_uninitialize_site() function
-------------------------------------------------+-------------------------
 Reporter:  naveen17797                          |       Owner:
                                                 |  johnjamesjacoby
     Type:  defect (bug)                         |      Status:  accepted
 Priority:  normal                               |   Milestone:  Awaiting
                                                 |  Review
Component:  Database                             |     Version:
 Severity:  normal                               |  Resolution:
 Keywords:  dev-feedback has-patch changes-      |     Focuses:  multisite
  requested                                      |
-------------------------------------------------+-------------------------

Comment (by spacedmonkey):

 @naveen17797 As work around could you use the `wpmu_drop_tables` and
 `wpmu_delete_blog_upload_dir` filters.

 {{{#!php
 add_filter( 'wpmu_drop_tables', function( $tables ){
   global $wpdb;
   $wpdb->query( 'SET foreign_key_checks = 0' );
   return $tables;
 });
 add_filter('wpmu_delete_blog_upload_dir', function( $basedir ){
   global $wpdb;
   $wpdb->query( 'SET foreign_key_checks = 1' );
   return $basedir;
 });
 }}}

 If this code was added to an mu-plugin or network activated plugin, then
 it would mean you don't want to wait for this code patch.

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


More information about the wp-trac mailing list