WordPress.org

Make WordPress Core

#20985 closed defect (bug) (fixed)

Mute errors when calling file_exists in search_theme_directories

Reported by: goldenapples Owned by: nacin
Milestone: 3.4.1 Priority: normal
Severity: normal Version: 3.4
Component: Themes Keywords:
Focuses: Cc:

Description

Just upgraded a production site to 3.4, and I noticed some errors on the admin screens related to the rewrites done in r20020.

The site is maintained by another designer in Dreamweaver, and has the usual _notes/dwsync.xml files strewn around - including, relevantly in the wp-content/themes/ directory.

After upgrading, on every page of the admin, I see the following warning:

Warning: file_exists() [function.file-exists]: open_basedir restriction in effect. File(/home/p25lh1ao/public_html/ati/wp-content/themes/_notes/dwsync.xml/style.css) is not within the allowed path(s): (/home/:/usr/lib/php:/usr/local/lib/php:/tmp) in /home/p25lh1ao/public_html/ati/wp-includes/theme.php on line 386

I don't mind the error - it gives me a reason to wonder why Dreamweaver is still being used on a site that I've had under version control for a long time. But it seems like there should be some checking going on before searching for a style.css under every file in a directory. I'm not sure which would be faster, to simply mute errors, or check is_dir() on each of the $sub_dirs looped through (which could be either directories, as assumed, or any kind of file.

The attached patch fixed the issue for me.

Attachments (1)

fix-file_exists-warning.diff (671 bytes) - added by goldenapples 22 months ago.

Download all attachments as: .zip

Change History (5)

comment:1 Steibock22 months ago

  • Cc Steibock added
  • Version set to 3.4

I confirm this.
To reproduce this bug, it is necessary to have set at least one path as basedir. For me, the warning was only issued when visiting the page used for activating the themes.

Last edited 22 months ago by Steibock (previous) (diff)

comment:2 nacin22 months ago

  • Milestone changed from Awaiting Review to 3.4.1

The is_dir() check two lines up should simply be checking $sub_dir as well; they can be combined into one.

comment:3 nacin22 months ago

In [21126]:

When looking in a sub-directory of wp-content/themes for more themes, check
if that specific directory exists before looking inside of it for style.css.

This avoids warnings when open_basedir restrictions are in effect.

props goldenapples. see #20985 for trunk.

comment:4 nacin22 months ago

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

In [21127]:

When looking in a sub-directory of wp-content/themes for more themes, check
if that specific directory exists before looking inside of it for style.css.

This avoids warnings when open_basedir restrictions are in effect.

props goldenapples. fixes #20985 for 3.4.

Note: See TracTickets for help on using tickets.