[wp-trac] [WordPress Trac] #6531: Recursively search for files in theme and plugin editors

WordPress Trac noreply at wordpress.org
Mon Oct 2 16:11:42 UTC 2017


#6531: Recursively search for files in theme and plugin editors
------------------------------------+-----------------------------
 Reporter:  torbens                 |       Owner:  westonruter
     Type:  defect (bug)            |      Status:  reviewing
 Priority:  high                    |   Milestone:  4.9
Component:  Themes                  |     Version:  2.5
 Severity:  minor                   |  Resolution:
 Keywords:  theme-editor has-patch  |     Focuses:  administration
------------------------------------+-----------------------------

Comment (by schlessera):

 @WraithKenny Here are some observations regarding the patch:

 * `list_files()` uses recursion, which can put a lot of strain on the
 system or even lead to failures in extreme cases.
 * The caching mechanism will fail if the result of the traversal is indeed
 an empty set (like if the only plugin was excluded). This will disable the
 caching and iterate over the files every single time.
 * The caching mechanism is prone to cache stampedes on high load servers,
 where the cache might be refreshed multiple times in parallel.

 I would recommend returning PHP recursive iterators instead of using a
 recursive function and collecting the entire result set, and building a
 more fail-safe caching mechanism.

 Using PHP iterators has the following advantages:
 * Depending on the use case, traversal can stop early.
 * Iterators can still be modified (i.e. further filtered) after they have
 been returned.
 * Depending on the PHP version support, they can even be better optimized
 to transparently support parallel crawling or other neat tricks.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/6531#comment:50>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list