From b3f5181415871e2c747b2d687bd70d7365e30b12 Mon Sep 17 00:00:00 2001 From: Shane Bishop Date: Tue, 11 Feb 2025 14:15:04 -0700 Subject: [PATCH] reinstate the skip_tools() check We know the defaults can change what tools should be installed, same as saving multisite settings. There could be other things we're not aware of, and the unit tests don't work without skip_tools() running within install_tools(), so we'll put it back. --- classes/class-local.php | 4 ++++ classes/class-plugin.php | 2 -- common.php | 1 - 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/classes/class-local.php b/classes/class-local.php index cdb2e50..4b724a1 100644 --- a/classes/class-local.php +++ b/classes/class-local.php @@ -316,6 +316,10 @@ public function check_permissions( $file, $minimum ) { public function install_tools() { $this->debug_message( '' . __METHOD__ . '()' ); $this->debug_message( 'Checking/Installing tools in ' . $this->content_dir ); + // If anything changed, we need to re-init the tools list. For instance, setting defaults + // and saving network settings, both of those change what tools should be installed. + // There may arise other circumstances that have similar impact, so better to be safe. + $this->skip_tools(); $toolfail = false; if ( $this->function_exists( '\php_uname' ) ) { $arch_type = \php_uname( 'm' ); diff --git a/classes/class-plugin.php b/classes/class-plugin.php index 7c088d3..62a8247 100644 --- a/classes/class-plugin.php +++ b/classes/class-plugin.php @@ -868,8 +868,6 @@ public function set_defaults() { \add_site_option( 'exactdn_sub_folder', false ); \add_site_option( 'exactdn_prevent_db_queries', true ); \add_site_option( 'ewww_image_optimizer_ll_autoscale', true ); - // If anything changed, need to re-init the tools list. - $this->local->skip_tools(); } /** diff --git a/common.php b/common.php index 34bc4ae..ef860cb 100644 --- a/common.php +++ b/common.php @@ -707,7 +707,6 @@ function ewww_image_optimizer_save_network_settings() { update_site_option( 'ewww_image_optimizer_enable_help', $ewww_image_optimizer_enable_help ); $ewww_image_optimizer_allow_tracking = empty( $_POST['ewww_image_optimizer_allow_tracking'] ) ? false : ewwwio()->tracking->check_for_settings_optin( (bool) $_POST['ewww_image_optimizer_allow_tracking'] ); update_site_option( 'ewww_image_optimizer_allow_tracking', $ewww_image_optimizer_allow_tracking ); - ewwwio()->local->skip_tools(); add_action( 'network_admin_notices', 'ewww_image_optimizer_network_settings_saved' ); add_settings_error( 'general', 'settings_updated', __( 'Settings saved.' ), 'success' ); // phpcs:ignore WordPress.WP.I18n.MissingArgDomain } elseif (