Skip to content

Commit d0f971f

Browse files
author
Felix Arntz
committed
Add expiration to transient to prevent it from being autoloaded.
1 parent 4414d8b commit d0f971f

2 files changed

Lines changed: 11 additions & 6 deletions

File tree

src/wp-includes/block-template-utils.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,7 @@ function _get_block_template_file_content( $template_file_path ) {
569569
$template_data['template_content'][ $relative_path ] = file_get_contents( $template_file_path );
570570

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

574574
return $template_data['template_content'][ $relative_path ];
575575
}

tests/phpunit/tests/block-template-utils.php

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -679,7 +679,8 @@ public function test_get_block_template_file_content_with_current_theme_file_rel
679679
'template_content' => array(
680680
'parts/small-header.html' => $forced_content,
681681
),
682-
)
682+
),
683+
WEEK_IN_SECONDS
683684
);
684685

685686
$content = _get_block_template_file_content( $template_file );
@@ -705,7 +706,8 @@ public function test_get_block_template_file_content_with_another_theme_file_ign
705706
'template_content' => array(
706707
'templates/page-1.html' => $forced_content,
707708
),
708-
)
709+
),
710+
WEEK_IN_SECONDS
709711
);
710712

711713
$content = _get_block_template_file_content( $template_file );
@@ -731,7 +733,8 @@ public function test_get_block_template_file_content_with_current_theme_file_ref
731733
'template_content' => array(
732734
'parts/small-header.html' => $forced_content,
733735
),
734-
)
736+
),
737+
WEEK_IN_SECONDS
735738
);
736739

737740
$content = _get_block_template_file_content( $template_file );
@@ -772,7 +775,8 @@ public function test_get_block_template_file_content_with_current_theme_file_and
772775
'template_content' => array(
773776
'parts/small-header.html' => $forced_content,
774777
),
775-
)
778+
),
779+
WEEK_IN_SECONDS
776780
);
777781

778782
$content = _get_block_template_file_content( $template_file );
@@ -801,7 +805,8 @@ public function test_get_block_template_file_content_with_theme_development_mode
801805
'template_content' => array(
802806
'parts/small-header.html' => '<div>Some content.</div>',
803807
),
804-
)
808+
),
809+
WEEK_IN_SECONDS
805810
);
806811

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

0 commit comments

Comments
 (0)