PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 5.0
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v5.0
6.35 6.34 6.33.1 6.33 6.32.1 6.32 6.31 6.25 6.25.1 6.26 6.26.1 6.27 6.28 6.29 6.3 6.3.1 6.3.2 6.30 6.4 6.4.1 6.4.2 6.5 6.5.1 6.5.2 6.5.3 All 141 releases
← All changes | classes/models/FrmDb.php +108 -221 6.265.0 View file →
@@ -3,35 +3,11 @@
3 3 die( 'You are not allowed to call this page directly.' );
4 4 }
5 5
6 6 class FrmDb {
7 -
8 - /**
9 - * The table name for Formidable Fields.
10 - *
11 - * @var string
12 - */
13 7 public $fields;
14 -
15 - /**
16 - * The table name for Formidable Forms.
17 - *
18 - * @var string
19 - */
20 8 public $forms;
21 -
22 - /**
23 - * The table name for Formidable Entries.
24 - *
25 - * @var string
26 - */
27 9 public $entries;
28 -
29 - /**
30 - * The table name for Formidable Entry Metas.
31 - *
32 - * @var string
33 - */
34 10 public $entry_metas;
35 11
36 12 public function __construct() {
37 13 if ( ! defined( 'ABSPATH' ) ) {
@@ -48,12 +24,10 @@
48 24
49 25 /**
50 26 * Change array into format $wpdb->prepare can use
51 27 *
52 - * @param array $args
28 + * @param array $args
53 29 * @param string $starts_with
54 - *
55 - * @return void
56 30 */
57 31 public static function get_where_clause_and_values( &$args, $starts_with = ' WHERE ' ) {
58 32 if ( empty( $args ) ) {
59 33 // add an arg to prevent prepare from failing
@@ -76,18 +50,15 @@
76 50 $args = compact( 'where', 'values' );
77 51 }
78 52
79 53 /**
80 - * @param array $args
54 + * @param array $args
81 55 * @param string $base_where
82 56 * @param string $where
83 - * @param array $values
84 - *
85 - * @return void
57 + * @param array $values
86 58 */
87 59 public static function parse_where_from_array( $args, $base_where, &$where, &$values ) {
88 60 $condition = ' AND';
89 -
90 61 if ( isset( $args['or'] ) ) {
91 62 $condition = ' OR';
92 63 unset( $args['or'] );
93 64 }
@@ -92,15 +63,13 @@
92 63 unset( $args['or'] );
93 64 }
94 65
95 66 foreach ( $args as $key => $value ) {
96 - $where .= empty( $where ) ? $base_where : $condition;
67 + $where .= empty( $where ) ? $base_where : $condition;
97 68 $array_inc_null = ( ! is_numeric( $key ) && is_array( $value ) && in_array( null, $value ) );
98 -
99 69 if ( is_numeric( $key ) || $array_inc_null ) {
100 - $where .= ' ( ';
70 + $where .= ' ( ';
101 71 $nested_where = '';
102 -
103 72 if ( $array_inc_null ) {
104 73 foreach ( $value as $val ) {
105 74 $parse_where = array(
106 75 $key => $val,
@@ -110,31 +79,29 @@
110 79 }
111 80 } else {
112 81 self::parse_where_from_array( $value, '', $nested_where, $values );
113 82 }
114 -
115 83 $where .= $nested_where;
116 84 $where .= ' ) ';
117 85 } else {
118 86 self::interpret_array_to_sql( $key, $value, $where, $values );
119 - }//end if
120 - }//end foreach
87 + }
88 + }
121 89 }
122 90
123 91 /**
124 - * @param string $key
125 - * @param array|string $value
126 - * @param string $where
127 - * @param array $values
128 - *
129 - * @return void
92 + * @param string $key
93 + * @param string|array $value
94 + * @param string $where
95 + * @param array $values
130 96 */
131 97 private static function interpret_array_to_sql( $key, $value, &$where, &$values ) {
132 98 $key = trim( $key );
133 99
134 100 if ( strpos( $key, 'created_at' ) !== false || strpos( $key, 'updated_at' ) !== false ) {
135 - $k = explode( ' ', $key );
136 - $where .= ' CAST(' . reset( $k ) . ' as CHAR) ' . str_replace( reset( $k ), '', $key );
101 + $k = explode( ' ', $key );
102 + $where .= ' DATE_FORMAT(' . reset( $k ) . ', %s) ' . str_replace( reset( $k ), '', $key );
103 + $values[] = '%Y-%m-%d %H:%i:%s';
137 104 } else {
138 105 $where .= ' ' . $key;
139 106 }
140 107
@@ -143,25 +110,22 @@
143 110
144 111 if ( is_array( $value ) ) {
145 112 // translate array of values to "in"
146 113 if ( strpos( $lowercase_key, 'like' ) !== false ) {
147 - $where = preg_replace( '/' . $key . '$/', '', $where );
114 + $where = preg_replace( '/' . $key . '$/', '', $where );
148 115 $where .= '(';
149 - $start = true;
150 -
116 + $start = true;
151 117 foreach ( $value as $v ) {
152 118 if ( ! $start ) {
153 119 $where .= ' OR ';
154 120 }
155 -
156 121 $start = false;
157 - $where .= $key . ' %s';
122 + $where .= $key . ' %s';
158 123 $values[] = '%' . self::esc_like( $v ) . '%';
159 124 }
160 -
161 125 $where .= ')';
162 126 } elseif ( ! empty( $value ) ) {
163 - $where .= ' in (' . self::prepare_array_values( $value, '%s' ) . ')';
127 + $where .= ' in (' . self::prepare_array_values( $value, '%s' ) . ')';
164 128 $values = array_merge( $values, $value );
165 129 }
166 130 } elseif ( strpos( $lowercase_key, 'like' ) !== false ) {
167 131 /**
@@ -170,19 +134,18 @@
170 134 * If the key is %like then skip the last % for ends with
171 135 */
172 136 $start = '%';
173 137 $end = '%';
174 -
175 - if ( $lowercase_key === 'like%' ) {
138 + if ( $lowercase_key == 'like%' ) {
176 139 $start = '';
177 140 $where = rtrim( $where, '%' );
178 - } elseif ( $lowercase_key === '%like' ) {
179 - $end = '';
180 - $where = rtrim( rtrim( $where, '%like' ), '%LIKE' );
141 + } elseif ( $lowercase_key == '%like' ) {
142 + $end = '';
143 + $where = rtrim( rtrim( $where, '%like' ), '%LIKE' );
181 144 $where .= 'like';
182 145 }
183 146
184 - $where .= ' %s';
147 + $where .= ' %s';
185 148 $values[] = $start . self::esc_like( $value ) . $end;
186 149
187 150 } elseif ( $value === null ) {
188 151 $where .= ' IS NULL';
@@ -187,9 +150,9 @@
187 150 } elseif ( $value === null ) {
188 151 $where .= ' IS NULL';
189 152 } else {
190 153 // allow a - to prevent = from being added
191 - if ( substr( $key, - 1 ) === '-' ) {
154 + if ( substr( $key, - 1 ) == '-' ) {
192 155 $where = rtrim( $where, '-' );
193 156 } else {
194 157 $where .= '=';
195 158 }
@@ -196,9 +159,9 @@
196 159
197 160 self::add_query_placeholder( $key, $value, $where );
198 161
199 162 $values[] = $value;
200 - }//end if
163 + }
201 164 }
202 165
203 166 /**
204 167 * Add %d, or %s to query
@@ -204,18 +167,15 @@
204 167 * Add %d, or %s to query
205 168 *
206 169 * @since 2.02.05
207 170 *
208 - * @param string $key
171 + * @param string $key
209 172 * @param int|string $value
210 - * @param string $where
211 - *
212 - * @return void
173 + * @param string $where
213 174 */
214 175 private static function add_query_placeholder( $key, $value, &$where ) {
215 176 if ( is_numeric( $value ) && ( strpos( $key, 'meta_value' ) === false || strpos( $key, '+0' ) !== false ) ) {
216 - // Switch string to number.
217 - $value = $value + 0;
177 + $value = $value + 0; // switch string to number
218 178 $where .= is_float( $value ) ? '%f' : '%d';
219 179 } else {
220 180 $where .= '%s';
221 181 }
@@ -222,10 +182,10 @@
222 182 }
223 183
224 184 /**
225 185 * @param string $table
226 - * @param array $where
227 - * @param array $args
186 + * @param array $where
187 + * @param array $args
228 188 *
229 189 * @return int
230 190 */
231 191 public static function get_count( $table, $where = array(), $args = array() ) {
@@ -235,21 +195,20 @@
235 195 }
236 196
237 197 /**
238 198 * @param string $table
239 - * @param array $where
199 + * @param array $where
240 200 * @param string $field
241 - * @param array $args
201 + * @param array $args
242 202 * @param string $limit
243 203 * @param string $type
244 204 *
245 - * @return array|object|string|null
205 + * @return array|null|string|object
246 206 */
247 207 public static function get_var( $table, $where = array(), $field = 'id', $args = array(), $limit = '', $type = 'var' ) {
248 208 $group = '';
249 209 self::get_group_and_table_name( $table, $group );
250 210 self::convert_options_to_array( $args, '', $limit );
251 -
252 211 if ( $type === 'var' && ! isset( $args['limit'] ) ) {
253 212 $args['limit'] = 1;
254 213 }
255 214
@@ -265,25 +224,23 @@
265 224 * Generate a cache key from the where query, field, type, and other arguments
266 225 *
267 226 * @since 2.03.07
268 227 *
269 - * @param array $where
270 - * @param array $args
228 + * @param array $where
229 + * @param array $args
271 230 * @param string $field
272 231 * @param string $type
273 232 *
274 233 * @return string
275 234 */
276 - public static function generate_cache_key( $where, $args, $field, $type ) {
235 + private static function generate_cache_key( $where, $args, $field, $type ) {
277 236 $cache_key = '';
278 237 $where = FrmAppHelper::array_flatten( $where );
279 -
280 238 foreach ( $where as $key => $value ) {
281 239 $cache_key .= $key . '_' . $value;
282 240 }
283 -
284 241 $cache_key .= implode( '_', $args ) . $field . '_' . $type;
285 - $cache_key = str_replace( array( ' ', ',' ), '_', $cache_key );
242 + $cache_key = str_replace( array( ' ', ',' ), '_', $cache_key );
286 243
287 244 return $cache_key;
288 245 }
289 246
@@ -288,14 +245,14 @@
288 245 }
289 246
290 247 /**
291 248 * @param string $table
292 - * @param array $where
249 + * @param array $where
293 250 * @param string $field
294 - * @param array $args
251 + * @param array $args
295 252 * @param string $limit
296 253 *
297 - * @return array
254 + * @return mixed
298 255 */
299 256 public static function get_col( $table, $where = array(), $field = 'id', $args = array(), $limit = '' ) {
300 257 return self::get_var( $table, $where, $field, $args, $limit, 'col' );
301 258 }
@@ -303,16 +260,17 @@
303 260 /**
304 261 * @since 2.0
305 262 *
306 263 * @param string $table
307 - * @param array $where
264 + * @param array $where
308 265 * @param string $fields
309 - * @param array $args
266 + * @param array $args
310 267 *
311 268 * @return mixed
312 269 */
313 270 public static function get_row( $table, $where = array(), $fields = '*', $args = array() ) {
314 271 $args['limit'] = 1;
272 +
315 273 return self::get_var( $table, $where, $fields, $args, '', 'row' );
316 274 }
317 275
318 276 /**
@@ -320,13 +278,13 @@
320 278 *
321 279 * @since 2.0
322 280 *
323 281 * @param string $table
324 - * @param array $where
282 + * @param array $where
325 283 * @param string $fields
326 - * @param array $args
284 + * @param array $args
327 285 *
328 - * @return array
286 + * @return mixed
329 287 */
330 288 public static function get_results( $table, $where = array(), $fields = '*', $args = array() ) {
331 289 return self::get_var( $table, $where, $fields, $args, '', 'results' );
332 290 }
@@ -353,17 +311,15 @@
353 311 '%like' => '%like',
354 312 );
355 313
356 314 $where_is = strtolower( $where_is );
357 -
358 315 if ( isset( $switch_to[ $where_is ] ) ) {
359 316 return ' ' . $switch_to[ $where_is ];
360 317 }
361 318
362 319 // > and < need a little more work since we don't want them switched to >= and <=
363 - if ( $where_is === '>' || $where_is === '<' ) {
364 - // The - indicates that the = should not be added later.
365 - return ' ' . $where_is . '-';
320 + if ( $where_is == '>' || $where_is == '<' ) {
321 + return ' ' . $where_is . '-'; // the - indicates that the = should not be added later
366 322 }
367 323
368 324 // fallback to = if the query is none of these
369 325 return '';
@@ -374,19 +330,17 @@
374 330 * Also add the wpdb->prefix to the table if it's missing
375 331 *
376 332 * @param string $table
377 333 * @param string $group
378 - *
379 - * @return void
380 334 */
381 335 private static function get_group_and_table_name( &$table, &$group ) {
382 - global $wpdb;
336 + global $wpdb, $wpmuBaseTablePrefix;
383 337
384 338 $table_parts = explode( ' ', $table );
385 339 $group = reset( $table_parts );
386 340 self::maybe_remove_prefix( $wpdb->prefix, $group );
387 341
388 - $prefix = $wpdb->base_prefix;
342 + $prefix = $wpmuBaseTablePrefix ? $wpmuBaseTablePrefix : $wpdb->base_prefix;
389 343 self::maybe_remove_prefix( $prefix, $group );
390 344
391 345 if ( $group == $table ) {
392 346 $table = $wpdb->prefix . $table;
@@ -399,13 +353,8 @@
399 353 /**
400 354 * Only remove the db prefix when at the beginning.
401 355 *
402 356 * @since 4.04.02
403 - *
404 - * @param string $prefix Prefix to remove.
405 - * @param string $name Name to strip prefix from, passed by reference.
406 - *
407 - * @return void
408 357 */
409 358 private static function maybe_remove_prefix( $prefix, &$name ) {
410 359 if ( substr( $name, 0, strlen( $prefix ) ) === $prefix ) {
411 360 $name = substr( $name, strlen( $prefix ) );
@@ -411,15 +360,8 @@
411 360 $name = substr( $name, strlen( $prefix ) );
412 361 }
413 362 }
414 363
415 - /**
416 - * @param array|string $args
417 - * @param string $order_by
418 - * @param int|string $limit
419 - *
420 - * @return void
421 - */
422 364 private static function convert_options_to_array( &$args, $order_by = '', $limit = '' ) {
423 365 if ( ! is_array( $args ) ) {
424 366 $args = array( 'order_by' => $args );
425 367 }
@@ -432,9 +374,8 @@
432 374 $args['limit'] = $limit;
433 375 }
434 376
435 377 $temp_args = $args;
436 -
437 378 foreach ( $temp_args as $k => $v ) {
438 379 if ( $v == '' ) {
439 380 unset( $args[ $k ] );
440 381 continue;
@@ -440,9 +381,8 @@
440 381 continue;
441 382 }
442 383
443 384 $db_name = strtoupper( str_replace( '_', ' ', $k ) );
444 -
445 385 if ( strpos( $v, $db_name ) === false ) {
446 386 $args[ $k ] = $db_name . ' ' . $v;
447 387 }
448 388 }
@@ -461,9 +401,9 @@
461 401 * @since 2.02.05
462 402 *
463 403 * @param string $columns
464 404 * @param string $table
465 - * @param array $where
405 + * @param array $where
466 406 *
467 407 * @return mixed
468 408 */
469 409 public static function get_associative_array_results( $columns, $table, $where ) {
@@ -484,10 +424,10 @@
484 424 * @since 2.02.05
485 425 *
486 426 * @param string $columns
487 427 * @param string $table
488 - * @param mixed $where
489 - * @param array $args
428 + * @param mixed $where
429 + * @param array $args
490 430 *
491 431 * @return string
492 432 */
493 433 private static function generate_query_string_from_pieces( $columns, $table, $where, $args = array() ) {
@@ -497,9 +437,16 @@
497 437
498 438 if ( is_array( $where ) || empty( $where ) ) {
499 439 self::get_where_clause_and_values( $where );
500 440 global $wpdb;
501 - $query = $wpdb->prepare( $query . $where['where'] . ' ' . implode( ' ', $args ), $where['values'] ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
441 + $query = $wpdb->prepare( $query . $where['where'] . ' ' . implode( ' ', $args ), $where['values'] ); // WPCS: unprepared SQL ok.
442 + } else {
443 + /**
444 + * Allow the $where to be prepared before we recieve it here.
445 + * This is a fallback for reverse compatibility, but is not recommended
446 + */
447 + _deprecated_argument( 'where', '2.0', esc_html__( 'Use the query in an array format so it can be properly prepared.', 'formidable' ) );
448 + $query .= $where . ' ' . implode( ' ', $args );
502 449 }
503 450
504 451 return $query;
505 452 }
@@ -505,18 +452,14 @@
505 452 }
506 453
507 454 /**
508 455 * @since 2.05.07
509 - *
510 - * @param array $args Query arguments, passed by reference.
511 - *
512 - * @return void
513 456 */
514 457 private static function esc_query_args( &$args ) {
515 458 foreach ( $args as $param => $value ) {
516 - if ( $param === 'order_by' ) {
459 + if ( $param == 'order_by' ) {
517 460 $args[ $param ] = self::esc_order( $value );
518 - } elseif ( $param === 'limit' ) {
461 + } elseif ( $param == 'limit' ) {
519 462 $args[ $param ] = self::esc_limit( $value );
520 463 }
521 464
522 465 if ( $args[ $param ] == '' ) {
@@ -525,13 +468,13 @@
525 468 }
526 469 }
527 470
528 471 /**
529 - * Added for < WP 4.0 compatibility
472 + * Added for < WP 4.0 compatability
530 473 *
531 474 * @since 2.05.06
532 475 *
533 - * @param string $term The value to escape.
476 + * @param string $term The value to escape
534 477 *
535 478 * @return string The escaped value
536 479 */
537 480 public static function esc_like( $term ) {
@@ -543,10 +486,8 @@
543 486 /**
544 487 * @since 2.05.06
545 488 *
546 489 * @param string $order_query
547 - *
548 - * @return string
549 490 */
550 491 public static function esc_order( $order_query ) {
551 492 if ( empty( $order_query ) ) {
552 493 return '';
@@ -551,11 +492,10 @@
551 492 if ( empty( $order_query ) ) {
552 493 return '';
553 494 }
554 495
555 - // Remove ORDER BY before sanitizing.
496 + // remove ORDER BY before santizing
556 497 $order_query = strtolower( $order_query );
557 -
558 498 if ( strpos( $order_query, 'order by' ) !== false ) {
559 499 $order_query = str_replace( 'order by', '', $order_query );
560 500 }
561 501
@@ -562,15 +502,13 @@
562 502 $order_query = explode( ' ', trim( $order_query ) );
563 503
564 504 $order = trim( reset( $order_query ) );
565 505 $safe_order = array( 'count(*)' );
566 -
567 506 if ( ! in_array( strtolower( $order ), $safe_order ) ) {
568 507 $order = preg_replace( '/[^a-zA-Z0-9\-\_\.\+]/', '', $order );
569 508 }
570 509
571 510 $order_by = '';
572 -
573 511 if ( count( $order_query ) > 1 ) {
574 512 $order_by = end( $order_query );
575 513 self::esc_order_by( $order_by );
576 514 }
@@ -581,27 +519,20 @@
581 519 /**
582 520 * Make sure this is ordering by either ASC or DESC
583 521 *
584 522 * @since 2.05.06
585 - *
586 - * @param string $order_by Sort direction, passed by reference.
587 - *
588 - * @return void
589 523 */
590 524 public static function esc_order_by( &$order_by ) {
591 525 $sort_options = array( 'asc', 'desc' );
592 -
593 - if ( ! in_array( strtolower( $order_by ), $sort_options, true ) ) {
526 + if ( ! in_array( strtolower( $order_by ), $sort_options ) ) {
594 527 $order_by = 'asc';
595 528 }
596 529 }
597 530
598 531 /**
599 - * @since 2.05.06
600 - *
601 532 * @param string $limit
602 533 *
603 - * @return string
534 + * @since 2.05.06
604 535 */
605 536 public static function esc_limit( $limit ) {
606 537 if ( empty( $limit ) ) {
607 538 return '';
@@ -607,15 +538,13 @@
607 538 return '';
608 539 }
609 540
610 541 $limit = trim( str_replace( 'limit ', '', strtolower( $limit ) ) );
611 -
612 542 if ( is_numeric( $limit ) ) {
613 543 return ' LIMIT ' . $limit;
614 544 }
615 545
616 546 $limit = explode( ',', trim( $limit ) );
617 -
618 547 foreach ( $limit as $k => $l ) {
619 548 if ( is_numeric( $l ) ) {
620 549 $limit[ $k ] = $l;
621 550 }
@@ -629,13 +558,8 @@
629 558 /**
630 559 * Get an array of values ready to go through $wpdb->prepare
631 560 *
632 561 * @since 2.05.06
633 - *
634 - * @param array $array Array of values.
635 - * @param string $type Placeholder type.
636 - *
637 - * @return string
638 562 */
639 563 public static function prepare_array_values( $array, $type = '%s' ) {
640 564 $placeholders = array_fill( 0, count( $array ), $type );
641 565
@@ -643,45 +567,32 @@
643 567 }
644 568
645 569 /**
646 570 * @since 2.05.06
647 - *
648 - * @param string $starts_with
649 - * @param array|string $where
650 - *
651 - * @return string
652 571 */
653 572 public static function prepend_and_or_where( $starts_with = ' WHERE ', $where = '' ) {
654 573 if ( empty( $where ) ) {
655 - $where = '';
656 - } elseif ( is_array( $where ) ) {
657 - global $wpdb;
658 - self::get_where_clause_and_values( $where, $starts_with );
659 - $where = $wpdb->prepare( $where['where'], $where['values'] ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
574 + return '';
575 + }
576 +
577 + if ( is_array( $where ) ) {
578 + global $wpdb;
579 + self::get_where_clause_and_values( $where, $starts_with );
580 + $where = $wpdb->prepare( $where['where'], $where['values'] ); // WPCS: unprepared SQL ok.
660 581 } else {
661 582 $where = $starts_with . $where;
662 583 }
663 584
664 - /**
665 - * Allows modifying where clause when using FrmDb::prepend_and_or_where() method.
666 - *
667 - * @since 5.0.16
668 - *
669 - * @param string $where Where string.
670 - * @param string $starts_with The start of where string.
671 - */
672 - return apply_filters( 'frm_prepend_and_or_where', $where, $starts_with );
585 + return $where;
673 586 }
674 587
675 588 /**
676 589 * Prepare and save settings in styles and actions
677 590 *
591 + * @param array $settings
592 + * @param string $group
593 + *
678 594 * @since 2.05.06
679 - *
680 - * @param array|object $settings
681 - * @param string $group
682 - *
683 - * @return int|WP_Error
684 595 */
685 596 public static function save_settings( $settings, $group ) {
686 597 $settings = (array) $settings;
687 598 $settings['post_content'] = FrmAppHelper::prepare_and_encode( $settings['post_content'] );
@@ -703,16 +614,11 @@
703 614 *
704 615 * Used when saving form actions and styles
705 616 *
706 617 * @since 2.05.06
707 - *
708 - * @param array $settings
709 - *
710 - * @return int|WP_Error
711 618 */
712 619 public static function save_json_post( $settings ) {
713 620 global $wp_filter;
714 -
715 621 if ( isset( $wp_filter['content_save_pre'] ) ) {
716 622 $filters = $wp_filter['content_save_pre'];
717 623 }
718 624
@@ -733,29 +639,26 @@
733 639 * Check cache before fetching values and saving to cache
734 640 *
735 641 * @since 2.05.06
736 642 *
737 - * @param string $cache_key The unique name for this cache.
738 - * @param string $group The name of the cache group.
739 - * @param string $query If blank, don't run a db call.
740 - * @param string $type The wpdb function to use with this query.
741 - * @param int $time Cache expiration time in seconds.
643 + * @param string $cache_key The unique name for this cache
644 + * @param string $group The name of the cache group
645 + * @param string $query If blank, don't run a db call
646 + * @param string $type The wpdb function to use with this query
742 647 *
743 648 * @return mixed $results The cache or query results
744 649 */
745 650 public static function check_cache( $cache_key, $group = '', $query = '', $type = 'get_var', $time = 300 ) {
746 - $found = null;
747 - $results = wp_cache_get( $cache_key, $group, false, $found );
748 -
749 - if ( ( $found === true && $results !== false ) || empty( $query ) ) {
651 + $results = wp_cache_get( $cache_key, $group );
652 + if ( ! FrmAppHelper::is_empty_value( $results, false ) || empty( $query ) ) {
750 653 return $results;
751 654 }
752 655
753 656 if ( 'get_posts' == $type ) {
754 657 $results = get_posts( $query );
755 - } elseif ( 'get_associative_results' === $type ) {
658 + } elseif ( 'get_associative_results' == $type ) {
756 659 global $wpdb;
757 - $results = $wpdb->get_results( $query, OBJECT_K ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
660 + $results = $wpdb->get_results( $query, OBJECT_K ); // WPCS: unprepared SQL ok.
758 661 } else {
759 662 global $wpdb;
760 663 $results = $wpdb->{$type}( $query );
761 664 }
@@ -766,15 +669,8 @@
766 669 }
767 670
768 671 /**
769 672 * @since 2.05.06
770 - *
771 - * @param string $cache_key The unique name for this cache.
772 - * @param mixed $results Cached results.
773 - * @param string $group The name of the cache group.
774 - * @param int $time Cache expiration time in seconds.
775 - *
776 - * @return void
777 673 */
778 674 public static function set_cache( $cache_key, $results, $group = '', $time = 300 ) {
779 675 if ( ! FrmAppHelper::prevent_caching() ) {
780 676 self::add_key_to_group_cache( $cache_key, $group );
@@ -786,13 +682,8 @@
786 682 * Keep track of the keys cached in each group so they can be deleted
787 683 * in Redis and Memcache
788 684 *
789 685 * @since 2.05.06
790 - *
791 - * @param string $key Cache key.
792 - * @param string $group Cache group name.
793 - *
794 - * @return void
795 686 */
796 687 public static function add_key_to_group_cache( $key, $group ) {
797 688 $cached = self::get_group_cached_keys( $group );
798 689 $cached[ $key ] = $key;
@@ -800,16 +691,11 @@
800 691 }
801 692
802 693 /**
803 694 * @since 2.05.06
804 - *
805 - * @param string $group Cache group name.
806 - *
807 - * @return array
808 695 */
809 696 public static function get_group_cached_keys( $group ) {
810 697 $cached = wp_cache_get( 'cached_keys', $group );
811 -
812 698 if ( ! $cached || ! is_array( $cached ) ) {
813 699 $cached = array();
814 700 }
815 701
@@ -818,12 +704,9 @@
818 704
819 705 /**
820 706 * @since 2.05.06
821 707 *
822 - * @param string $cache_key Cache key to delete.
823 - * @param string $group Cache group name.
824 - *
825 - * @return void
708 + * @param string $cache_key
826 709 */
827 710 public static function delete_cache_and_transient( $cache_key, $group = 'default' ) {
828 711 delete_transient( $cache_key );
829 712 wp_cache_delete( $cache_key, $group );
@@ -833,11 +716,9 @@
833 716 * Delete all caching in a single group
834 717 *
835 718 * @since 2.05.06
836 719 *
837 - * @param string $group The name of the cache group.
838 - *
839 - * @return void
720 + * @param string $group The name of the cache group
840 721 */
841 722 public static function cache_delete_group( $group ) {
842 723 $cached_keys = self::get_group_cached_keys( $group );
843 724
@@ -850,21 +731,27 @@
850 731 }
851 732 }
852 733
853 734 /**
854 - * Checks if a DB column exists.
855 - *
856 - * @since 6.7
857 - *
858 - * @param string $table Table name without `$wpdb->prefix`.
859 - * @param string $column Column name.
860 - *
861 - * @return bool
735 + * @deprecated 2.05.06
736 + * @codeCoverageIgnore
862 737 */
863 - public static function db_column_exists( $table, $column ) {
864 - global $wpdb;
738 + public function upgrade() {
739 + FrmDeprecated::upgrade();
740 + }
865 741
866 - // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
867 - $result = $wpdb->get_results( $wpdb->prepare( 'SHOW COLUMNS FROM ' . $wpdb->prefix . $table . ' LIKE %s', $column ) );
868 - return ! empty( $result );
742 + /**
743 + * @deprecated 2.05.06
744 + * @codeCoverageIgnore
745 + */
746 + public function collation() {
747 + return FrmDeprecated::collation();
748 + }
749 +
750 + /**
751 + * @deprecated 2.05.06
752 + * @codeCoverageIgnore
753 + */
754 + public function uninstall() {
755 + FrmDeprecated::uninstall();
869 756 }
870 757 }