PluginProbe
Elementor Website Builder – more than just a page builder / 3.0.6
Elementor Website Builder – more than just a page builder v3.0.6
4.3.0-beta3 4.3.0-beta2 4.3.0-beta1 4.2.4 4.2.3 4.2.2 4.2.1 4.2.0 4.1.5 4.2.0-beta2 4.2.0-dev2 4.2.0-beta1 4.1.4 4.1.3 4.1.2 4.1.1 4.1.0 4.1.0-beta3 4.1.0-dev3 4.0.9 4.1.0-beta2 4.1.0-dev2 4.0.8 4.1.0-beta1 4.1.0-dev1 All 452 releases
← All changes | core/base/db-upgrades-manager.php +14 -85 4.2.23.0.6 View file →
@@ -1,13 +1,12 @@
1 1 <?php
2 2
3 3 namespace Elementor\Core\Base;
4 4
5 -use Elementor\Core\Admin\Admin_Notices;
6 5 use Elementor\Plugin;
7 6
8 7 if ( ! defined( 'ABSPATH' ) ) {
9 - exit; // Exit if accessed directly.
8 + exit; // Exit if accessed directly
10 9 }
11 10
12 11 abstract class DB_Upgrades_Manager extends Background_Task_Manager {
13 12 protected $current_version = null;
@@ -52,11 +51,9 @@
52 51
53 52 public function on_runner_start() {
54 53 parent::on_runner_start();
55 54
56 - if ( ! defined( 'IS_ELEMENTOR_UPGRADE' ) ) {
57 - define( 'IS_ELEMENTOR_UPGRADE', true );
58 - }
55 + define( 'IS_ELEMENTOR_UPGRADE', true );
59 56 }
60 57
61 58 public function on_runner_complete( $did_tasks = false ) {
62 59 $logger = Plugin::$instance->logger->get_logger();
@@ -68,9 +65,9 @@
68 65 'to' => $this->get_new_version(),
69 66 ],
70 67 ] );
71 68
72 - $this->clear_cache();
69 + Plugin::$instance->files_manager->clear_cache();
73 70
74 71 $this->update_db_version();
75 72
76 73 if ( $did_tasks ) {
@@ -77,71 +74,30 @@
77 74 $this->add_flag( 'completed' );
78 75 }
79 76 }
80 77
81 - protected function clear_cache() {
82 - Plugin::$instance->files_manager->clear_cache();
83 - }
84 -
85 78 public function admin_notice_start_upgrade() {
86 - /**
87 - * @var Admin_Notices $admin_notices
88 - */
89 - $admin_notices = Plugin::$instance->admin->get_component( 'admin-notices' );
79 + $upgrade_link = $this->get_start_action_url();
80 + $message = '<p>' . sprintf( __( '%s Your site database needs to be updated to the latest version.', 'elementor' ), $this->get_updater_label() ) . '</p>';
81 + $message .= '<p>' . sprintf( '<a href="%s" class="button-primary">%s</a>', $upgrade_link, __( 'Update Now', 'elementor' ) ) . '</p>';
90 82
91 - $options = [
92 - 'title' => $this->get_updater_label(),
93 - 'description' => esc_html__( 'Your site database needs to be updated to the latest version.', 'elementor' ),
94 - 'type' => 'error',
95 - 'icon' => false,
96 - 'button' => [
97 - 'text' => esc_html__( 'Update Now', 'elementor' ),
98 - 'url' => $this->get_start_action_url(),
99 - 'class' => 'e-button e-button--cta',
100 - ],
101 - ];
102 -
103 - $admin_notices->print_admin_notice( $options );
83 + echo '<div class="notice notice-error is-dismissible">' . $message . '</div>';
104 84 }
105 85
106 86 public function admin_notice_upgrade_is_running() {
107 - /**
108 - * @var Admin_Notices $admin_notices
109 - */
110 - $admin_notices = Plugin::$instance->admin->get_component( 'admin-notices' );
87 + $upgrade_link = $this->get_continue_action_url();
88 + $message = '<p>' . sprintf( __( '%s Database update process is running in the background.', 'elementor' ), $this->get_updater_label() ) . '</p>';
89 + $message .= '<p>' . __( 'Taking a while?', 'elementor' ) . ' <a href="' . $upgrade_link . '" class="button-primary">' . __( 'Click here to run it now', 'elementor' ) . '</a></p>';
111 90
112 - $options = [
113 - 'title' => $this->get_updater_label(),
114 - 'description' => esc_html__( 'Database update process is running in the background. Taking a while?', 'elementor' ),
115 - 'type' => 'warning',
116 - 'icon' => false,
117 - 'button' => [
118 - 'text' => esc_html__( 'Click here to run it now', 'elementor' ),
119 - 'url' => $this->get_continue_action_url(),
120 - 'class' => 'e-button e-button--primary',
121 - ],
122 - ];
123 -
124 - $admin_notices->print_admin_notice( $options );
91 + echo '<div class="notice notice-warning is-dismissible">' . $message . '</div>';
125 92 }
126 93
127 94 public function admin_notice_upgrade_is_completed() {
128 95 $this->delete_flag( 'completed' );
129 96
130 - $message = esc_html__( 'The database update process is now complete. Thank you for updating to the latest version!', 'elementor' );
97 + $message = '<p>' . sprintf( __( '%s The database update process is now complete. Thank you for updating to the latest version!', 'elementor' ), $this->get_updater_label() ) . '</p>';
131 98
132 - /**
133 - * @var Admin_Notices $admin_notices
134 - */
135 - $admin_notices = Plugin::$instance->admin->get_component( 'admin-notices' );
136 -
137 - $options = [
138 - 'description' => '<b>' . $this->get_updater_label() . '</b> - ' . $message,
139 - 'type' => 'success',
140 - 'icon' => false,
141 - ];
142 -
143 - $admin_notices->print_admin_notice( $options );
99 + echo '<div class="notice notice-success is-dismissible">' . $message . '</div>';
144 100 }
145 101
146 102 /**
147 103 * @access protected
@@ -148,12 +104,9 @@
148 104 */
149 105 protected function start_run() {
150 106 $updater = $this->get_task_runner();
151 107
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() ) {
108 + if ( $updater->is_running() ) {
156 109 return;
157 110 }
158 111
159 112 $upgrade_callbacks = $this->get_upgrade_callbacks();
@@ -162,10 +115,8 @@
162 115 $this->on_runner_complete();
163 116 return;
164 117 }
165 118
166 - $this->clear_cache();
167 -
168 119 foreach ( $upgrade_callbacks as $callback ) {
169 120 $updater->push_to_queue( [
170 121 'callback' => $callback,
171 122 ] );
@@ -194,14 +145,8 @@
194 145 $callbacks = [];
195 146
196 147 foreach ( $upgrades_reflection->getMethods() as $method ) {
197 148 $method_name = $method->getName();
198 -
199 - if ( '_on_each_version' === $method_name ) {
200 - $callbacks[] = [ $upgrades_class, $method_name ];
201 - continue;
202 - }
203 -
204 149 if ( false === strpos( $method_name, $prefix ) ) {
205 150 continue;
206 151 }
207 152
@@ -227,17 +172,8 @@
227 172 if ( is_admin() && current_user_can( 'update_plugins' ) && $this->get_flag( 'completed' ) ) {
228 173 add_action( 'admin_notices', [ $this, 'admin_notice_upgrade_is_completed' ] );
229 174 }
230 175
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 176 if ( ! $this->should_upgrade() ) {
241 177 return;
242 178 }
243 179
@@ -243,15 +179,8 @@
243 179
244 180 $updater = $this->get_task_runner();
245 181
246 182 $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 183
255 184 if ( $updater->is_running() && current_user_can( 'update_plugins' ) ) {
256 185 add_action( 'admin_notices', [ $this, 'admin_notice_upgrade_is_running' ] );
257 186 }