WordPress.org

Make WordPress Core

Opened 7 years ago

Closed 6 years ago

#7640 closed defect (bug) (fixed)

Upgrade has warnings when open_basedir is in effect

Reported by: Oded Owned by:
Milestone: 2.7 Priority: lowest
Severity: minor Version: 2.7
Component: Upgrade/Install Keywords: needs-patch
Focuses: Cc:

Description

With open_basedir set in PHP to not include where the PHP error log is stored, the database upgrade process shows two PHP warnings (in red with full stack traces - not user friendly at all):

---8<-----
( ! ) Warning: is_writable() [function.is-writable]: open_basedir restriction in effect. File(/var/log/httpd/php-errors_log) is not within the allowed path(s): (/usr/lib/pear:/usr/share/pear/:/usr/share/php-adodb/:/usr/share/php-jaffa/:/var/www:/var/tmp/:/tmp:/vhosts/coil/geek/public_html) in /vhosts/coil/geek/public_html/wp/wp-includes/wp-db.php on line 500
Call Stack
# Time Function Location
1 0.0020 {main}() /vhosts/coil/geek/public_html/wp/wp-admin/upgrade.php:0
2 0.9184 wp_upgrade() /vhosts/coil/geek/public_html/wp/wp-admin/upgrade.php:68
3 0.9213 make_db_current_silent() /vhosts/coil/geek/public_html/wp/wp-admin/includes/upgrade.php:149
4 0.9214 dbDelta() /vhosts/coil/geek/public_html/wp/wp-admin/includes/upgrade.php:1109
5 1.0854 wpdb->query() /vhosts/coil/geek/public_html/wp/wp-admin/includes/upgrade.php:1090
6 1.0957 wpdb->print_error() /vhosts/coil/geek/public_html/wp/wp-includes/wp-db.php:616
7 1.0963 is_writable () /vhosts/coil/geek/public_html/wp/wp-includes/wp-db.php:500

( ! ) Warning: is_writable() [function.is-writable]: open_basedir restriction in effect. File(/var/log/httpd/php-errors_log) is not within the allowed path(s): (/usr/lib/pear:/usr/share/pear/:/usr/share/php-adodb/:/usr/share/php-jaffa/:/var/www:/var/tmp/:/tmp:/vhosts/coil/geek/public_html) in /vhosts/coil/geek/public_html/wp/wp-includes/wp-db.php on line 500
Call Stack
# Time Function Location
1 0.0020 {main}() /vhosts/coil/geek/public_html/wp/wp-admin/upgrade.php:0
2 0.9184 wp_upgrade() /vhosts/coil/geek/public_html/wp/wp-admin/upgrade.php:68
3 0.9213 make_db_current_silent() /vhosts/coil/geek/public_html/wp/wp-admin/includes/upgrade.php:149
4 0.9214 dbDelta() /vhosts/coil/geek/public_html/wp/wp-admin/includes/upgrade.php:1109
5 1.0982 wpdb->query() /vhosts/coil/geek/public_html/wp/wp-admin/includes/upgrade.php:1090
6 1.0994 wpdb->print_error() /vhosts/coil/geek/public_html/wp/wp-includes/wp-db.php:616
7 1.0999 is_writable () /vhosts/coil/geek/public_html/wp/wp-includes/wp-db.php:500
---8<-----

The fix should be simple - in wp-includes/wp-db.php, line 500, use the "don't show warnings" syntax in the call to is_writable, changing that line to:

if ( !empty($log_file) && ('syslog' != $log_file) && !@is_writable($log_file) )

Change History (23)

comment:1 @santosj7 years ago

  • Milestone changed from 2.6.2 to 2.7
  • Priority changed from normal to low

comment:2 @santosj7 years ago

  • Summary changed from Upgrade has warnnings when open_basedir is in effect to Upgrade has warnings when open_basedir is in effect

comment:3 @santosj7 years ago

I think the cause should be corrected instead of covering up the symptom.

comment:4 @Otto427 years ago

is_writable is not particularly reliable, so using it would be a bad move, IMO.

Basically, the error stems from attempting to use the standard PHP error_log function when the host has implemented security such that the default error log is not allowed to be written to.

You could fix this by setting the error_log setting to a writable file (using ini_set). Alternatively, you could just turn off error logging by setting log_errors to false (also using ini_set).

comment:5 @ryan7 years ago

ini_set would also need to be silenced because hosts disable it too.

comment:6 @santosj7 years ago

I think it is disabled during safe_mode is on.

comment:7 @santosj7 years ago

You know, I created a ticket and a patch that can be used to log errors.

comment:9 @ryan7 years ago

(In [9199]) silence is_writable() warnings. see #7640

comment:10 @ryan7 years ago

  • Milestone changed from 2.7 to 2.8

I papered over the problem for now. Moving this ticket to 2.8 for a more thoughtful fix.

comment:11 @mrmist6 years ago

According to the forum you also hit this with Post edits so it could be a bigger issue. http://wordpress.org/support/topic/224372?replies=2#post-921404

comment:12 @mrmist6 years ago

  • Version set to 2.7

comment:13 @jacobsantos6 years ago

  • Keywords needs-patch added

comment:14 @DD326 years ago

According to the forum you also hit this with Post edits so it could be a bigger issue. http://wordpress.org/support/topic/224372?replies=2#post-921404

That appears to be realpath() breaking & returning false.. Bloody nuisance that function is.. I dont think its completely related to this ticket though.

comment:15 @ryan6 years ago

  • Component changed from General to Upgrade/Install
  • Owner anonymous deleted

comment:16 @Denis-de-Bernardy6 years ago

Could we just not make WP die with an angry error message (i.e. Get a real host!) when safe_mode and similar restrictions are on? After all, they're getting deprecated... :-)

comment:17 @DD326 years ago

Could we just not make WP die with an angry error message (i.e. Get a real host!) when safe_mode and similar restrictions are on? After all, they're getting deprecated... :-)

Unfortunately thats against WordPress's (and most developers) instincts of supporting users :)

comment:18 @Denis-de-Bernardy6 years ago

  • Milestone changed from 2.8 to Future Release

sending this to the oubliette, then...

comment:19 @Denis-de-Bernardy6 years ago

see also: #5953 (end of ticket related to realpath())

comment:20 @Denis-de-Bernardy6 years ago

  • Milestone changed from Future Release to 2.9
  • Priority changed from low to lowest

comment:21 @hakre6 years ago

  • Milestone changed from 2.9 to Unassigned
  • Resolution set to invalid
  • Status changed from new to closed

The reporter of this ticket is in error. First of all the messages he is reporting are beautified by xdebug. secondly it's the server configuration that is misleading here. error logging of php is logging into a file where open basedir does not allow it. so this is a configuration issue.

I will close the ticket as invalid now.

comment:22 @dd326 years ago

  • Resolution invalid deleted
  • Status changed from closed to reopened

comment:23 @dd326 years ago

  • Milestone changed from Unassigned to 2.7
  • Resolution set to fixed
  • Status changed from reopened to closed

Closing as fixed as the is_writable() warnings were silenced. Which as hakre has pointed out, Is about the most one can expect from this due to it being a bad PHP configuration.

Note: See TracTickets for help on using tickets.