Skip to content

Pods 3.4.0 #7431

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

Draft
wants to merge 10 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
97 changes: 80 additions & 17 deletions classes/PodsAPI.php
Original file line number Diff line number Diff line change
Expand Up @@ -6632,6 +6632,7 @@
* $params['id'] int The Group ID.
* $params['name'] string The Group name.
* $params['new_name'] string The new Group name.
* $params['duplicate_fields'] bool Whether to duplicate the fields.
*
* @since 2.8.0
*
Expand Down Expand Up @@ -6670,7 +6671,11 @@
return false;
}

$pod_data = null;

if ( $group instanceof Group ) {
$pod_data = $group->get_parent_object();

$group = $group->export(
[
'include_fields' => true,
Expand Down Expand Up @@ -6701,7 +6706,13 @@

$fields = $group['fields'];

unset( $group['id'], $group['parent'], $group['object_type'], $group['object_storage_type'], $group['fields'] );
unset( $group['id'], $group['object_type'], $group['object_storage_type'], $group['fields'] );

if ( $pod_data ) {
unset( $group['parent'] );

$group['pod_data'] = $pod_data;
}

try {
$group_id = $this->save_group( $group );
Expand All @@ -6715,16 +6726,24 @@
return false;
}

foreach ( $fields as $field => $field_data ) {
unset( $field_data['id'], $field_data['parent'], $field_data['object_type'], $field_data['object_storage_type'], $field_data['group'] );
$group_data = $this->load_group( [ 'id' => $group_id ] );

$field_data['group_id'] = $group_id;
if ( ! empty( $params->duplicate_fields ) ) {
foreach ( $fields as $field_data ) {
try {
$field_params = [
'pod' => $pod_data,
'id' => $field_data['id'],
'name' => $field_data['name'],
'new_group' => $group_data,
'new_group_id' => $group_id,
];

try {
$this->save_field( $field_data );
} catch ( Exception $exception ) {
// Field not saved.
pods_debug_log( $exception );
$this->duplicate_field( $field_params, true || $strict );
} catch ( Exception $exception ) {
// Field not saved.
pods_debug_log( $exception );
}
}
}

Expand Down Expand Up @@ -11291,16 +11310,20 @@
* @param bool $flush_rewrites Whether to flush rewrites.
* @param bool $flush_groups_and_fields Whether to flush cache for groups and fields.
* @param bool $static_only Whether to flush only static caches.
* @param bool $flush_object_cache Whether to fully flush object caches.
* @param bool $delete_transients Whether to fully delete transients.
*
* @return void
*
* @since 2.0.0
*/
public function cache_flush_pods(
$pod = null,
$flush_rewrites = true,
$flush_groups_and_fields = true,
$static_only = false
bool $flush_rewrites = true,
bool $flush_groups_and_fields = true,
bool $static_only = false,
bool $flush_object_cache = false,
bool $delete_transients = false
) {

/**
Expand Down Expand Up @@ -11375,29 +11398,50 @@
pods_init()->refresh_existing_content_types_cache( true );

if ( ! $static_only ) {
// Delete transients in the database
// Delete transients in the database.
$wpdb->query( "DELETE FROM `{$wpdb->options}` WHERE `option_name` LIKE '_transient_pods%'" );
$wpdb->query( "DELETE FROM `{$wpdb->options}` WHERE `option_name` LIKE '_transient_timeout_pods%'" );

// Delete Pods Options Cache in the database
// Delete Pods Options Cache in the database.
$wpdb->query( "DELETE FROM `{$wpdb->options}` WHERE `option_name` LIKE '_pods_option_%'" );

if ( class_exists( \Pods_Unit_Tests\Pods_UnitTestCase::class ) ) {
// Maybe use the test-based cache flushing to prevent major slowdowns.
\Pods_Unit_Tests\Pods_UnitTestCase::flush_cache();
} else {
} else{
// Do normal cache clear.
pods_cache_clear( true );

wp_cache_flush();
// Maybe flush the full object cache.
if ( $flush_object_cache ) {
wp_cache_flush();
}

// Maybe delete all transients in the database.
if ( $delete_transients ) {
$wpdb->query( "DELETE FROM `{$wpdb->options}` WHERE `option_name` LIKE '_transient_%'" );
$wpdb->query( "DELETE FROM `{$wpdb->options}` WHERE `option_name` LIKE '_transient_timeout_%'" );
}
}

if ( $flush_rewrites ) {
pods_transient_set( 'pods_flush_rewrites', 1, WEEK_IN_SECONDS );
}
}

do_action( 'pods_cache_flushed' );
/**
* Allow hooking into the end of the Pods cache flush process.
*
* @since unknown
*
* @param array|Pod|null $pod The pod object or null of flushing general cache.
* @param bool $flush_rewrites Whether to flush rewrites.
* @param bool $flush_groups_and_fields Whether to flush cache for groups and fields.
* @param bool $static_only Whether to flush only static caches.
* @param bool $flush_object_cache Whether to fully flush object caches.
* @param bool $delete_transients Whether to fully delete transients.
*/
do_action( 'pods_cache_flushed', $pod, $flush_rewrites, $flush_groups_and_fields, $static_only, $flush_object_cache, $flush_transients );

Check failure on line 11444 in classes/PodsAPI.php

View workflow job for this annotation

GitHub Actions / phpstan / phpstan (8.3)

Undefined variable: $flush_transients
}

/**
Expand Down Expand Up @@ -11429,6 +11473,16 @@
pods_static_cache_clear( true, \Pods\Whatsit\Storage\Collection::class . '/find_objects' );
pods_static_cache_clear( true, \Pods\Whatsit\Storage\Post_Type::class . '/find_objects/any' );
}

/**
* Allow hooking into the end of the Pods cache flush for groups process.
*
* @since 3.3.2
*
* @param bool $flush_fields Whether to flush cache for fields.
* @param bool $static_only Whether to flush only static caches.
*/
do_action( 'pods_api_cache_flush_groups', $flush_fields, $static_only );
}

/**
Expand Down Expand Up @@ -11459,6 +11513,15 @@

pods_static_cache_clear( true, \Pods\Whatsit\Storage\Collection::class . '/find_objects' );
pods_static_cache_clear( true, \Pods\Whatsit\Storage\Post_Type::class . '/find_objects/any' );

/**
* Allow hooking into the end of the Pods cache flush for fields process.
*
* @since 3.3.2
*
* @param bool $static_only Whether to flush only static caches.
*/
do_action( 'pods_api_cache_flush_fields', $static_only );
}

/**
Expand Down
19 changes: 16 additions & 3 deletions classes/cli/PodsAPI_CLI_Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -343,15 +343,28 @@ public function deactivate_component( $args, $assoc_args ) {
/**
* Clear the Pods cache.
*
* [--skip-object-cache]
* : Skip flushing the full object cache (default: Flush full object cache).
*
* [--skip-transients]
* : Skip deleting all transients (default: Delete all transients).
*
* ## EXAMPLES
*
* wp pods-legacy-api clear-cache
*
* @subcommand clear-cache
*/
public function cache_clear() {

pods_api()->cache_flush_pods();
public function cache_clear( $args, $assoc_args ) {

pods_api()->cache_flush_pods(
null,
true,
true,
false,
empty( $assoc_args['skip-object-cache'] ),
empty( $assoc_args['skip-transients'] )
);

WP_CLI::success( __( 'Pods cache cleared', 'pods' ) );

Expand Down
4 changes: 2 additions & 2 deletions init.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* Plugin Name: Pods - Custom Content Types and Fields
* Plugin URI: https://pods.io/
* Description: Pods is a framework for creating, managing, and deploying customized content types and fields
* Version: 3.3.2
* Version: 3.4.0-a-1
* Author: Pods Framework Team
* Author URI: https://pods.io/about/
* Text Domain: pods
Expand Down Expand Up @@ -43,7 +43,7 @@
add_action( 'init', 'pods_deactivate_pods_ui' );
} else {
// Current version.
define( 'PODS_VERSION', '3.3.2' );
define( 'PODS_VERSION', '3.4.0-a-1' );

// Current database version, this is the last version the database changed.
define( 'PODS_DB_VERSION', '2.3.5' );
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pods",
"version": "3.3.2",
"version": "3.4.0-a-1",
"description": "Pods is a development framework for creating, extending, managing, and deploying customized content types in WordPress.",
"author": "Pods Foundation, Inc",
"homepage": "https://pods.io/",
Expand Down
2 changes: 1 addition & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Tags: pods, custom post types, custom taxonomies, content types, custom fields
Requires at least: 6.3
Tested up to: 6.8
Requires PHP: 7.2
Stable tag: 3.3.2
Stable tag: 3.4.0-a-1
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html

Expand Down
Loading
Loading