File tree Expand file tree Collapse file tree 2 files changed +23
-2
lines changed
Expand file tree Collapse file tree 2 files changed +23
-2
lines changed Original file line number Diff line number Diff line change @@ -44,6 +44,17 @@ function sqlite_activation() {
4444}
4545add_action ( 'admin_init ' , 'sqlite_activation ' );
4646
47+ // Flush the cache at the last moment before the redirect.
48+ add_filter (
49+ 'x_redirect_by ' ,
50+ function ( $ result ) {
51+ wp_cache_flush ();
52+ return $ result ;
53+ },
54+ PHP_INT_MAX ,
55+ 1
56+ );
57+
4758/**
4859 * Add the db.php file in wp-content.
4960 *
Original file line number Diff line number Diff line change @@ -22,7 +22,12 @@ function sqlite_plugin_remove_db_file() {
2222
2323 // Init the filesystem if needed, then delete custom drop-in.
2424 if ( $ wp_filesystem || WP_Filesystem () ) {
25+ // Flush any persistent cache.
26+ wp_cache_flush ();
27+ // Delete the drop-in.
2528 $ wp_filesystem ->delete ( WP_CONTENT_DIR . '/db.php ' );
29+ // Flush the cache again to mitigate a possible race condition.
30+ wp_cache_flush ();
2631 }
2732
2833 // Run an action on `shutdown`, to deactivate the option in the MySQL database.
@@ -47,12 +52,17 @@ function() {
4752 $ value = maybe_unserialize ( $ row ->option_value );
4853 if ( is_array ( $ value ) ) {
4954 $ value_flipped = array_flip ( $ value );
50- unset( $ value_flipped [ str_replace ( WP_PLUGIN_DIR . '/ ' , '' , SQLITE_MAIN_FILE ) ] );
55+ $ items = array_reverse ( explode ( DIRECTORY_SEPARATOR , SQLITE_MAIN_FILE ) );
56+ $ item = $ items [1 ] . DIRECTORY_SEPARATOR . $ items [0 ];
57+ unset( $ value_flipped [ $ item ] );
5158 $ value = array_flip ( $ value_flipped );
5259 $ wpdb_mysql ->update ( $ wpdb_mysql ->options , array ( 'option_value ' => maybe_serialize ( $ value ) ), array ( 'option_name ' => 'active_plugins ' ) );
5360 }
5461 }
55- }
62+ },
63+ PHP_INT_MAX
5664 );
65+ // Flush any persistent cache.
66+ wp_cache_flush ();
5767}
5868register_deactivation_hook ( SQLITE_MAIN_FILE , 'sqlite_plugin_remove_db_file ' ); // Remove db.php file on plugin deactivation.
You can’t perform that action at this time.
0 commit comments