Making WordPress.org


Ignore:
Timestamp:
10/13/2017 11:31:06 PM (8 years ago)
Author:
SergeyBiryukov
Message:

Plugin Directory: When searching for the main plugin file on upload, limit recursion depth to 1 level.

Scanning the deeper levels can grab the wrong data, e.g. if there's a sub-plugin with headers, it may be scanned instead of the main one.

Fixes #2804.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/tools/class-filesystem.php

    r3512 r6026  
    8181     * @param bool   $recursive Optional. Whether to recurse into subdirectories. Default: false.
    8282     * @param string $pattern   Optional. A regular expression to match files against. Default: null.
     83     * @param int    $depth     Optional. Recursion depth. Default: -1 (infinite).
    8384     * @return array All files within the passed directory.
    8485     */
    85     public static function list_files( $directory, $recursive = false, $pattern = null ) {
     86    public static function list_files( $directory, $recursive = false, $pattern = null, $depth = -1 ) {
    8687        if ( $recursive ) {
    8788            $iterator = new \RecursiveIteratorIterator(
     
    8990                \RecursiveIteratorIterator::SELF_FIRST
    9091            );
     92
     93            if ( $depth > -1 ) {
     94                $iterator->setMaxDepth( $depth );
     95            }
    9196        } else {
    9297            $iterator = new \DirectoryIterator( $directory );
Note: See TracChangeset for help on using the changeset viewer.