| @@ -252,9 +252,9 @@ | ||
| 252 | 252 | * @param string $field |
| 253 | 253 | * @param array $args |
| 254 | 254 | * @param string $limit |
| 255 | 255 | * |
| 256 | - * @return array | |
| 256 | + * @return mixed | |
| 257 | 257 | */ |
| 258 | 258 | public static function get_col( $table, $where = array(), $field = 'id', $args = array(), $limit = '' ) { |
| 259 | 259 | return self::get_var( $table, $where, $field, $args, $limit, 'col' ); |
| 260 | 260 | } |
| @@ -270,8 +270,9 @@ | ||
| 270 | 270 | * @return mixed |
| 271 | 271 | */ |
| 272 | 272 | public static function get_row( $table, $where = array(), $fields = '*', $args = array() ) { |
| 273 | 273 | $args['limit'] = 1; |
| 274 | + | |
| 274 | 275 | return self::get_var( $table, $where, $fields, $args, '', 'row' ); |
| 275 | 276 | } |
| 276 | 277 | |
| 277 | 278 | /** |
| @@ -283,9 +284,9 @@ | ||
| 283 | 284 | * @param array $where |
| 284 | 285 | * @param string $fields |
| 285 | 286 | * @param array $args |
| 286 | 287 | * |
| 287 | - * @return array | |
| 288 | + * @return mixed | |
| 288 | 289 | */ |
| 289 | 290 | public static function get_results( $table, $where = array(), $fields = '*', $args = array() ) { |
| 290 | 291 | return self::get_var( $table, $where, $fields, $args, '', 'results' ); |
| 291 | 292 | } |
| @@ -440,8 +441,15 @@ | ||
| 440 | 441 | if ( is_array( $where ) || empty( $where ) ) { |
| 441 | 442 | self::get_where_clause_and_values( $where ); |
| 442 | 443 | global $wpdb; |
| 443 | 444 | $query = $wpdb->prepare( $query . $where['where'] . ' ' . implode( ' ', $args ), $where['values'] ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared |
| 445 | + } else { | |
| 446 | + /** | |
| 447 | + * Allow the $where to be prepared before we receive it here. | |
| 448 | + * This is a fallback for reverse compatibility, but is not recommended | |
| 449 | + */ | |
| 450 | + _deprecated_argument( 'where', '2.0', esc_html__( 'Use the query in an array format so it can be properly prepared.', 'formidable' ) ); | |
| 451 | + $query .= $where . ' ' . implode( ' ', $args ); | |
| 444 | 452 | } |
| 445 | 453 | |
| 446 | 454 | return $query; |
| 447 | 455 | } |
| @@ -654,18 +662,16 @@ | ||
| 654 | 662 | * |
| 655 | 663 | * @return mixed $results The cache or query results |
| 656 | 664 | */ |
| 657 | 665 | public static function check_cache( $cache_key, $group = '', $query = '', $type = 'get_var', $time = 300 ) { |
| 658 | - $found = null; | |
| 659 | - $results = wp_cache_get( $cache_key, $group, false, $found ); | |
| 660 | - | |
| 661 | - if ( ( $found === true && $results !== false ) || empty( $query ) ) { | |
| 666 | + $results = wp_cache_get( $cache_key, $group ); | |
| 667 | + if ( ! FrmAppHelper::is_empty_value( $results, false ) || empty( $query ) ) { | |
| 662 | 668 | return $results; |
| 663 | 669 | } |
| 664 | 670 | |
| 665 | 671 | if ( 'get_posts' == $type ) { |
| 666 | 672 | $results = get_posts( $query ); |
| 667 | - } elseif ( 'get_associative_results' === $type ) { | |
| 673 | + } elseif ( 'get_associative_results' == $type ) { | |
| 668 | 674 | global $wpdb; |
| 669 | 675 | $results = $wpdb->get_results( $query, OBJECT_K ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared |
| 670 | 676 | } else { |
| 671 | 677 | global $wpdb; |