From d46913de41fc63eb197a8128cd627f3332a49c97 Mon Sep 17 00:00:00 2001 From: wpdev Date: Sun, 27 Sep 2026 16:41:08 +0800 Subject: [PATCH] chore(2meet-data-optimizer): prefix the global variables in uninstall.php - $bootstrap_files, $bootstrap_ok, $f, $result, $snapshot_id and $dir become $wpdo_* like the file's other globals (WordPress.org Plugin Check) - Verify: PrefixAllGlobals sniff 0, phpcs, UninstallGuardTest and InstallerCleanupTest, unit 701 - PR: PR-098 --- uninstall.php | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/uninstall.php b/uninstall.php index b8747dc..c6e0a40 100644 --- a/uninstall.php +++ b/uninstall.php @@ -30,7 +30,7 @@ if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) { global $wpdb; // ── Load shared cleanup logic + snapshot classes ───────────────────────── -$bootstrap_files = array( +$wpdo_bootstrap_files = array( __DIR__ . '/includes/class-tmdo-logger.php', __DIR__ . '/includes/class-tmdo-feature-flags.php', __DIR__ . '/includes/class-tmdo-installer.php', @@ -39,13 +39,13 @@ $bootstrap_files = array( __DIR__ . '/includes/snapshots/class-tmdo-snapshot-reader.php', __DIR__ . '/includes/snapshots/class-tmdo-snapshot-pruner.php', ); -$bootstrap_ok = true; -foreach ( $bootstrap_files as $f ) { - if ( ! is_file( $f ) ) { - $bootstrap_ok = false; +$wpdo_bootstrap_ok = true; +foreach ( $wpdo_bootstrap_files as $wpdo_bootstrap_file ) { + if ( ! is_file( $wpdo_bootstrap_file ) ) { + $wpdo_bootstrap_ok = false; continue; } - require_once $f; + require_once $wpdo_bootstrap_file; } // ── Sites to check and clean (0 = single site, no blog switching) ──────── @@ -77,7 +77,7 @@ $wpdo_for_each_site = static function ( callable $callback ) use ( $wpdo_site_id }; // ── Refuse while any site holds data that exists only in wpdo_* tables ─── -if ( ! $bootstrap_ok ) { +if ( ! $wpdo_bootstrap_ok ) { wp_die( esc_html( '2meet Data Optimizer:無法載入資料安全檢查,為避免資料遺失,已停止解除安裝。' ) ); } @@ -103,7 +103,7 @@ if ( $wpdo_blocked ) { // wpdo_snapshots rows (which is per-site so per-site snapshots survive the // site-level table DROP that happens later). Best-effort. if ( class_exists( 'TMDO_Snapshot_Manager' ) ) { - $result = TMDO_Snapshot_Manager::create( + $wpdo_snapshot = TMDO_Snapshot_Manager::create( 'pre_uninstall', array(), array( @@ -112,18 +112,18 @@ if ( class_exists( 'TMDO_Snapshot_Manager' ) ) { 'inline_threshold_bytes' => 0, ) ); - if ( ! empty( $result['ok'] ) ) { - $snapshot_id = $result['snapshot_id']; - $dir = TMDO_Snapshot_Manager::backup_dir(); - if ( is_dir( $dir ) ) { + if ( ! empty( $wpdo_snapshot['ok'] ) ) { + $wpdo_snapshot_id = $wpdo_snapshot['snapshot_id']; + $wpdo_backup_dir = TMDO_Snapshot_Manager::backup_dir(); + if ( is_dir( $wpdo_backup_dir ) ) { file_put_contents( - trailingslashit( $dir ) . 'README-pre-uninstall.txt', - "WPDO pre-uninstall snapshot: {$snapshot_id}\n" + trailingslashit( $wpdo_backup_dir ) . 'README-pre-uninstall.txt', + "WPDO pre-uninstall snapshot: {$wpdo_snapshot_id}\n" . 'Created: ' . gmdate( 'Y-m-d H:i:s' ) . " UTC\n\n" . "To restore after re-installing wp-data-optimizer:\n" . " 1. Re-install the plugin (it will re-create wp_wpdo_snapshots).\n" . " 2. Manually re-insert this snapshot's catalog row, or use wp wpdo snapshot list to confirm.\n" - . " 3. Run: wp wpdo snapshot restore {$snapshot_id} --apply\n" + . " 3. Run: wp wpdo snapshot restore {$wpdo_snapshot_id} --apply\n" ); } }