Make WordPress Core

Opened 11 years ago

Closed 11 years ago

#24639 closed defect (bug) (fixed)

search_theme_directories returns nothing if scandir() returns FALSE

Reported by: csixty4's profile csixty4 Owned by: nacin's profile nacin
Milestone: 3.7 Priority: normal
Severity: normal Version: 3.6
Component: Themes Keywords: has-patch commit 3.7-early
Focuses: Cc:

Description

I'm experimenting with ways to detect themes & plugins WordPress can't upgrade automatically, and found that wp_get_themes() (wp-includes/theme.php) returns an empty array if one of the theme directories is unreadable (chmod 770, neither owner or group exist).

Currently, the search_theme_directories() function returns false if any scandir() calls return false. Shouldn't it return a list of valid themes it can access, ignoring the ones it can't?

The attached patch issues a "continue" statement if scandir() returns false, so at least some information is returned. It isn't enough to help me detect those cases where a theme can't be updated, but it's probably more useful for people who need a list of themes.

Attachments (2)

search_theme_directories_continue.patch (846 bytes) - added by csixty4 11 years ago.
continue instead of returning false when scandir() returns false
24639.diff (1.1 KB) - added by nacin 11 years ago.

Download all attachments as: .zip

Change History (7)

@csixty4
11 years ago

continue instead of returning false when scandir() returns false

#1 @nacin
11 years ago

I wrote this code, and yes, this is a good change. Maybe we should do a trigger_error() with E_USER_NOTICE whenever we can't read a directory we're supposedly to read?

@nacin
11 years ago

#2 @csixty4
11 years ago

Thanks! The patch works for me, and I should be able to intercept that notice with an error_handler. That's better than I was hoping for.

#3 @nacin
11 years ago

  • Keywords has-patch commit 3.7-early added; dev-feedback removed
  • Milestone changed from Awaiting Review to Future Release

#4 @wonderboymusic
11 years ago

  • Milestone changed from Future Release to 3.7

these are all marked 3.7-early

#5 @nacin
11 years ago

  • Owner set to nacin
  • Resolution set to fixed
  • Status changed from new to closed

In 24976:

Don't return false from search_theme_directories() when a single directory is not readable.

Issue a notice.

props csixty4.
fixes #24639.

Note: See TracTickets for help on using tickets.