File tree Expand file tree Collapse file tree 2 files changed +45
-1
lines changed
tests/phpunit/tests/dependencies Expand file tree Collapse file tree 2 files changed +45
-1
lines changed Original file line number Diff line number Diff line change @@ -3081,7 +3081,18 @@ function wp_maybe_inline_styles() {
30813081 $ path = $ wp_styles ->get_data ( $ handle , 'path ' );
30823082 if ( $ path && $ src ) {
30833083 $ size = wp_filesize ( $ path );
3084- if ( ! $ size ) {
3084+ if ( 0 === $ size ) {
3085+ _doing_it_wrong (
3086+ __FUNCTION__ ,
3087+ sprintf (
3088+ /* translators: 1: 'path', 2: filesystem path, 3: style handle */
3089+ __ ( 'Unable to read the "%1$s" key with value "%2$s" for stylesheet "%3$s". ' ),
3090+ 'path ' ,
3091+ esc_html ( $ path ),
3092+ esc_html ( $ handle )
3093+ ),
3094+ '7.0.0 '
3095+ );
30853096 continue ;
30863097 }
30873098 $ styles [] = array (
@@ -3120,6 +3131,20 @@ static function ( $a, $b ) {
31203131
31213132 // Get the styles if we don't already have them.
31223133 $ style ['css ' ] = file_get_contents ( $ style ['path ' ] );
3134+ if ( false === $ style ['css ' ] ) {
3135+ _doing_it_wrong (
3136+ __FUNCTION__ ,
3137+ sprintf (
3138+ /* translators: 1: 'path', 2: filesystem path, 3: style handle */
3139+ __ ( 'Unable to read the "%1$s" key with value "%2$s" for stylesheet "%3$s". ' ),
3140+ 'path ' ,
3141+ esc_html ( $ style ['path ' ] ),
3142+ esc_html ( $ style ['handle ' ] )
3143+ ),
3144+ '7.0.0 '
3145+ );
3146+ continue ;
3147+ }
31233148
31243149 /*
31253150 * Check if the style contains relative URLs that need to be modified.
Original file line number Diff line number Diff line change @@ -768,6 +768,25 @@ public function test_wp_maybe_inline_styles_no_path() {
768768 $ this ->assertSame ( $ GLOBALS ['wp_styles ' ]->registered ['test-handle ' ]->src , $ url );
769769 }
770770
771+ /**
772+ * @ticket 64447
773+ *
774+ * @covers ::wp_maybe_inline_styles
775+ * @expectedIncorrectUsage wp_maybe_inline_styles
776+ */
777+ public function test_wp_maybe_inline_styles_bad_path () {
778+ $ handle = 'test-handle ' ;
779+ $ inc_path = '/css/ancient-themes.css ' ; // Does not exist.
780+ $ url = '/ ' . WPINC . $ inc_path ;
781+ wp_register_style ( $ handle , $ url );
782+ wp_style_add_data ( $ handle , 'path ' , ABSPATH . WPINC . $ inc_path );
783+ wp_enqueue_style ( $ handle );
784+
785+ wp_maybe_inline_styles ();
786+
787+ $ this ->assertSame ( $ GLOBALS ['wp_styles ' ]->registered [ $ handle ]->src , $ url );
788+ }
789+
771790 /**
772791 * @ticket 63887
773792 */
You can’t perform that action at this time.
0 commit comments