Make WordPress Core

Changeset 42243


Ignore:
Timestamp:
11/27/2017 02:59:27 AM (7 years ago)
Author:
dd32
Message:

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].
Merges [42242] to the 4.9 branch.
See #6531.
Fixes #42573 for 4.9.

Location:
branches/4.9
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/4.9

  • branches/4.9/src/wp-admin/includes/plugin.php

    r41819 r42243  
    195195    $dir = dirname( $plugin_file );
    196196
    197     $data = get_plugin_data( $plugin_file );
    198     $label = isset( $data['Version'] )
    199         ? sanitize_key( 'files_' . $plugin . '-' . $data['Version'] )
    200         : sanitize_key( 'files_' . $plugin );
    201     $transient_key = substr( $label, 0, 29 ) . md5( $label );
    202 
    203     $plugin_files = get_transient( $transient_key );
    204     if ( false !== $plugin_files ) {
    205         return $plugin_files;
    206     }
    207 
    208197    $plugin_files = array( plugin_basename( $plugin_file ) );
    209198
     
    225214        $plugin_files = array_values( array_unique( $plugin_files ) );
    226215    }
    227 
    228     set_transient( $transient_key, $plugin_files, HOUR_IN_SECONDS );
    229216
    230217    return $plugin_files;
  • branches/4.9/src/wp-includes/class-wp-theme.php

    r41975 r42243  
    985985     */
    986986    public function get_files( $type = null, $depth = 0, $search_parent = false ) {
    987         // get and cache all theme files to start with.
    988         $label = sanitize_key( 'files_' . $this->cache_hash . '-' . $this->get( 'Version' ) );
    989         $transient_key = substr( $label, 0, 29 ) . md5( $label );
    990 
    991         $all_files = get_transient( $transient_key );
    992         if ( false === $all_files ) {
    993             $all_files = (array) self::scandir( $this->get_stylesheet_directory(), null, -1 );
    994 
    995             if ( $search_parent && $this->parent() ) {
    996                 $all_files += (array) self::scandir( $this->get_template_directory(), null, -1 );
    997             }
    998 
    999             set_transient( $transient_key, $all_files, HOUR_IN_SECONDS );
    1000         }
    1001 
    1002         // Filter $all_files by $type & $depth.
    1003         $files = array();
    1004         if ( $type ) {
    1005             $type = (array) $type;
    1006             $_extensions = implode( '|', $type );
    1007         }
    1008         foreach ( $all_files as $key => $file ) {
    1009             if ( $depth >= 0 && substr_count( $key, '/' ) > $depth ) {
    1010                 continue; // Filter by depth.
    1011             }
    1012             if ( ! $type || preg_match( '~\.(' . $_extensions . ')$~', $file ) ) { // Filter by type.
    1013                 $files[ $key ] = $file;
    1014             }
     987        $files = (array) self::scandir( $this->get_stylesheet_directory(), $type, $depth );
     988
     989        if ( $search_parent && $this->parent() ) {
     990            $files += (array) self::scandir( $this->get_template_directory(), $type, $depth );
    1015991        }
    1016992
Note: See TracChangeset for help on using the changeset viewer.