WordPress.org

Make WordPress Core

Opened 6 months ago

Closed 6 months ago

#42611 closed defect (bug) (duplicate)

Validate get_post_templates() File Cache

Reported by: Howdy_McGee Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.9
Component: General Keywords:
Focuses: administration Cc:

Description

The WP_Theme Class method get_files() caches the all the theme's files. Whenever anything calls WP_Theme->get_post_templates() it pulls from the transient but whenever looping through the file it does not verify the cached file exists before calling `file_get_content()`. I suggest we change LNL1048 to the following:

if ( ! ( file_exists( $full_path ) && preg_match( '|Template Name:(.*)$|mi', file_get_contents( $full_path ), $header ) ) ) {
        continue;
}

If a file is removed within the hour cache limit, Pages Post Templates throw out some errors.

Attachments (1)

post-templates-error.jpg (66.5 KB) - added by Howdy_McGee 6 months ago.
WP_Theme Post Template Errors

Download all attachments as: .zip

Change History (2)

@Howdy_McGee
6 months ago

WP_Theme Post Template Errors

#1 @Clorith
6 months ago

  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed

Duplicate of #42573

Note: See TracTickets for help on using tickets.