PluginProbe
Yoast SEO – Advanced SEO with real-time guidance and built-in AI / trunk
Yoast SEO – Advanced SEO with real-time guidance and built-in AI vtrunk
28.5 28.4 28.3 28.2 28.1 28.0 27.9 27.8 27.7 27.6 27.5 trunk 18.0 18.1 18.2 18.3 18.4 18.4.1 18.5 18.5.1 18.6 18.7 18.8 18.9 19.0 All 129 releases
← All changes | admin/class-database-proxy.php +37 -23 18.4 → trunk View file →
@@ -45,8 +45,15 @@
45 45 */
46 46 protected $database;
47 47
48 48 /**
49 + * Holds the table prefix.
50 + *
51 + * @var string
52 + */
53 + protected $table_prefix;
54 +
55 + /**
49 56 * Sets the class attributes and registers the table.
50 57 *
51 58 * @param wpdb $database The database object.
52 59 * @param string $table_name The table name that is represented.
@@ -72,12 +79,12 @@
72 79
73 80 /**
74 81 * Inserts data into the database.
75 82 *
76 - * @param array $data Data to insert.
77 - * @param null $format Formats for the data.
83 + * @param array $data Data to insert.
84 + * @param array|string|null $format Formats for the data.
78 85 *
79 - * @return false|int Total amount of inserted rows or false on error.
86 + * @return int|false Total amount of inserted rows or false on error.
80 87 */
81 88 public function insert( array $data, $format = null ) {
82 89 $this->pre_execution();
83 90
@@ -90,14 +97,14 @@
90 97
91 98 /**
92 99 * Updates data in the database.
93 100 *
94 - * @param array $data Data to update on the table.
95 - * @param array $where Where condition as key => value array.
96 - * @param null $format Optional. Data prepare format.
97 - * @param null $where_format Optional. Where prepare format.
101 + * @param array $data Data to update on the table.
102 + * @param array $where Where condition as key => value array.
103 + * @param array|string|null $format Optional. Data prepare format.
104 + * @param array|string|null $where_format Optional. Where prepare format.
98 105 *
99 - * @return false|int False when the update request is invalid, int on number of rows changed.
106 + * @return int|false False when the update request is invalid, int on number of rows changed.
100 107 */
101 108 public function update( array $data, array $where, $format = null, $where_format = null ) {
102 109 $this->pre_execution();
103 110
@@ -112,20 +119,23 @@
112 119 * Upserts data in the database.
113 120 *
114 121 * Performs an insert into and if key is duplicate it will update the existing record.
115 122 *
116 - * @param array $data Data to update on the table.
117 - * @param array|null $where Unused. Where condition as key => value array.
118 - * @param null $format Optional. Data prepare format.
119 - * @param null $where_format Deprecated. Where prepare format.
123 + * @param array $data Data to update on the table.
124 + * @param array|null $where Deprecated since 28.6. Unused since the query was rewritten in 7.7.0.
125 + * @param array|string|null $format Deprecated since 28.6. Unused since the query was rewritten in 7.7.0.
120 126 *
121 - * @return false|int False when the upsert request is invalid, int on number of rows changed.
127 + * @return int|false False when the upsert request is invalid, int on number of rows changed.
122 128 */
123 - public function upsert( array $data, array $where = null, $format = null, $where_format = null ) {
124 - if ( $where_format !== null ) {
125 - _deprecated_argument( __METHOD__, '7.7.0', 'The where_format argument is deprecated' );
129 + public function upsert( array $data, ?array $where = null, $format = null ) {
130 + if ( $where !== null ) {
131 + _deprecated_argument( __METHOD__, 'Yoast SEO 28.6', 'The where argument is deprecated' );
126 132 }
127 133
134 + if ( $format !== null ) {
135 + _deprecated_argument( __METHOD__, 'Yoast SEO 28.6', 'The format argument is deprecated' );
136 + }
137 +
128 138 $this->pre_execution();
129 139
130 140 $update = [];
131 141 $keys = [];
@@ -139,16 +149,16 @@
139 149 'INSERT INTO `%1$s` (%2$s) VALUES ( %3$s ) ON DUPLICATE KEY UPDATE %4$s',
140 150 $this->get_table_name(),
141 151 implode( ', ', $keys ),
142 152 implode( ', ', array_fill( 0, count( $data ), '%s' ) ),
143 - implode( ', ', $update )
153 + implode( ', ', $update ),
144 154 );
145 155
146 156 $result = $this->database->query(
147 157 $this->database->prepare(
148 158 $query,
149 - array_values( $data )
150 - )
159 + array_values( $data ),
160 + ),
151 161 );
152 162
153 163 $this->post_execution();
154 164
@@ -157,12 +167,12 @@
157 167
158 168 /**
159 169 * Deletes a record from the database.
160 170 *
161 - * @param array $where Where clauses for the query.
162 - * @param array|null $format Formats for the data.
171 + * @param array $where Where clauses for the query.
172 + * @param array|string|null $format Formats for the data.
163 173 *
164 - * @return false|int
174 + * @return int|false
165 175 */
166 176 public function delete( array $where, $format = null ) {
167 177 $this->pre_execution();
168 178
@@ -202,9 +212,9 @@
202 212 $create_table = sprintf(
203 213 'CREATE TABLE IF NOT EXISTS %1$s ( %2$s ) %3$s',
204 214 $this->get_table_name(),
205 215 implode( ',', array_merge( $columns, $indexes ) ),
206 - $this->database->get_charset_collate()
216 + $this->database->get_charset_collate(),
207 217 );
208 218
209 219 $this->pre_execution();
210 220
@@ -225,8 +235,10 @@
225 235 }
226 236
227 237 /**
228 238 * Executed before a query will be ran.
239 + *
240 + * @return void
229 241 */
230 242 protected function pre_execution() {
231 243 if ( $this->suppress_errors ) {
232 244 $this->last_suppressed_state = $this->database->suppress_errors();
@@ -234,8 +246,10 @@
234 246 }
235 247
236 248 /**
237 249 * Executed after a query has been ran.
250 + *
251 + * @return void
238 252 */
239 253 protected function post_execution() {
240 254 if ( $this->suppress_errors ) {
241 255 $this->database->suppress_errors( $this->last_suppressed_state );