Skip to content

Commit

Permalink
Add expiration to transient to prevent it from being autoloaded.
Browse files Browse the repository at this point in the history
  • Loading branch information
felixarntz committed Oct 12, 2023
1 parent 4414d8b commit d0f971f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/wp-includes/block-template-utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,7 @@ function _get_block_template_file_content( $template_file_path ) {
$template_data['template_content'][ $relative_path ] = file_get_contents( $template_file_path );

// Update the cache.
set_transient( 'wp_theme_template_contents_' . $theme->get_stylesheet(), $template_data );
set_transient( 'wp_theme_template_contents_' . $theme->get_stylesheet(), $template_data, WEEK_IN_SECONDS );

return $template_data['template_content'][ $relative_path ];
}
Expand Down
15 changes: 10 additions & 5 deletions tests/phpunit/tests/block-template-utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,8 @@ public function test_get_block_template_file_content_with_current_theme_file_rel
'template_content' => array(
'parts/small-header.html' => $forced_content,
),
)
),
WEEK_IN_SECONDS
);

$content = _get_block_template_file_content( $template_file );
Expand All @@ -705,7 +706,8 @@ public function test_get_block_template_file_content_with_another_theme_file_ign
'template_content' => array(
'templates/page-1.html' => $forced_content,
),
)
),
WEEK_IN_SECONDS
);

$content = _get_block_template_file_content( $template_file );
Expand All @@ -731,7 +733,8 @@ public function test_get_block_template_file_content_with_current_theme_file_ref
'template_content' => array(
'parts/small-header.html' => $forced_content,
),
)
),
WEEK_IN_SECONDS
);

$content = _get_block_template_file_content( $template_file );
Expand Down Expand Up @@ -772,7 +775,8 @@ public function test_get_block_template_file_content_with_current_theme_file_and
'template_content' => array(
'parts/small-header.html' => $forced_content,
),
)
),
WEEK_IN_SECONDS
);

$content = _get_block_template_file_content( $template_file );
Expand Down Expand Up @@ -801,7 +805,8 @@ public function test_get_block_template_file_content_with_theme_development_mode
'template_content' => array(
'parts/small-header.html' => '<div>Some content.</div>',
),
)
),
WEEK_IN_SECONDS
);

// We don't care about the value here as it is already covered by the test above.
Expand Down

0 comments on commit d0f971f

Please sign in to comment.