PluginProbe
WP-Optimize – Cache, Compress images, Minify & Clean database to boost page speed & performance / 4.7.0
WP-Optimize – Cache, Compress images, Minify & Clean database to boost page speed & performance v4.7.0
4.7.0 4.6.1 4.6.0 4.5.5 4.5.4 4.5.3 4.5.2 3.2.20 3.2.21 3.2.22 3.2.3 3.2.5 3.2.6 3.2.7 3.2.9 3.3.0 3.3.1 3.3.2 3.4.0 3.4.1 3.4.2 3.5.0 3.6.0 3.7.0 3.7.1 All 111 releases
← All changes | vendor/team-updraft/common-libs/src/updraft-semaphore/class-updraft-semaphore.php +7 -6 3.2.21 → 4.7.0 View file →
@@ -1,6 +1,7 @@
1 1 <?php
2 -
2 +// phpcs:disable WordPress.DB.DirectDatabaseQuery.DirectQuery -- we try to reduce overhead by bypassing WP APIs and other extra layers; Some custom complex queries tailored specifically to our needs, giving us full control over the SQL commands and data manipulation
3 +// phpcs:disable WordPress.DB.DirectDatabaseQuery.NoCaching -- some query operations need to always receive the most up-to-date or actual data directly from the database, reducing the risk of serving stale information
3 4 if (!defined('ABSPATH')) die('No direct access.');
4 5
5 6 /**
6 7 * Class Updraft_Semaphore_3_0
@@ -65,9 +66,9 @@
65 66 global $wpdb;
66 67
67 68 $sql = $wpdb->prepare("SELECT COUNT(*) FROM {$wpdb->options} WHERE option_name = %s", $this->option_name);
68 69
69 - if (1 === (int) $wpdb->get_var($sql)) {
70 + if (1 === (int) $wpdb->get_var($sql)) { // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared -- $sql is already prepared via $wpdb->prepare() above
70 71 $this->log('Lock option ('.$this->option_name.', '.$wpdb->options.') already existed in the database', 'debug');
71 72 return 1;
72 73 }
73 74
@@ -72,9 +73,9 @@
72 73 }
73 74
74 75 $sql = $wpdb->prepare("INSERT INTO {$wpdb->options} (option_name, option_value, autoload) VALUES(%s, '0', 'no');", $this->option_name);
75 76
76 - $rows_affected = $wpdb->query($sql);
77 + $rows_affected = $wpdb->query($sql); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared -- $sql is already prepared via $wpdb->prepare() above
77 78
78 79 if ($rows_affected > 0) {
79 80 $this->log('Lock option ('.$this->option_name.', '.$wpdb->options.') was created in the database', 'debug');
80 81 } else {
@@ -101,9 +102,9 @@
101 102 $acquire_until = $time_now + $this->locked_for;
102 103
103 104 $sql = $wpdb->prepare("UPDATE {$wpdb->options} SET option_value = %s WHERE option_name = %s AND option_value < %d", $acquire_until, $this->option_name, $time_now);
104 105
105 - if (1 === $wpdb->query($sql)) {
106 + if (1 === $wpdb->query($sql)) { // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared -- $sql is already prepared via $wpdb->prepare() above
106 107 $this->log('Lock ('.$this->option_name.', '.$wpdb->options.') acquired', 'info');
107 108 $this->acquired = true;
108 109 return true;
109 110 }
@@ -112,9 +113,9 @@
112 113 if (!$this->ensure_database_initialised()) return false;
113 114
114 115 do {
115 116 // Now that the row has been created, try again
116 - if (1 === $wpdb->query($sql)) {
117 + if (1 === $wpdb->query($sql)) { // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared -- $sql is already prepared via $wpdb->prepare() above
117 118 $this->log('Lock ('.$this->option_name.', '.$wpdb->options.') acquired after initialising the database', 'info');
118 119 $this->acquired = true;
119 120 return true;
120 121 }
@@ -147,9 +148,9 @@
147 148 $sql = $wpdb->prepare("UPDATE {$wpdb->options} SET option_value = '0' WHERE option_name = %s", $this->option_name);
148 149
149 150 $this->log('Lock option ('.$this->option_name.', '.$wpdb->options.') released', 'info');
150 151
151 - $result = (int) $wpdb->query($sql) === 1;
152 + $result = (int) $wpdb->query($sql) === 1; // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared -- $sql is already prepared via $wpdb->prepare() above
152 153
153 154 $this->acquired = false;
154 155
155 156 return $result;