mirror of
git://develop.git.wordpress.org/
synced 2025-01-29 10:38:22 +01:00
Theme/Plugin Editor: Remove the caching added in [41806] as it causes more problems than it fixes.
While caching here seemed like a good idea in theory, in practice the cache would be often stale causing development issues. We exclude common folders (such as `node_modules`) from the scanning to avoid directories which are not useful to the end-user, so as long as those exclusion lists are held up this shouldn't cause too much of a degredation in the future. We may consider adding caching here again in the future if it's determined that it is really needed. Props precies, ibenic, mariovalney, schlessera, and all the others who commented on the ticket(s). This partually reverts [41806]. See #6531. Fixes #42573. git-svn-id: https://develop.svn.wordpress.org/trunk@42242 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
574821573a
commit
76f77416d6
@ -194,17 +194,6 @@ function get_plugin_files( $plugin ) {
|
||||
$plugin_file = WP_PLUGIN_DIR . '/' . $plugin;
|
||||
$dir = dirname( $plugin_file );
|
||||
|
||||
$data = get_plugin_data( $plugin_file );
|
||||
$label = isset( $data['Version'] )
|
||||
? sanitize_key( 'files_' . $plugin . '-' . $data['Version'] )
|
||||
: sanitize_key( 'files_' . $plugin );
|
||||
$transient_key = substr( $label, 0, 29 ) . md5( $label );
|
||||
|
||||
$plugin_files = get_transient( $transient_key );
|
||||
if ( false !== $plugin_files ) {
|
||||
return $plugin_files;
|
||||
}
|
||||
|
||||
$plugin_files = array( plugin_basename( $plugin_file ) );
|
||||
|
||||
if ( is_dir( $dir ) && WP_PLUGIN_DIR !== $dir ) {
|
||||
@ -225,8 +214,6 @@ function get_plugin_files( $plugin ) {
|
||||
$plugin_files = array_values( array_unique( $plugin_files ) );
|
||||
}
|
||||
|
||||
set_transient( $transient_key, $plugin_files, HOUR_IN_SECONDS );
|
||||
|
||||
return $plugin_files;
|
||||
}
|
||||
|
||||
|
@ -984,34 +984,10 @@ final class WP_Theme implements ArrayAccess {
|
||||
* being absolute paths.
|
||||
*/
|
||||
public function get_files( $type = null, $depth = 0, $search_parent = false ) {
|
||||
// get and cache all theme files to start with.
|
||||
$label = sanitize_key( 'files_' . $this->cache_hash . '-' . $this->get( 'Version' ) );
|
||||
$transient_key = substr( $label, 0, 29 ) . md5( $label );
|
||||
$files = (array) self::scandir( $this->get_stylesheet_directory(), $type, $depth );
|
||||
|
||||
$all_files = get_transient( $transient_key );
|
||||
if ( false === $all_files ) {
|
||||
$all_files = (array) self::scandir( $this->get_stylesheet_directory(), null, -1 );
|
||||
|
||||
if ( $search_parent && $this->parent() ) {
|
||||
$all_files += (array) self::scandir( $this->get_template_directory(), null, -1 );
|
||||
}
|
||||
|
||||
set_transient( $transient_key, $all_files, HOUR_IN_SECONDS );
|
||||
}
|
||||
|
||||
// Filter $all_files by $type & $depth.
|
||||
$files = array();
|
||||
if ( $type ) {
|
||||
$type = (array) $type;
|
||||
$_extensions = implode( '|', $type );
|
||||
}
|
||||
foreach ( $all_files as $key => $file ) {
|
||||
if ( $depth >= 0 && substr_count( $key, '/' ) > $depth ) {
|
||||
continue; // Filter by depth.
|
||||
}
|
||||
if ( ! $type || preg_match( '~\.(' . $_extensions . ')$~', $file ) ) { // Filter by type.
|
||||
$files[ $key ] = $file;
|
||||
}
|
||||
if ( $search_parent && $this->parent() ) {
|
||||
$files += (array) self::scandir( $this->get_template_directory(), $type, $depth );
|
||||
}
|
||||
|
||||
return $files;
|
||||
|
Loading…
x
Reference in New Issue
Block a user