Opened 6 years ago
Closed 19 months ago
#45880 closed defect (bug) (duplicate)
Twenty Seventeen: edit-form-blocks.php shows Warning when $editor_styles include blank element.
Reported by: | atachibana | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 5.0.2 |
Component: | Bundled Theme | Keywords: | has-patch |
Focuses: | Cc: |
Description
Environment:
- Windows 10 Japanese (64bit) UAC off
- XAMPP for Windows 7.3 (PHP 7.3)
- WordPress 5.0.2
- Theme: Twenty Seventeen
- Plugin: None
Reproduction:
- Setup WordPress on Windows (XAMPP environment).
- Select Twenty Seventeen Theme
- Select Japanese from Language Settings ('日本語')
- Select New Post ('投稿' > '新規追加')
You will see Warning messages are flushed twice with same message but different format, and editor screen is displayed (See attached images for real displayed strings)
Warning: file_get_contents(C:\xampp\htdocs\wordpress/wp-content/themes/twentyseventeen): failed to open stream: Permission denied in C:\xampp\htdocs\wordpress\wp-admin\edit-form-blocks.php on line 200
This warning is not shown
- if language is English, or
- if theme is Twenty Nineteen or Twenty Sixteen, or
- if Classic Editor
Attachments (4)
Change History (8)
#1
@
6 years ago
The global variable $editor_styles
in English settings has font information in 2nd element:
( [0] => assets/css/editor-style.css [1] => https://fonts.googleapis.com/css?family=Libre+Franklin%3A300%2C300i%2C400%2C400i%2C600%2C600i%2C800%2C800i&subset=latin%2Clatin-ext )
But in Japanese environment no value.
( [0] => assets/css/editor-style.css [1] => )
This blank value failed at preg_match
and reached the error point in below sentences at wp-admin/edit-form-blocks.php line 200.
if ( $editor_styles && current_theme_supports( 'editor-styles' ) ) { foreach ( $editor_styles as $style ) { if ( preg_match( '~^(https?:)?//~', $style ) ) { $response = wp_remote_get( $style ); if ( ! is_wp_error( $response ) ) { $styles[] = array( 'css' => wp_remote_retrieve_body( $response ), ); } } else { $file = get_theme_file_path( $style ); if ( file_exists( $file ) ) { $styles[] = array( 'css' => file_get_contents( $file ), 'baseURL' => get_theme_file_uri( $style ), ); } } } }
I'll investigate who set the global variable $editor_styles
and why 2nd element is null only when Japanese Windows. It must be font settings issue...
#2
@
6 years ago
- Component changed from Themes to Editor
- Keywords has-patch added
- Summary changed from Twenty Seventeen shows warning: file_get_contents when new post/page creation in Japanese Settings to edit-form-blocks.php shows Warning when $editor_styles include blank element.
This issue was common thing, not Windows nor Japanese related.
The global array variable $editor_styles
keeps editor-style.css and font URI information as described in the above comment, but they might be blank string with some reason. Refer Twenty Seventeen's twentyseventeen_fonts_url().
Current edit-form-blocks.php assumes two elements of $editor_styles are not blank and causes this issue. String check should be included.
foreach ( $editor_styles as $style ) { if ( preg_match( '~^(https?:)?//~', $style ) ) { : // } else { // OLD } elseif ( $style ) { // NEW :
#3
@
4 years ago
- Component changed from Editor to Bundled Theme
Thanks for reporting this @atachibana! I wasn't able to reproduce this by setting my language to Japanese, but I agree there's a logic error in the code you linked to.
Instead of checking that the string exists in edit-form-blocks.php
, I think we should instead patch Twenty Seventeen so that it doesn't pass an array containing an empty string to add_editor_style()
.
45880.diff demonstrates what I mean.
#4
@
19 months ago
- Milestone Awaiting Review deleted
- Resolution set to duplicate
- Status changed from new to closed
- Summary changed from edit-form-blocks.php shows Warning when $editor_styles include blank element. to Twenty Seventeen: edit-form-blocks.php shows Warning when $editor_styles include blank element.
#1 shown warning