[wp-trac] [WordPress Trac] #55387: $wp_filesystem->dirlist() can return false and that should be checked for before iterating over the return value

WordPress Trac noreply at wordpress.org
Sun Mar 13 19:22:48 UTC 2022


#55387: $wp_filesystem->dirlist() can return false and that should be checked for
before iterating over the return value
----------------------------+----------------------
 Reporter:  pbiron          |      Owner:  pbiron
     Type:  defect (bug)    |     Status:  assigned
 Priority:  normal          |  Milestone:  6.0
Component:  Filesystem API  |    Version:
 Severity:  normal          |   Keywords:
  Focuses:                  |
----------------------------+----------------------
 There are a number of cases in core (e.g.,
 https://core.trac.wordpress.org/browser/trunk/src/wp-admin/includes/class-
 wp-upgrader.php#L500) where the return value of
 `$wp_filesystem->dirlist()` is assumed to be an array.  But since that
 method can return `false`, we should always check for that before
 iterating (or calling `array_keys()` or `array_values()` on it) over the
 return value.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/55387>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list