Skip to content
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

Merged
merged 71 commits into from
Aug 28, 2024
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
6d74f29
Add fallback for clipboard.writeText
heybran Jun 21, 2024
7ef89e5
Toggle add file button on single file field
heybran Jun 21, 2024
e25db13
Set version to 3.2.7-a-1
sc0ttkclark Jul 22, 2024
5e7b3cb
Pick Sync Taxonomy: Checkbox & Unblock
pdclark Aug 15, 2024
c347208
Wrap pagination in a p tag instead of just spans
sc0ttkclark Aug 18, 2024
fe2671d
Add context to shortcode usage by Blocks
sc0ttkclark Aug 18, 2024
21cd97b
Add debug logging action-based support for Pods
sc0ttkclark Aug 18, 2024
2d8c301
Call wp_cache_flush() in addition to the normal clear Pods caches whe…
sc0ttkclark Aug 18, 2024
4a167c2
Adjust text for access rights message so it’s more clear
sc0ttkclark Aug 18, 2024
47b46f3
Support linking field values in the Pods Field Value block
sc0ttkclark Aug 18, 2024
696f5a0
Clean up PodsData::select() so that it can cache total found and othe…
sc0ttkclark Aug 18, 2024
2fd7434
Add new Pods Related Item List block to display items from a related …
sc0ttkclark Aug 18, 2024
4bc165d
Add more integration for Query Monitor and display Pods constants and…
sc0ttkclark Aug 18, 2024
f9b84e1
REST API fixes for working with the Pod object
sc0ttkclark Aug 18, 2024
247e180
Add Query Monitor CSS to allow filtering the debug log and move it in…
sc0ttkclark Aug 18, 2024
bb596e5
Fix inheritDoc usage
sc0ttkclark Aug 18, 2024
efaa10c
Update phpcs
sc0ttkclark Aug 18, 2024
4c8f25e
Update test
sc0ttkclark Aug 18, 2024
f76a670
Fix phpstan
sc0ttkclark Aug 18, 2024
013ea67
Phpstan fixes
sc0ttkclark Aug 18, 2024
31d72b0
Fix php issue
sc0ttkclark Aug 18, 2024
670079f
Fix phpstan exclude path
sc0ttkclark Aug 18, 2024
0ff135e
More phpstan fixes
sc0ttkclark Aug 18, 2024
32d62a7
Fix slug/id check for tests
sc0ttkclark Aug 18, 2024
9357c2d
Fix exists checks
sc0ttkclark Aug 18, 2024
ff55e29
Enqueue assets for QM through correct hook
sc0ttkclark Aug 19, 2024
c9095f0
Handle debug log calls more uniformly
sc0ttkclark Aug 19, 2024
54e0020
Support filter_var to handle namespacing search/filtering across diff…
sc0ttkclark Aug 19, 2024
0bace07
Update filters to always show select text even when value is set
sc0ttkclark Aug 19, 2024
5aac0c6
More debug points
sc0ttkclark Aug 19, 2024
a061600
Add source to block shortcode usage
sc0ttkclark Aug 19, 2024
c0f0663
Add QM backtrace support
sc0ttkclark Aug 19, 2024
2913b34
Filters work for shortcodes
sc0ttkclark Aug 19, 2024
78c9a2f
More debug points and pass shortcode inner content into template_cust…
sc0ttkclark Aug 19, 2024
d5c5c1b
Exclude static cache from nocache handling
sc0ttkclark Aug 19, 2024
76caf18
Reset items loop before running Pods template
sc0ttkclark Aug 19, 2024
fea6f2d
Add helpful filter functions
sc0ttkclark Aug 19, 2024
4e5b0b1
Discard changes to ui/js/dfv/pods-dfv.min.js
sc0ttkclark Aug 27, 2024
db52c94
Discard changes to ui/js/dfv/pods-dfv.min.asset.json
sc0ttkclark Aug 27, 2024
4a80b15
Discard changes to ui/js/blocks/pods-blocks-api.min.js
sc0ttkclark Aug 27, 2024
371a07b
Discard changes to ui/js/blocks/pods-blocks-api.min.asset.json
sc0ttkclark Aug 27, 2024
b4f492c
Fix: Add fallback for clipboard.writeText (#7314)
sc0ttkclark Aug 27, 2024
5766add
Discard changes to ui/js/blocks/pods-blocks-api.min.asset.json
sc0ttkclark Aug 27, 2024
8219d6e
Discard changes to ui/js/blocks/pods-blocks-api.min.js
sc0ttkclark Aug 27, 2024
69d4c3a
Discard changes to ui/js/dfv/pods-dfv.min.asset.json
sc0ttkclark Aug 27, 2024
24f6bc1
Discard changes to ui/js/dfv/pods-dfv.min.js
sc0ttkclark Aug 27, 2024
f9f92d7
Discard changes to ui/styles/dist/pods.css
sc0ttkclark Aug 27, 2024
35e9f52
Discard changes to ui/styles/dist/pods-form.css
sc0ttkclark Aug 27, 2024
9171ecb
Enhancement: Toggle add file button on single file field (#7315)
sc0ttkclark Aug 27, 2024
7e07a50
Auto rebuild assets
sc0ttkclark Aug 27, 2024
efa97df
Auto rebuild assets
PodsBot Aug 27, 2024
68fc2bc
Remove deprecated PHP support and add todos for complete code removal…
sc0ttkclark Aug 28, 2024
8b2b87c
Relationship Field Sync Taxonomy: Checkbox & Unblock Sync (#7336)
sc0ttkclark Aug 28, 2024
32af949
Further improve the Taxonomy sync option and include new option to hi…
sc0ttkclark Aug 28, 2024
b7c0a0f
Auto rebuild assets
sc0ttkclark Aug 28, 2024
7a35076
Fix invalid default value
JoryHogeveen Aug 22, 2024
9f71c66
Fix alignment (phpcs)
JoryHogeveen Aug 22, 2024
55fa1a1
Fix backcompat handling
sc0ttkclark Aug 28, 2024
9a16ab9
REST API Write access - Fix invalid default value (#7339)
sc0ttkclark Aug 28, 2024
44e1cb0
Improve REST authentication method
JoryHogeveen Aug 22, 2024
c7d542d
Fix phpcs
JoryHogeveen Aug 22, 2024
5d26a32
Use static cache so the REST user authenticated can be test-friendly
sc0ttkclark Aug 28, 2024
3a5cf0a
Improve REST authentication method when registering fields (#7341)
sc0ttkclark Aug 28, 2024
6b3d4c5
Wrap pagination for shortcode/block renders
sc0ttkclark Aug 28, 2024
2cf5a70
Add changelog for the release
sc0ttkclark Aug 28, 2024
64e8dff
Update version
sc0ttkclark Aug 28, 2024
a749bce
Update wporg version(s)
sc0ttkclark Aug 28, 2024
6274a8e
Use var to pass to pagination
sc0ttkclark Aug 28, 2024
091c677
Update TBD
sc0ttkclark Aug 28, 2024
a4c3365
Phpstan fixes
sc0ttkclark Aug 28, 2024
3a45454
Phpstan fixes
sc0ttkclark Aug 28, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion classes/Pods.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -1349,6 +1349,14 @@ public function field( $name, $single = null, $raw = false ) {

$item_data = array();

// Debug purposes
Copy link
Collaborator Author

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

if ( 1 == pods_v( 'pods_debug_params_all', 'get', 0 ) && pods_is_admin( array( 'pods' ) ) ) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[phpcs] reported by reviewdog 🐶
Generic.Arrays.DisallowLongArraySyntax.Found
Short array syntax must be used to define arrays

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();
Expand Down
2 changes: 2 additions & 0 deletions classes/PodsAPI.php
Original file line number Diff line number Diff line change
Expand Up @@ -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

View workflow job for this annotation

GitHub Actions / phpstan / phpstan (8.3)

is_wp_error(Pods\Whatsit\Pod|false) will always evaluate to false.

Check failure on line 1748 in classes/PodsAPI.php

View workflow job for this annotation

GitHub Actions / phpstan / phpstan (8.2)

is_wp_error(Pods\Whatsit\Pod|false) will always evaluate to false.
$pod = null;
}

if ( $fail_on_load ) {
if ( is_wp_error( $pod ) ) {

Check failure on line 1753 in classes/PodsAPI.php

View workflow job for this annotation

GitHub Actions / phpstan / phpstan (8.3)

is_wp_error(Pods\Whatsit\Pod|false) will always evaluate to false.

Check failure on line 1753 in classes/PodsAPI.php

View workflow job for this annotation

GitHub Actions / phpstan / phpstan (8.2)

is_wp_error(Pods\Whatsit\Pod|false) will always evaluate to false.
return $pod;
} elseif ( empty( $pod ) ) {
return pods_error( __( 'Pod not found', 'pods' ), $this );
Expand Down Expand Up @@ -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

View workflow job for this annotation

GitHub Actions / phpstan / phpstan (8.3)

is_wp_error(Pods\Whatsit\Field|true) will always evaluate to false.

Check failure on line 3288 in classes/PodsAPI.php

View workflow job for this annotation

GitHub Actions / phpstan / phpstan (8.2)

is_wp_error(Pods\Whatsit\Field|true) will always evaluate to false.
return $field_obj;
}
}
Expand Down Expand Up @@ -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

View workflow job for this annotation

GitHub Actions / phpstan / phpstan (8.3)

Expected 2 @param tags, found 1.

Check failure on line 4837 in classes/PodsAPI.php

View workflow job for this annotation

GitHub Actions / phpstan / phpstan (8.2)

Expected 2 @param tags, found 1.

$changed_fields = array();

Expand Down Expand Up @@ -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

View workflow job for this annotation

GitHub Actions / phpstan / phpstan (8.3)

@param Pods\Whatsit\Field $field does not accept actual type of parameter: Pods\API\Whatsit\Value_Field.

Check failure on line 5091 in classes/PodsAPI.php

View workflow job for this annotation

GitHub Actions / phpstan / phpstan (8.2)

@param Pods\Whatsit\Field $field does not accept actual type of parameter: Pods\API\Whatsit\Value_Field.
'pods_api_save_pod_item_conditional_logic_field_is_visible',
$is_visible,
$fields[ $active_field_name ],
Expand Down Expand Up @@ -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

View workflow job for this annotation

GitHub Actions / phpstan / phpstan (8.3)

Cannot unset offset non-falsy-string on array{}|true.

Check failure on line 6207 in classes/PodsAPI.php

View workflow job for this annotation

GitHub Actions / phpstan / phpstan (8.2)

Cannot unset offset non-falsy-string on array{}|true.
}

if ( empty( $old_fields_cache[ $cache_key ] ) || 'reset' === $mode ) {
Expand Down Expand Up @@ -9785,7 +9785,7 @@

$related = get_comments( $comment_args );

if ( ! is_wp_error( $related ) ) {

Check failure on line 9788 in classes/PodsAPI.php

View workflow job for this annotation

GitHub Actions / phpstan / phpstan (8.3)

is_wp_error(array<int|WP_Comment>|int) will always evaluate to false.

Check failure on line 9788 in classes/PodsAPI.php

View workflow job for this annotation

GitHub Actions / phpstan / phpstan (8.2)

is_wp_error(array<int|WP_Comment>|int) will always evaluate to false.
$related_ids = $related;
}
} elseif (
Expand Down Expand Up @@ -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

View workflow job for this annotation

GitHub Actions / phpstan / phpstan (8.3)

@param string $name does not accept actual type of parameter: null.

Check failure on line 10467 in classes/PodsAPI.php

View workflow job for this annotation

GitHub Actions / phpstan / phpstan (8.2)

@param string $name does not accept actual type of parameter: null.
} else {
// Data not cached, load it up
$_info = $this->get_table_info_load( $object_type, $object, $name, $pod );
Expand Down Expand Up @@ -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

View workflow job for this annotation

GitHub Actions / phpstan / phpstan (8.3)

Expected 8 @param tags, found 7.

Check failure on line 10583 in classes/PodsAPI.php

View workflow job for this annotation

GitHub Actions / phpstan / phpstan (8.2)

Expected 8 @param tags, found 7.

$info['where'] = [
//'post_status' => "`t`.`post_status` IN ( 'inherit', 'publish' )", // @todo Figure out what statuses Attachments can be
Expand Down Expand Up @@ -10993,7 +10993,7 @@
*/
global $wpdb;

if ( null === $format && null !== $this->format ) {

Check failure on line 10996 in classes/PodsAPI.php

View workflow job for this annotation

GitHub Actions / phpstan / phpstan (8.3)

Access to deprecated property $format of class PodsAPI: 2.0.0

Check failure on line 10996 in classes/PodsAPI.php

View workflow job for this annotation

GitHub Actions / phpstan / phpstan (8.2)

Access to deprecated property $format of class PodsAPI: 2.0.0
$format = $this->format;
}

Expand Down Expand Up @@ -11341,6 +11341,8 @@
} else {
// Do normal cache clear.
pods_cache_clear( true );

wp_cache_flush();
}

if ( $flush_rewrites ) {
Expand Down
3 changes: 3 additions & 0 deletions classes/PodsComponents.php
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,10 @@ public function get_components() {
}//end if

if ( 1 === (int) pods_v( 'pods_debug_components', 'get', 0 ) && pods_is_admin( array( 'pods' ) ) ) {
pods_debug( __METHOD__ . ':' . __LINE__ );
pods_debug( $components );
} else {
pods_debug_log_data( $components, 'components', __METHOD__, __LINE__ );
}

$this->components = $components;
Expand Down
92 changes: 80 additions & 12 deletions classes/PodsData.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Collaborator Author

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.FunctionComment.MissingParamComment
Missing parameter comment

*
* @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
Expand All @@ -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' ) );
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[phpcs] reported by reviewdog 🐶
Generic.Arrays.DisallowLongArraySyntax.Found
Short array syntax must be used to define arrays


$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 ) );
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[phpcs] reported by reviewdog 🐶
WordPress.PHP.DiscouragedPHPFunctions.serialize_serialize
serialize() found. Serialized data has known vulnerability problems with Object Injection. JSON is generally a better approach for serializing data. See https://www.owasp.org/index.php/PHP_Object_Injection

$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' );
}
}
}
}

Expand All @@ -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 ) ) {
Expand All @@ -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

Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -770,6 +824,10 @@ public function select( $params ) {
*/
public function calculate_totals() {

if ( $this->total_found_calculated ) {
return;
}

/**
* @var $wpdb wpdb
*/
Expand Down Expand Up @@ -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';
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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 );

Expand Down
31 changes: 8 additions & 23 deletions classes/PodsInit.php
Original file line number Diff line number Diff line change
Expand Up @@ -1030,6 +1030,8 @@ public function refresh_existing_content_types_cache( $force = false ) {

if ( 1 === (int) pods_v( 'pods_debug_register', 'get', 0 ) && pods_is_admin( array( 'pods' ) ) ) {
pods_debug( [ __METHOD__, compact( 'existing_post_types_cached', 'existing_taxonomies_cached' ) ] );
} else {
pods_debug_log_data( compact( 'existing_post_types_cached', 'existing_taxonomies_cached' ), 'register-existing', __METHOD__, __LINE__ );
}

return compact( 'existing_post_types_cached', 'existing_taxonomies_cached' );
Expand Down Expand Up @@ -1648,6 +1650,8 @@ public function setup_content_types( $force = false ) {

if ( 1 === (int) pods_v( 'pods_debug_register', 'get', 0 ) && pods_is_admin( array( 'pods' ) ) ) {
pods_debug( [ __METHOD__ . '/register_taxonomy', compact( 'taxonomy', 'ct_post_types', 'options' ) ] );
} else {
pods_debug_log_data( compact( 'taxonomy', 'ct_post_types', 'options' ), 'register-taxonomy', __METHOD__, __LINE__ );
}

if ( 1 === (int) pods_v( 'pods_debug_register_export', 'get', 0 ) && pods_is_admin( array( 'pods' ) ) ) {
Expand Down Expand Up @@ -1701,6 +1705,8 @@ public function setup_content_types( $force = false ) {

if ( 1 === (int) pods_v( 'pods_debug_register', 'get', 0 ) && pods_is_admin( array( 'pods' ) ) ) {
pods_debug( [ __METHOD__ . '/register_post_type', compact( 'post_type', 'options' ) ] );
} else {
pods_debug_log_data( compact( 'post_type', 'options' ), 'register-post-type', __METHOD__, __LINE__ );
}

if ( 1 === (int) pods_v( 'pods_debug_register_export', 'get', 0 ) && pods_is_admin( array( 'pods' ) ) ) {
Expand Down Expand Up @@ -1793,7 +1799,7 @@ public function setup_content_types( $force = false ) {
$rest_enabled = (boolean) pods_v( 'rest_enable', $pod, false );

if ( $rest_enabled ) {
new PodsRESTFields( $pod['name'] );
new PodsRESTFields( $pod );
}
}

Expand All @@ -1803,7 +1809,7 @@ public function setup_content_types( $force = false ) {
$rest_enabled = (boolean) pods_v( 'rest_enable', $pod, false );

if ( $rest_enabled ) {
new PodsRESTFields( $pod['name'] );
new PodsRESTFields( $pod );
}
}

Expand Down Expand Up @@ -2479,9 +2485,6 @@ public function run() {
// Compatibility with WP 5.4 privacy export.
add_filter( 'wp_privacy_additional_user_profile_data', array( $this, 'filter_wp_privacy_additional_user_profile_data' ), 10, 3 );

// Compatibility for Query Monitor conditionals
add_filter( 'query_monitor_conditionals', array( $this, 'filter_query_monitor_conditionals' ) );

// Support for quick edit in WP 6.4+.
add_filter( 'quick_edit_enabled_for_post_type', [ $this, 'quick_edit_enabled_for_post_type' ], 10, 2 );
add_filter( 'quick_edit_enabled_for_taxonomy', [ $this, 'quick_edit_enabled_for_taxonomy' ], 10, 2 );
Expand Down Expand Up @@ -2726,22 +2729,4 @@ public function filter_wp_privacy_additional_user_profile_data( $additional_user

return $additional_user_profile_data;
}

/**
* Add Pods conditional functions to Query Monitor.
*
* @param array $conditionals
* @return array
*/
public function filter_query_monitor_conditionals( $conditionals ) {
$conditionals[] = 'pods_developer';
$conditionals[] = 'pods_tableless';
$conditionals[] = 'pods_light';
$conditionals[] = 'pods_strict';
$conditionals[] = 'pods_allow_deprecated';
$conditionals[] = 'pods_api_cache';
$conditionals[] = 'pods_shortcode_allow_evaluate_tags';
$conditionals[] = 'pods_session_auto_start';
return $conditionals;
}
}
42 changes: 23 additions & 19 deletions classes/PodsRESTHandlers.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,29 +17,33 @@ class PodsRESTHandlers {
*
* @var Pods
*/
private static $pod;
private static $pods = false;

/**
* Get Pod object
* Get the Pods object.
*
* @since 2.5.6
*
* @param $pod_name
* @param $id
* @param string $pod_name The pod name.
* @param string|int $id The item ID.
*
* @return bool|Pods
* @return bool|Pods The Pods object or false if not found.
*/
protected static function get_pod( $pod_name, $id ) {
public static function get_pods_object( $pod_name, $id ) {

if ( ! self::$pod || self::$pod->pod !== $pod_name ) {
self::$pod = pods_get_instance( $pod_name, $id, true );
if ( ! self::$pods || self::$pods->pod !== $pod_name ) {
self::$pods = pods_get_instance( $pod_name, $id, true );
}

if ( self::$pod && (int) self::$pod->id !== (int) $id ) {
self::$pod->fetch( $id );
if ( self::$pods && (int) self::$pods->id !== (int) $id ) {
self::$pods->fetch( $id );
}

return self::$pod;
if ( ! self::$pods->exists() ) {
return false;
}

return self::$pods;

}

Expand Down Expand Up @@ -81,15 +85,15 @@ public static function get_handler( $object, $field_name, $request, $object_type
}

/**
* Filter the pod name
* Filter the pod name for the REST API handler.
*
* @since 2.6.7
*
* @param array $pod_name Pod name
* @param Pods $object Rest object
* @param string $field_name Name of the field
* @param WP_REST_Request $request Current request
* @param string $object_type Rest Object type
* @param array $pod_name The Pod name.
* @param array $object The REST object.
* @param string $field_name The name of the field.
* @param WP_REST_Request $request The current request.
* @param string $object_type The REST object type.
*/
$pod_name = apply_filters( 'pods_rest_api_pod_name', $pod_name, $object, $field_name, $request, $object_type );

Expand All @@ -99,7 +103,7 @@ public static function get_handler( $object, $field_name, $request, $object_type
$id = pods_v( 'ID', $object );
}

$pod = self::get_pod( $pod_name, $id );
$pod = self::get_pods_object( $pod_name, $id );

$value = false;

Expand Down Expand Up @@ -267,7 +271,7 @@ public static function save_handler( $object, $request, $creating ) {
$pod_name = 'media';
}

$pod = self::get_pod( $pod_name, $id );
$pod = self::get_pods_object( $pod_name, $id );

global $wp_rest_additional_fields;

Expand Down
Loading
Loading