| @@ -5,9 +5,9 @@ | ||
| 5 | 5 | use Elementor\Core\Admin\Admin_Notices; |
| 6 | 6 | use Elementor\Plugin; |
| 7 | 7 | |
| 8 | 8 | if ( ! defined( 'ABSPATH' ) ) { |
| 9 | - exit; // Exit if accessed directly. | |
| 9 | + exit; // Exit if accessed directly | |
| 10 | 10 | } |
| 11 | 11 | |
| 12 | 12 | abstract class DB_Upgrades_Manager extends Background_Task_Manager { |
| 13 | 13 | protected $current_version = null; |
| @@ -68,9 +68,9 @@ | ||
| 68 | 68 | 'to' => $this->get_new_version(), |
| 69 | 69 | ], |
| 70 | 70 | ] ); |
| 71 | 71 | |
| 72 | - $this->clear_cache(); | |
| 72 | + Plugin::$instance->files_manager->clear_cache(); | |
| 73 | 73 | |
| 74 | 74 | $this->update_db_version(); |
| 75 | 75 | |
| 76 | 76 | if ( $did_tasks ) { |
| @@ -77,12 +77,8 @@ | ||
| 77 | 77 | $this->add_flag( 'completed' ); |
| 78 | 78 | } |
| 79 | 79 | } |
| 80 | 80 | |
| 81 | - protected function clear_cache() { | |
| 82 | - Plugin::$instance->files_manager->clear_cache(); | |
| 83 | - } | |
| 84 | - | |
| 85 | 81 | public function admin_notice_start_upgrade() { |
| 86 | 82 | /** |
| 87 | 83 | * @var Admin_Notices $admin_notices |
| 88 | 84 | */ |
| @@ -148,12 +144,9 @@ | ||
| 148 | 144 | */ |
| 149 | 145 | protected function start_run() { |
| 150 | 146 | $updater = $this->get_task_runner(); |
| 151 | 147 | |
| 152 | - // Skip if process is actively running (has lock) or queue already has items. | |
| 153 | - // Stuck queues (items exist but no lock) are handled by the shutdown fallback | |
| 154 | - // registered in the constructor, so we don't need to re-push callbacks here. | |
| 155 | - if ( $updater->is_process_locked() || $updater->is_running() ) { | |
| 148 | + if ( $updater->is_running() ) { | |
| 156 | 149 | return; |
| 157 | 150 | } |
| 158 | 151 | |
| 159 | 152 | $upgrade_callbacks = $this->get_upgrade_callbacks(); |
| @@ -162,10 +155,8 @@ | ||
| 162 | 155 | $this->on_runner_complete(); |
| 163 | 156 | return; |
| 164 | 157 | } |
| 165 | 158 | |
| 166 | - $this->clear_cache(); | |
| 167 | - | |
| 168 | 159 | foreach ( $upgrade_callbacks as $callback ) { |
| 169 | 160 | $updater->push_to_queue( [ |
| 170 | 161 | 'callback' => $callback, |
| 171 | 162 | ] ); |
| @@ -227,17 +218,8 @@ | ||
| 227 | 218 | if ( is_admin() && current_user_can( 'update_plugins' ) && $this->get_flag( 'completed' ) ) { |
| 228 | 219 | add_action( 'admin_notices', [ $this, 'admin_notice_upgrade_is_completed' ] ); |
| 229 | 220 | } |
| 230 | 221 | |
| 231 | - // Don't run upgrade logic during background process AJAX requests. | |
| 232 | - // The AJAX handler (maybe_handle) will process the queue. | |
| 233 | - // phpcs:ignore WordPress.Security.NonceVerification.Recommended | |
| 234 | - $ajax_action = isset( $_REQUEST['action'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['action'] ) ) : ''; | |
| 235 | - | |
| 236 | - if ( wp_doing_ajax() && $ajax_action && false !== strpos( $ajax_action, 'updater' ) ) { | |
| 237 | - return; | |
| 238 | - } | |
| 239 | - | |
| 240 | 222 | if ( ! $this->should_upgrade() ) { |
| 241 | 223 | return; |
| 242 | 224 | } |
| 243 | 225 | |
| @@ -243,15 +225,8 @@ | ||
| 243 | 225 | |
| 244 | 226 | $updater = $this->get_task_runner(); |
| 245 | 227 | |
| 246 | 228 | $this->start_run(); |
| 247 | - | |
| 248 | - // If queue has items but process is not locked, it's stuck - try to process on shutdown. | |
| 249 | - if ( $updater->is_running() && ! $updater->is_process_locked() ) { | |
| 250 | - if ( is_admin() && ! wp_doing_ajax() && ! wp_doing_cron() ) { | |
| 251 | - add_action( 'shutdown', [ $updater, 'maybe_handle_on_shutdown' ], 0 ); | |
| 252 | - } | |
| 253 | - } | |
| 254 | 229 | |
| 255 | 230 | if ( $updater->is_running() && current_user_can( 'update_plugins' ) ) { |
| 256 | 231 | add_action( 'admin_notices', [ $this, 'admin_notice_upgrade_is_running' ] ); |
| 257 | 232 | } |