[wp-trac] [WordPress Trac] #6531: Recursively search for files in theme and plugin editors
WordPress Trac
noreply at wordpress.org
Wed Oct 4 19:46:53 UTC 2017
#6531: Recursively search for files in theme and plugin editors
-------------------------------------------------+-------------------------
Reporter: torbens | Owner:
Type: defect (bug) | WraithKenny
Priority: high | Status: reviewing
Component: Themes | Milestone: 4.9
Severity: minor | Version: 2.5
Keywords: theme-editor has-patch needs-unit- | Resolution:
tests | Focuses:
| administration
-------------------------------------------------+-------------------------
Comment (by WraithKenny):
Here is a rundown of the current patch
* `list_files()` now contains a filter called `'list_files_exclusions'`
that will ignore ''hidden files and folders'' and folders named 'CVS',
'node_modules', 'vendor', or 'bower_components' when scanning for files.
('CVS' because it existed in 'theme_scandir_exclusions'.)
* `WP_Theme::scandir()` filter `'theme_scandir_exclusions'` updated to
exclude 'vendor', or 'bower_components' also.
* `get_plugin_files` now uses `list_files()`
* `get_files` now does `scandir` only once for all files at all depths,
and filters it's return per call.
* `get_plugin_files` now caches file lists returned from `list_files()`
into a transient for an hour, keyed to directory and Version.
* `WP_Theme::get_files()` caches file lists returned from `scandir()`
into a transient for an hour, keyed to theme Name and Version.
* `theme-editor.php` calls to `$theme->get_files()` are passed with `-1`
to get all files of the type.
Patch 6531.9.diff is to address some of @schlessera's comments,
particularly the "empty set" condition. I'm not sure I fully understand
the implications however, since an empty set would cause the function to
scan for 0 files when the theme editor is loaded. I updated the patch to
check for `false === $all_files` which should make sure that it won't run
more than once per hour. As for the "stampedes" issue, I don't fully
understand, but that'd be a wider issue for transients and caching in
general rather than this ticket, right?
As for PHP recursive iterators, I'm not too familiar with them, but I'll
research after work to see what I can do, unless you'd like to take a stab
at it :) Thanks for the feedback!
@westonruter thanks for the link to wpcs/phpcs; I've got it installed now.
I've got the folders you've suggested filtered out now (and devs can use
the filter to adjust to their liking, if they really really want to opt
into including 'vendor' or whatever after #24048 folders are added).
It also looks like you've already solved a lot of the issues in the second
paragraph over in #24048!
--
Ticket URL: <https://core.trac.wordpress.org/ticket/6531#comment:54>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list