[wp-trac] [WordPress Trac] #48960: failed to open dir: No such file or directory in WIndows

WordPress Trac noreply at wordpress.org
Tue Dec 17 19:18:54 UTC 2019


#48960: failed to open dir: No such file or directory in WIndows
-----------------------------------+-----------------------
 Reporter:  eden159                |       Owner:  azaozz
     Type:  defect (bug)           |      Status:  reopened
 Priority:  normal                 |   Milestone:  5.3.2
Component:  Media                  |     Version:  5.3.1
 Severity:  major                  |  Resolution:
 Keywords:  has-patch fixed-major  |     Focuses:
-----------------------------------+-----------------------

Comment (by autotutorial):

 Hi guys do a great job, I have a suggestion to improve scandir, the code
 is well commented .. I'm not sure for php 7.4 in doubt I have inserted a
 comment.
 Best wishes for happy holidays and good work.
 {{{#!php
 <?php
             // Compatibily with open_basedir
             $dir_trim = dirname( '/' . preg_replace(
 '#^((?:[^:]+:)?(?:\\\\|/))?(.*)$#', '$2', rtrim( $dir, '\\/' ) ) . '/' )
 !== '/' ? $dir_default = array( '.', '..' ) : $dir_default = array( '.' );
             $dir_arr = @scandir( $dir );
                 if( !$dir_arr ) {
                     //compatibility php 7.4 see https://wiki.php.net/rfc
 /notice-for-non-valid-array-container
                     unset( $dir_arr );
                     $dir_arr = $dir_default;
                 }
              // restore key with start 0 or now array_diff work , previous
              // scandir without variable not remove dot.
              $files = array_values( array_diff( $dir_arr, array( '.', '..'
 ) ) );
              unset( $dir_default, $dir_arr, $dir_trim );
 }}}

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


More information about the wp-trac mailing list