Make WordPress Core

Opened 12 years ago

Closed 7 years ago

#21403 closed enhancement (maybelater)

Introduce wp_scandir, remove opendir / closedir code

Reported by: wonderboymusic's profile wonderboymusic Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.0
Component: Filesystem API Keywords: needs-refresh dev-feedback
Focuses: Cc:

Description

There is @opendir code all over the place that is not standardized. On top of that, there is plenty of code that is duplicated and could be condensed into one handy function. Plus, in all of the places we are using opendir(), we really want to be using scandir().

I have created a master function in load.php called wp_scandir() that does the basics:

  • scans a directory for files / subdirectories
  • filters list by extension(s)
  • optionally returns ONLY files

This cleans up code in many places.

Attachments (1)

wp-scandir.diff (16.4 KB) - added by wonderboymusic 12 years ago.

Download all attachments as: .zip

Change History (7)

#1 @scribu
12 years ago

Wouldn't glob() be more appropriate?

#2 @markoheijnen
12 years ago

I'm curious how this effect the performance

#3 @wonderboymusic
12 years ago

opendir is the PHP4 alternative to scandir - scandir is faster and requires less code. glob might be ok but is less standard. I was following @nacin's lead, he used scandir in WP_Theme

#4 @Mamaduka
12 years ago

  • Cc georgemamadashvili@… added

#5 @chriscct7
9 years ago

  • Keywords needs-refresh dev-feedback added; has-patch removed

#6 @wonderboymusic
7 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to maybelater
  • Status changed from new to closed
Note: See TracTickets for help on using tickets.