Make WordPress Core

Opened 10 years ago

Closed 9 years ago

#29680 closed defect (bug) (fixed)

PHP open_basedir errors are outputted during setup and load

Reported by: mklusak's profile mklusak Owned by: chriscct7's profile chriscct7
Milestone: 4.4 Priority: normal
Severity: normal Version: 4.0
Component: Upgrade/Install Keywords: has-patch commit
Focuses: Cc:

Description (last modified by SergeyBiryukov)

Hi, there is one situation, when WP 4.0 setup fails - if there is some output before header( 'Location: ' . $path ); line in wp-load.php ... then I am stuck at blank page with PHP errors, and no redirect to setup files happens.

For example, my hosting company has some open_basedir restriction. My hosting "space" directory is for example /data/www/. For every domain is generated its own subfolder, like /data/www/mydomain.com, /data/www/myanotherdomain.com text. WordPress files are located in these subfolders, and PHP scripts allowed paths are restricted only to this subfolders.

And there is problem: in wp-load.php from line 27 to 32 script tries to check:

if ( file_exists( ABSPATH . 'wp-config.php') ) {
// checks /data/www/mydomain.com/wp-config.php ... it does not exist now

} elseif ( file_exists( dirname(ABSPATH) . '/wp-config.php' ) && .... ) ) {
// checks /data/www/wp-config.php ... it does not exist now, BUT this path 
// is not within alowed paths ... and PHP error is outputted.

And when PHP error is outputed to the browser, then folowing header() location redirect fails, and another PHP error is outputted. And setup stops.

Warning: file_exists() [function.file-exists]: open_basedir restriction in effect. File(.../data/www/wp-config.php) is not within the allowed path(s): (.../data/www/mydomain.com:/tmp/uploads) in .../data/www/mydomain.com/wp-load.php on line 31

Warning: Cannot modify header information - headers already sent by (output started at .../data/www/mydomain.com/wp-load.php:31) in .../data/www/mydomain.com/wp-load.php on line 56

Line numbers can be slightly changed as I was analyzing source code.

This happend with WP 3.9.x too, but there was only error message on top of setup information, and everything worked. I know this is related to webserver configuration, but maybe there is some solution.

Attachments (2)

patch (1.8 KB) - added by misterunknown 9 years ago.
fix for this issue
29680.patch (1.8 KB) - added by chriscct7 9 years ago.

Download all attachments as: .zip

Change History (11)

#1 @SergeyBiryukov
10 years ago

  • Component changed from General to Upgrade/Install
  • Description modified (diff)
  • Summary changed from Wordpress 4.0 setup stops on start - PHP open_basedir errors are outputted to WordPress 4.0 setup stops on start - PHP open_basedir errors are outputted

#2 @SergeyBiryukov
10 years ago

#31266 was marked as a duplicate.

#4 @azurit
10 years ago

The simple solution should be this (disable warnings with @):

wp-load.php:31

} elseif ( @file_exists( dirname(ABSPATH) . '/wp-config.php' ) && ! @file_exists( dirname(ABSPATH) . '/wp-settings.php' ) ) {

setup-config.php:56

if ( @file_exists(ABSPATH . '../wp-config.php' ) && ! @file_exists( ABSPATH . '../wp-settings.php' ) )

#5 @ocean90
9 years ago

#33373 was marked as a duplicate.

@misterunknown
9 years ago

fix for this issue

#6 @misterunknown
9 years ago

I just added a patch which should solve this issue. Please let me know if that's not the correct way, it is the very first patch I contribute.

@chriscct7
9 years ago

#7 @chriscct7
9 years ago

  • Keywords has-patch commit added
  • Milestone changed from Awaiting Review to 4.4
  • Owner set to chriscct7
  • Status changed from new to assigned

Path was slightly off, and the patch file needs to have a .patch extension so it can be applied.

Nice job on your first patch @misterunknown

#8 @chriscct7
9 years ago

  • Summary changed from WordPress 4.0 setup stops on start - PHP open_basedir errors are outputted to PHP open_basedir errors are outputted during setup and load

#9 @wonderboymusic
9 years ago

  • Resolution set to fixed
  • Status changed from assigned to closed

In 34867:

Setup/Config: some dirname( ABSPATH ) file lookups should have errors suppressed due to possibility of open_basedir restrictions on hosts.

Props chriscct7, misterunknown.
Fixes #29680.

Note: See TracTickets for help on using tickets.