-
-
Notifications
You must be signed in to change notification settings - Fork 265
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pods 3.2.7 #7331
Pods 3.2.7 #7331
Changes from 16 commits
6d74f29
7ef89e5
e25db13
5e7b3cb
c347208
fe2671d
21cd97b
2d8c301
4a167c2
47b46f3
696f5a0
2fd7434
4bc165d
f9b84e1
247e180
bb596e5
efaa10c
4c8f25e
f76a670
013ea67
31d72b0
670079f
0ff135e
32d62a7
9357c2d
ff55e29
c9095f0
54e0020
0bace07
5aac0c6
a061600
c0f0663
2913b34
78c9a2f
d5c5c1b
76caf18
fea6f2d
4e5b0b1
db52c94
4a80b15
371a07b
b4f492c
5766add
8219d6e
69d4c3a
24f6bc1
f9f92d7
35e9f52
9171ecb
7e07a50
efa97df
68fc2bc
8b2b87c
32af949
b7c0a0f
7a35076
9f71c66
55fa1a1
9a16ab9
44e1cb0
c7d542d
5d26a32
3a5cf0a
6b3d4c5
2cf5a70
64e8dff
a749bce
6274a8e
091c677
a4c3365
3a45454
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,7 +22,7 @@ | |
* @property null|string $search Whether search is enabled. | ||
* @property null|string $search_var The query variable used for search. | ||
* @property null|string $search_mode The search mode to use. | ||
* @property null|string $params The last find() params. | ||
* @property null|array $params The last find() params. | ||
* @property null|string $sql The last find() SQL query. | ||
*/ | ||
class Pods implements Iterator { | ||
|
@@ -1349,6 +1349,14 @@ public function field( $name, $single = null, $raw = false ) { | |
|
||
$item_data = array(); | ||
|
||
// Debug purposes | ||
if ( 1 == pods_v( 'pods_debug_params_all', 'get', 0 ) && pods_is_admin( array( 'pods' ) ) ) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [phpcs] reported by reviewdog 🐶 |
||
pods_debug( __METHOD__ . ':' . __LINE__ ); | ||
pods_debug( $sql ); | ||
} else { | ||
pods_debug_log_data( $sql, 'related-find-params', __METHOD__, __LINE__ ); | ||
} | ||
|
||
if ( ! $related_obj || ! $related_obj->valid() ) { | ||
if ( ! is_object( $this->alt_data ) ) { | ||
$this->alt_data = pods_data(); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1745,12 +1745,12 @@ | |
if ( $load_params ) { | ||
$pod = $this->load_pod( $load_params ); | ||
|
||
if ( is_wp_error( $pod ) ) { | ||
Check failure on line 1748 in classes/PodsAPI.php GitHub Actions / phpstan / phpstan (8.3)
|
||
$pod = null; | ||
} | ||
|
||
if ( $fail_on_load ) { | ||
if ( is_wp_error( $pod ) ) { | ||
Check failure on line 1753 in classes/PodsAPI.php GitHub Actions / phpstan / phpstan (8.3)
|
||
return $pod; | ||
} elseif ( empty( $pod ) ) { | ||
return pods_error( __( 'Pod not found', 'pods' ), $this ); | ||
|
@@ -3285,7 +3285,7 @@ | |
if ( $load_params ) { | ||
$field_obj = $this->load_field( $load_params ); | ||
|
||
if ( $fail_on_load && ( empty( $field_obj ) || is_wp_error( $field_obj ) ) ) { | ||
Check failure on line 3288 in classes/PodsAPI.php GitHub Actions / phpstan / phpstan (8.3)
|
||
return $field_obj; | ||
} | ||
} | ||
|
@@ -4834,7 +4834,7 @@ | |
* | ||
* @since 2.3.19 | ||
*/ | ||
$track_changed_fields = apply_filters( "pods_api_save_pod_item_track_changed_fields_{$pod_name}", (boolean) $params->track_changed_fields, $params ); | ||
Check failure on line 4837 in classes/PodsAPI.php GitHub Actions / phpstan / phpstan (8.3)
Check failure on line 4837 in classes/PodsAPI.php GitHub Actions / phpstan / phpstan (8.2)
|
||
|
||
$changed_fields = array(); | ||
|
||
|
@@ -5088,7 +5088,7 @@ | |
* @param array $field_values The field values referenced. | ||
* @param object $params The save_pod_item parameters. | ||
*/ | ||
$is_visible = (bool) apply_filters( | ||
Check failure on line 5091 in classes/PodsAPI.php GitHub Actions / phpstan / phpstan (8.3)
Check failure on line 5091 in classes/PodsAPI.php GitHub Actions / phpstan / phpstan (8.2)
|
||
'pods_api_save_pod_item_conditional_logic_field_is_visible', | ||
$is_visible, | ||
$fields[ $active_field_name ], | ||
|
@@ -6204,7 +6204,7 @@ | |
|
||
if ( in_array( $mode, array( 'set', 'reset' ), true ) ) { | ||
if ( isset( $changed_fields_cache[ $cache_key ] ) ) { | ||
unset( $changed_fields_cache[ $cache_key ] ); | ||
Check failure on line 6207 in classes/PodsAPI.php GitHub Actions / phpstan / phpstan (8.3)
|
||
} | ||
|
||
if ( empty( $old_fields_cache[ $cache_key ] ) || 'reset' === $mode ) { | ||
|
@@ -9785,7 +9785,7 @@ | |
|
||
$related = get_comments( $comment_args ); | ||
|
||
if ( ! is_wp_error( $related ) ) { | ||
Check failure on line 9788 in classes/PodsAPI.php GitHub Actions / phpstan / phpstan (8.3)
|
||
$related_ids = $related; | ||
} | ||
} elseif ( | ||
|
@@ -10464,7 +10464,7 @@ | |
* @param array|Field $field The field config (if found). | ||
* @param self $obj The PodsAPI object. | ||
*/ | ||
return apply_filters( 'pods_api_get_table_info', $info, $object_type, $object, $name, $pod, $field, $this ); | ||
Check failure on line 10467 in classes/PodsAPI.php GitHub Actions / phpstan / phpstan (8.3)
Check failure on line 10467 in classes/PodsAPI.php GitHub Actions / phpstan / phpstan (8.2)
|
||
} else { | ||
// Data not cached, load it up | ||
$_info = $this->get_table_info_load( $object_type, $object, $name, $pod ); | ||
|
@@ -10580,7 +10580,7 @@ | |
* | ||
* @since unknown | ||
*/ | ||
$post_status = apply_filters( 'pods_api_get_table_info_default_post_status', $post_status, $post_type, $info, $object_type, $object, $name, $pod, $field ); | ||
Check failure on line 10583 in classes/PodsAPI.php GitHub Actions / phpstan / phpstan (8.3)
Check failure on line 10583 in classes/PodsAPI.php GitHub Actions / phpstan / phpstan (8.2)
|
||
|
||
$info['where'] = [ | ||
//'post_status' => "`t`.`post_status` IN ( 'inherit', 'publish' )", // @todo Figure out what statuses Attachments can be | ||
|
@@ -10993,7 +10993,7 @@ | |
*/ | ||
global $wpdb; | ||
|
||
if ( null === $format && null !== $this->format ) { | ||
Check failure on line 10996 in classes/PodsAPI.php GitHub Actions / phpstan / phpstan (8.3)
|
||
$format = $this->format; | ||
} | ||
|
||
|
@@ -11341,6 +11341,8 @@ | |
} else { | ||
// Do normal cache clear. | ||
pods_cache_clear( true ); | ||
|
||
wp_cache_flush(); | ||
} | ||
|
||
if ( $flush_rewrites ) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -639,24 +639,30 @@ public function delete( $table, $where, $where_format = null ) { | |
/** | ||
* Select items, eventually building dynamic query | ||
* | ||
* @param array $params | ||
* @param array|object $params | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [phpcs] reported by reviewdog 🐶 |
||
* | ||
* @return array|bool|mixed | ||
* @since 2.0.0 | ||
*/ | ||
public function select( $params ) { | ||
|
||
if ( is_array( $params ) ) { | ||
$params = (object) $params; | ||
} | ||
|
||
global $wpdb; | ||
|
||
$cache_key = false; | ||
$results = false; | ||
$cache_key = false; | ||
$cache_mode = 'cache'; | ||
$expires = 0; | ||
$results = false; | ||
|
||
$instance = $this; | ||
|
||
/** | ||
* Filter select parameters before the query | ||
* | ||
* @param array $params | ||
* @param object $params | ||
* @param PodsData $instance The current PodsData class instance. | ||
* | ||
* @since unknown | ||
|
@@ -665,17 +671,59 @@ public function select( $params ) { | |
|
||
// Debug purposes. | ||
if ( 1 === (int) pods_v( 'pods_debug_params', 'get', 0 ) && pods_is_admin( array( 'pods' ) ) ) { | ||
pods_debug( __METHOD__ . ':' . __LINE__ ); | ||
pods_debug( $params ); | ||
} else { | ||
pods_debug_log_data( $params, 'find-params', __METHOD__, __LINE__ ); | ||
} | ||
|
||
$debug_sql = ( 1 === (int) pods_v( 'pods_debug_sql', 'get', 0 ) || 1 === (int) pods_v( 'pods_debug_sql_all', 'get', 0 ) ) && pods_is_admin( array( 'pods' ) ); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [phpcs] reported by reviewdog 🐶 |
||
|
||
$total_found_cached = false; | ||
|
||
// Get from cache if enabled. | ||
if ( null !== pods_v( 'expires', $params, null, true ) ) { | ||
$cache_key = md5( (string) $this->pod . serialize( $params ) ); | ||
if ( ! $debug_sql && null !== pods_v( 'expires', $params, null, true ) ) { | ||
$cache_key = md5( (string) $this->pod . serialize( $params ) ); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [phpcs] reported by reviewdog 🐶 |
||
$cache_mode = pods_v( 'cache_mode', $params, 'cache', true ); | ||
$expires = (int) pods_v( 'expires', $params, 0 ); | ||
|
||
$results = pods_view_get( $cache_key, pods_v( 'cache_mode', $params, 'cache', true ), 'pods_data_select' ); | ||
$results = pods_view_get( $cache_key, $cache_mode, 'pods_data_select' ); | ||
$stats = pods_view_get( $cache_key, $cache_mode, 'pods_data_select_stats' ); | ||
|
||
if ( empty( $results ) ) { | ||
$results = false; | ||
} elseif ( ! empty( $stats ) ) { | ||
$this->total_found = $stats->total_found ?? null; | ||
$this->limit = (int) ( $stats->limit ?? 15 ); | ||
$this->page = (int) ( $stats->page ?? 1 ); | ||
$this->offset = (int) ( $stats->offset ?? 0 ); | ||
|
||
if ( null !== $this->total_found ) { | ||
$this->total_found_calculated = true; | ||
|
||
$total_found_cached = true; | ||
} | ||
} else { | ||
$params->calc_rows = false; | ||
|
||
// Attempt to calculate total found. | ||
$this->sql = $this->build( $params ); | ||
|
||
if ( $this->total_sql ) { | ||
$this->calculate_totals(); | ||
|
||
// Cache if enabled. | ||
if ( false !== $cache_key && $this->total_found_calculated ) { | ||
$stats = (object) [ | ||
'total_found' => $this->total_found, | ||
'limit' => $this->limit, | ||
'page' => $this->page, | ||
'offset' => $this->offset, | ||
]; | ||
|
||
pods_view_set( $cache_key, $stats, $expires, $cache_mode, 'pods_data_select_stats' ); | ||
} | ||
} | ||
} | ||
} | ||
|
||
|
@@ -684,12 +732,16 @@ public function select( $params ) { | |
$this->sql = $this->build( $params ); | ||
|
||
// Debug purposes. | ||
if ( ( 1 === (int) pods_v( 'pods_debug_sql', 'get', 0 ) || 1 === (int) pods_v( 'pods_debug_sql_all', 'get', 0 ) ) && pods_is_admin( array( 'pods' ) ) ) { | ||
if ( $debug_sql ) { | ||
pods_debug( __METHOD__ . ':' . __LINE__ ); | ||
|
||
if ( function_exists( 'codecept_debug' ) ) { | ||
pods_debug( $this->get_sql() ); | ||
} else { | ||
echo '<textarea cols="100" rows="24">' . esc_textarea( $this->get_sql() ) . '</textarea>'; | ||
} | ||
} else { | ||
pods_debug_log_data( $this->get_sql(), 'sql-select', __METHOD__, __LINE__ ); | ||
} | ||
|
||
if ( empty( $this->sql ) ) { | ||
|
@@ -701,7 +753,7 @@ public function select( $params ) { | |
|
||
// Cache if enabled. | ||
if ( false !== $cache_key ) { | ||
pods_view_set( $cache_key, $results, (int) pods_v( 'expires', $params, 0, false ), pods_v( 'cache_mode', $params, 'cache', true ), 'pods_data_select' ); | ||
pods_view_set( $cache_key, $results, $expires, $cache_mode, 'pods_data_select' ); | ||
} | ||
}//end if | ||
|
||
|
@@ -740,7 +792,9 @@ public function select( $params ) { | |
$this->row_number = - 1; | ||
$this->row = null; | ||
|
||
$this->total_found_calculated = false; | ||
if ( ! $total_found_cached ) { | ||
$this->total_found_calculated = false; | ||
} | ||
|
||
$this->total = 0; | ||
|
||
|
@@ -770,6 +824,10 @@ public function select( $params ) { | |
*/ | ||
public function calculate_totals() { | ||
|
||
if ( $this->total_found_calculated ) { | ||
return; | ||
} | ||
|
||
/** | ||
* @var $wpdb wpdb | ||
*/ | ||
|
@@ -1079,7 +1137,10 @@ public function build( $params ) { | |
$params->search = (boolean) $params->search; | ||
|
||
if ( 1 === (int) pods_v( 'pods_debug_params_all', 'get', 0 ) && pods_is_admin( array( 'pods' ) ) ) { | ||
pods_debug( __METHOD__ . ':' . __LINE__ ); | ||
pods_debug( $params ); | ||
} else { | ||
pods_debug_log_data( $params, 'find-params', __METHOD__, __LINE__ ); | ||
} | ||
|
||
$params->field_table_alias = 't'; | ||
|
@@ -2448,12 +2509,14 @@ public static function query( $sql, $error = 'Database Error', $results_error = | |
} | ||
} | ||
|
||
if ( pods_is_admin() && 1 === (int) pods_v( 'pods_debug_backtrace' ) ) { | ||
if ( 1 === (int) pods_v( 'pods_debug_backtrace' ) && pods_is_admin() ) { | ||
ob_start(); | ||
echo '<pre>'; | ||
var_dump( debug_backtrace( DEBUG_BACKTRACE_IGNORE_ARGS, 11 ) ); | ||
echo '</pre>'; | ||
$error = ob_get_clean() . $error; | ||
} else { | ||
pods_debug_log_data( debug_backtrace( DEBUG_BACKTRACE_IGNORE_ARGS, 11 ), 'sql-error', __METHOD__, __LINE__ ); | ||
} | ||
|
||
$params = (object) array( | ||
|
@@ -2488,10 +2551,15 @@ public static function query( $sql, $error = 'Database Error', $results_error = | |
} | ||
|
||
if ( 1 === (int) pods_v( 'pods_debug_sql_all', 'get', 0 ) && pods_is_admin( array( 'pods' ) ) ) { | ||
pods_debug( __METHOD__ . ':' . __LINE__ ); | ||
echo '<textarea cols="100" rows="24">' . esc_textarea( pods_data()->get_sql( $params->sql ) ) . '</textarea>'; | ||
} else { | ||
pods_debug_log_data( pods_data()->get_sql( $params->sql ), 'sql-query', __METHOD__, __LINE__ ); | ||
} | ||
|
||
}//end if | ||
} else { | ||
pods_debug_log_data( pods_data()->get_sql( $params->sql ), 'sql-query', __METHOD__, __LINE__ ); | ||
} | ||
|
||
$params->sql = trim( $params->sql ); | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[phpcs] reported by reviewdog 🐶
Squiz.Commenting.InlineComment.InvalidEndChar
Inline comments must end in full-stops, exclamation marks, or question marks