PluginProbe
xSpeed Cache: AI-Powered Performance Hub with MCP, Caching & CDN / 1.3.7
xSpeed Cache: AI-Powered Performance Hub with MCP, Caching & CDN v1.3.7
1.3.7 1.3.6 1.3.5 1.3.4 1.3.3 1.3.2 1.3.1 1.3.0 1.2.4 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 All 33 releases
← All changes | includes/modules/Migration/MigrationModule.php +45 -10 1.2.4 → 1.3.7 View file →
@@ -26,12 +26,13 @@
26 26 public const VERSION = '1.0.0';
27 27
28 28 public function ui_metadata(): array {
29 29 return array(
30 - 'label' => 'Migration',
30 + 'label' => __( 'Migration', 'xspeed' ),
31 31 'icon' => 'Import',
32 - 'description' => 'Import settings from WP Rocket, W3 Total Cache, or WP Super Cache.',
32 + 'description' => __( 'Import settings from WP Rocket, W3 Total Cache, WP Super Cache or LiteSpeed Cache.', 'xspeed' ),
33 33 'custom_panel' => 'MigrationPanel',
34 + 'group' => 'tools',
34 35 );
35 36 }
36 37
37 38 public function settings_schema(): array {
@@ -1133,8 +1134,21 @@
1133 1134 */
1134 1135 $network_wide = is_multisite() && is_plugin_active_for_network( $file );
1135 1136 deactivate_plugins( $file, false, $network_wide );
1136 1137
1138 + /*
1139 + * The source's teardown just rewrote the very state the detector
1140 + * memoizes for the request -- WP Rocket truncates advanced-cache.php
1141 + * to 0 bytes and W3TC strips WP_CACHE, both from inside the call
1142 + * above. Without dropping the memo, restore_own_environment() asks a
1143 + * report taken while the source still held the field, sees "foreign",
1144 + * and refuses -- so the handover deactivated the source and then
1145 + * declined to take over, which is the outcome #391 describes.
1146 + */
1147 + if ( class_exists( '\\XSpeed\\Page_Cache_Detector' ) ) {
1148 + \XSpeed\Page_Cache_Detector::invalidate();
1149 + }
1150 +
1137 1151 return ! is_plugin_active( $file );
1138 1152 }
1139 1153
1140 1154 /**
@@ -1150,11 +1164,18 @@
1150 1164 * loads it without the constant, and the cache silently degrades to the
1151 1165 * slow in-PHP path — measured at 78ms vs 16ms TTFB on an otherwise
1152 1166 * identical request.
1153 1167 *
1154 - * Only runs when the user has caching ON, and only re-asserts what we
1155 - * already own, so it cannot resurrect a cache the user turned off.
1156 - * (#218, #219)
1168 + * Runs at exactly one moment -- the user asked to import from another
1169 + * plugin AND switch it off, and we just switched it off -- so it turns
1170 + * caching ON rather than only re-asserting an existing setting. It used
1171 + * to return early unless cache_enabled was already set, which it almost
1172 + * never is here: the site was being cached by the plugin we just
1173 + * deactivated. That is how a migration could end with the source gone
1174 + * and nothing serving. (#218, #219, #391)
1175 + *
1176 + * Not a licence to trample: toggle() still refuses on an occupied field,
1177 + * so a page cache we were not asked to replace is left alone.
1157 1178 */
1158 1179 private function restore_own_environment(): void {
1159 1180 if ( ! class_exists( '\\XSpeed\\Cache' ) || ! class_exists( '\\XSpeed\\Settings' ) ) {
1160 1181 return;
@@ -1159,13 +1180,20 @@
1159 1180 if ( ! class_exists( '\\XSpeed\\Cache' ) || ! class_exists( '\\XSpeed\\Settings' ) ) {
1160 1181 return;
1161 1182 }
1162 1183
1163 - $opts = \XSpeed\Settings::get();
1164 - if ( empty( $opts['cache_enabled'] ) ) {
1165 - return;
1166 - }
1167 -
1184 + /*
1185 + * Turn caching ON, rather than only re-asserting it when it was
1186 + * already on. This runs at exactly one moment: the user asked us to
1187 + * import from another plugin AND switch it off, and we just did. A
1188 + * handover that ends with the old cache gone and no new one is not a
1189 + * handover -- and cache_enabled is nearly always empty here, because
1190 + * the site was being cached by the plugin we just deactivated. That
1191 + * early return is why #391 ended with nothing serving.
1192 + *
1193 + * toggle() still refuses if the field is genuinely occupied, so this
1194 + * cannot trample a cache we were not asked to replace.
1195 + */
1168 1196 \XSpeed\Cache::toggle( true );
1169 1197 }
1170 1198
1171 1199 public function cli_commands(): array {
@@ -1275,8 +1303,15 @@
1275 1303 if ( $want_off && $imported_something && $still_on ) {
1276 1304 if ( $this->deactivate_source( $src ) ) {
1277 1305 \WP_CLI::log( sprintf( 'Deactivated %s.', $src ) );
1278 1306 $still_on = false;
1307 + // Same handover the REST route performs. Without it
1308 + // the CLI switched the source off and stopped there,
1309 + // leaving the husk of its drop-in and no page cache
1310 + // at all -- reported as "Success: Import complete."
1311 + // CLI and REST must not disagree about what
1312 + // --deactivate-source means. (#391)
1313 + $this->restore_own_environment();
1279 1314 } else {
1280 1315 \WP_CLI::warning( sprintf( 'Could not deactivate %s.', $src ) );
1281 1316 }
1282 1317 }