WordPress.org

Make WordPress Core

#45739 closed defect (bug) (fixed)

Block Editor: $editor_styles bug.

Reported by: gqevu6bsiz Owned by: pento
Milestone: 5.2.3 Priority: normal
Severity: normal Version: 5.0.2
Component: Editor Keywords: needs-testing fixed-major
Focuses: Cc:

Description

WP 5.0.2 with TwentySeventeen, it is PHP Warning error on Post Edit/Add New Post screen.

PHP Warning: file_get_contents(/wp-content/themes/twentyseventeen): failed to open stream: Permission denied in wp-admin/edit-form-blocks.php on line 200

It seems to editor_style file is nothing. This problem looks like TwentySeventeen, but I think it would be better to empty check for all themes.

And TwentyNinteen, activate to Classic Editor is not get same problem.

Example To

	foreach ( $editor_styles as $style ) {
>>                if ( empty( $style ) ) {
>>                    continue;
>>                }
		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 ),
				);
			}
		}
        }

Change History (5)

#1 @SergeyBiryukov
8 months ago

  • Component changed from General to Editor

#2 @pento
6 weeks ago

  • Milestone changed from Awaiting Review to 5.3
  • Owner set to pento
  • Status changed from new to assigned

#3 @pento
6 weeks ago

  • Resolution set to fixed
  • Status changed from assigned to closed

In 45619:

Block Editor: Avoid a PHP warning when a theme adds an editor style with an empty filename.

Fixes #45739.

#4 @JeffPaul
3 days ago

  • Keywords needs-testing fixed-major added
  • Milestone changed from 5.3 to 5.2.3
  • Resolution fixed deleted
  • Status changed from closed to reopened

Reopening this so it can be back-ported to the 5.2 branch, also needs testing to validate if this ticket is good to land in 5.2.3.

#5 @SergeyBiryukov
68 minutes ago

  • Resolution set to fixed
  • Status changed from reopened to closed

In 45829:

Block Editor: Avoid a PHP warning when a theme adds an editor style with an empty filename.

Props pento, gqevu6bsiz.
Merges [45619] to the 5.2 branch.
Fixes #45739.

Note: See TracTickets for help on using tickets.