Changeset 61416
- Timestamp:
- 12/29/2025 06:59:20 PM (6 weeks ago)
- Location:
- trunk
- Files:
-
- 4 edited
-
src/wp-includes/script-loader.php (modified) (2 diffs)
-
tests/phpunit/tests/dependencies/styles.php (modified) (2 diffs)
-
tests/phpunit/tests/media.php (modified) (1 diff)
-
tests/phpunit/tests/template.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/script-loader.php
r61415 r61416 3011 3011 if ( $path && $src ) { 3012 3012 $size = wp_filesize( $path ); 3013 if ( ! $size ) { 3013 if ( 0 === $size && ! file_exists( $path ) ) { 3014 _doing_it_wrong( 3015 __FUNCTION__, 3016 sprintf( 3017 /* translators: 1: 'path', 2: filesystem path, 3: style handle */ 3018 __( 'Unable to read the "%1$s" key with value "%2$s" for stylesheet "%3$s".' ), 3019 'path', 3020 esc_html( $path ), 3021 esc_html( $handle ) 3022 ), 3023 '7.0.0' 3024 ); 3014 3025 continue; 3015 3026 } … … 3049 3060 3050 3061 // Get the styles if we don't already have them. 3062 if ( ! is_readable( $style['path'] ) ) { 3063 _doing_it_wrong( 3064 __FUNCTION__, 3065 sprintf( 3066 /* translators: 1: 'path', 2: filesystem path, 3: style handle */ 3067 __( 'Unable to read the "%1$s" key with value "%2$s" for stylesheet "%3$s".' ), 3068 'path', 3069 esc_html( $style['path'] ), 3070 esc_html( $style['handle'] ) 3071 ), 3072 '7.0.0' 3073 ); 3074 continue; 3075 } 3051 3076 $style['css'] = file_get_contents( $style['path'] ); 3052 3077 -
trunk/tests/phpunit/tests/dependencies/styles.php
r61411 r61416 717 717 /** 718 718 * @ticket 58394 719 * @ticket 64447 719 720 * 720 721 * @covers ::wp_maybe_inline_styles 721 */ 722 public function test_test_wp_maybe_inline_styles_missing_file() { 722 * @expectedIncorrectUsage wp_maybe_inline_styles 723 */ 724 public function test_wp_maybe_inline_styles_missing_file() { 723 725 $filter = new MockAction(); 724 726 add_filter( 'pre_wp_filesize', array( $filter, 'filter' ) ); … … 767 769 768 770 $this->assertSame( $GLOBALS['wp_styles']->registered['test-handle']->src, $url ); 771 } 772 773 /** 774 * @ticket 64447 775 * 776 * @covers ::wp_maybe_inline_styles 777 * @expectedIncorrectUsage wp_maybe_inline_styles 778 */ 779 public function test_wp_maybe_inline_styles_bad_path_with_file_size_provided() { 780 $style_path = '/css/invalid.css'; // Does not exist. 781 782 // This ensures the initial file size check is bypassed. 783 add_filter( 784 'pre_wp_filesize', 785 static function ( $size, $path ) use ( $style_path ) { 786 if ( str_contains( $path, $style_path ) ) { 787 $size = 1000; 788 } 789 return $size; 790 }, 791 10, 792 2 793 ); 794 795 $handle = 'test-handle'; 796 $url = '/' . WPINC . $style_path; 797 wp_register_style( $handle, $url ); 798 wp_style_add_data( $handle, 'path', ABSPATH . WPINC . $style_path ); 799 wp_enqueue_style( $handle ); 800 801 wp_maybe_inline_styles(); 802 803 $this->assertSame( $GLOBALS['wp_styles']->registered[ $handle ]->src, $url ); 804 } 805 806 /** 807 * @ticket 64447 808 * 809 * @covers ::wp_maybe_inline_styles 810 */ 811 public function test_wp_maybe_inline_styles_good_path_with_zero_file_size_provided() { 812 $style_path = '/css/classic-themes.css'; 813 814 // This simulates the file having a zero size. 815 add_filter( 816 'pre_wp_filesize', 817 static function ( $size, $path ) use ( $style_path ) { 818 if ( str_contains( $path, $style_path ) ) { 819 $size = 0; 820 } 821 return $size; 822 }, 823 10, 824 2 825 ); 826 827 $handle = 'test-handle'; 828 wp_register_style( $handle, '/' . WPINC . $style_path ); 829 wp_style_add_data( $handle, 'path', ABSPATH . WPINC . $style_path ); 830 wp_enqueue_style( $handle ); 831 832 wp_maybe_inline_styles(); 833 834 $this->assertFalse( $GLOBALS['wp_styles']->registered[ $handle ]->src ); 769 835 } 770 836 -
trunk/tests/phpunit/tests/media.php
r60971 r61416 6678 6678 */ 6679 6679 public function test_wp_enqueue_img_auto_sizes_contain_css_fix( ?Closure $set_up, bool $expected, ?string $expected_deprecated = null ): void { 6680 // These files are created as part of the build process, but the unit tests don't run the build prior to running unit tests on GHA. 6681 self::touch( ABSPATH . WPINC . '/css/dist/block-library/style.css' ); 6682 self::touch( ABSPATH . WPINC . '/css/dist/block-library/common.css' ); 6683 6680 6684 if ( $set_up ) { 6681 6685 $set_up(); -
trunk/tests/phpunit/tests/template.php
r61174 r61416 1678 1678 */ 1679 1679 public function test_wp_hoist_late_printed_styles( ?Closure $set_up, int $inline_size_limit, array $expected_styles ): void { 1680 // `_print_emoji_detection_script()` assumes `wp-includes/js/wp-emoji-loader.js` is present: 1681 self::touch( ABSPATH . WPINC . '/js/wp-emoji-loader.js' ); 1682 1680 1683 switch_theme( 'default' ); 1681 1684 global $wp_styles; … … 1712 1715 wp_should_load_separate_core_block_assets() ? 'css/dist/block-library/common.css' : 'css/dist/block-library/style.css' 1713 1716 ); 1717 $this->ensure_style_asset_file_created( 'wp-block-library-theme', 'css/dist/block-library/theme.css' ); 1718 1714 1719 if ( wp_should_load_separate_core_block_assets() ) { 1715 1720 $this->ensure_style_asset_file_created( 'wp-block-separator', 'blocks/separator/style.css' ); … … 1828 1833 $dependency->src = includes_url( $relative_path ); 1829 1834 $path = ABSPATH . WPINC . '/' . $relative_path; 1830 if ( ! file_exists( $path ) ) { 1831 $dir = dirname( $path ); 1832 if ( ! file_exists( $dir ) ) { 1833 mkdir( $dir, 0777, true ); 1834 } 1835 self::touch( $path ); 1836 if ( 0 === filesize( $path ) ) { 1835 1837 file_put_contents( $path, "/* CSS for $handle */" ); 1836 1838 }
Note: See TracChangeset
for help on using the changeset viewer.