Skip to content

Commit

Permalink
Revert changes based on feedback.
Browse files Browse the repository at this point in the history
  • Loading branch information
jonnynews committed Jan 9, 2024
1 parent 3cc7133 commit c1e9415
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 30 deletions.
22 changes: 16 additions & 6 deletions src/wp-includes/class-wp-theme.php
Original file line number Diff line number Diff line change
Expand Up @@ -1830,23 +1830,31 @@ public function get_block_template_folders() {
* @return array Block pattern data.
*/
public function get_block_patterns() {
$can_use_cached = ! wp_is_development_mode( 'theme' );

$pattern_data = $this->get_pattern_cache();
if ( is_array( $pattern_data ) ) {
return $pattern_data;
if ( $can_use_cached ) {
return $pattern_data;
}
// If in development mode, clear pattern cache.
$this->delete_pattern_cache();
}

$dirpath = $this->get_stylesheet_directory() . '/patterns/';
$pattern_data = array();

if ( ! file_exists( $dirpath ) ) {
$this->set_pattern_cache( $pattern_data );

if ( $can_use_cached ) {
$this->set_pattern_cache( $pattern_data );
}
return $pattern_data;
}
$files = glob( $dirpath . '*.php' );
if ( ! $files ) {
$this->set_pattern_cache( $pattern_data );

if ( $can_use_cached ) {
$this->set_pattern_cache( $pattern_data );
}
return $pattern_data;
}

Expand Down Expand Up @@ -1948,7 +1956,9 @@ public function get_block_patterns() {
$pattern_data[ $key ] = $pattern;
}

$this->set_pattern_cache( $pattern_data );
if ( $can_use_cached ) {
$this->set_pattern_cache( $pattern_data );
}

return $pattern_data;
}
Expand Down
7 changes: 1 addition & 6 deletions src/wp-includes/load.php
Original file line number Diff line number Diff line change
Expand Up @@ -882,12 +882,7 @@ function wp_start_object_cache() {
)
);

$non_persistent_groups = array( 'counts', 'plugins', 'theme_json' );
if ( wp_is_development_mode( 'theme' ) ) {
$non_persistent_groups[] = 'theme_files';
}

wp_cache_add_non_persistent_groups( $non_persistent_groups );
wp_cache_add_non_persistent_groups( array( 'counts', 'plugins', 'theme_json' ) );
}

$first_init = false;
Expand Down
14 changes: 2 additions & 12 deletions src/wp-includes/ms-blogs.php
Original file line number Diff line number Diff line change
Expand Up @@ -578,12 +578,7 @@ function switch_to_blog( $new_blog_id, $deprecated = null ) {
);
}

$non_persistent_groups = array( 'counts', 'plugins', 'theme_json' );
if ( wp_is_development_mode( 'theme' ) ) {
$non_persistent_groups[] = 'theme_files';
}

wp_cache_add_non_persistent_groups( $non_persistent_groups );
wp_cache_add_non_persistent_groups( array( 'counts', 'plugins', 'theme_json' ) );
}
}

Expand Down Expand Up @@ -677,12 +672,7 @@ function restore_current_blog() {
);
}

$non_persistent_groups = array( 'counts', 'plugins', 'theme_json' );
if ( wp_is_development_mode( 'theme' ) ) {
$non_persistent_groups[] = 'theme_files';
}

wp_cache_add_non_persistent_groups( $non_persistent_groups );
wp_cache_add_non_persistent_groups( array( 'counts', 'plugins', 'theme_json' ) );
}
}

Expand Down
7 changes: 1 addition & 6 deletions tests/phpunit/includes/abstract-testcase.php
Original file line number Diff line number Diff line change
Expand Up @@ -423,12 +423,7 @@ public static function flush_cache() {
)
);

$non_persistent_groups = array( 'counts', 'plugins', 'theme_json' );
if ( wp_is_development_mode( 'theme' ) ) {
$non_persistent_groups[] = 'theme_files';
}

wp_cache_add_non_persistent_groups( $non_persistent_groups );
wp_cache_add_non_persistent_groups( array( 'counts', 'plugins', 'theme_json' ) );
}

/**
Expand Down

0 comments on commit c1e9415

Please sign in to comment.