[wp-trac] [WordPress Trac] #42611: Validate get_post_templates() File Cache
WordPress Trac
noreply at wordpress.org
Fri Nov 17 21:40:56 UTC 2017
#42611: Validate get_post_templates() File Cache
----------------------------+-----------------------------
Reporter: Howdy_McGee | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: General | Version: 4.9
Severity: normal | Keywords:
Focuses: administration |
----------------------------+-----------------------------
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
[https://core.trac.wordpress.org/browser/tags/4.8/src/wp-includes/class-
wp-theme.php#L1048 `file_get_content()`]. I suggest we change LNL1048 to
the following:
{{{#!php
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.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/42611>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list