Make WordPress Core

Opened 9 years ago

Closed 9 years ago

#34526 closed defect (bug) (fixed)

Minor mistake in wp_get_installed_translations function which causes little flood in error log

Reported by: profforg's profile Profforg Owned by: ocean90's profile ocean90
Milestone: 4.5 Priority: normal
Severity: normal Version: 3.7
Component: I18N Keywords:
Focuses: Cc:

Description

There are a minor mistake in wp_get_installed_translations function in file wp-includes/l10n.php at line 821 (ver 4.3.1) https://github.com/WordPress/WordPress/blob/4.3-branch/wp-includes/l10n.php#L821

Affected versions: 3.7.0 - trunk

Current line:

if ( '.' === $file[0] || is_dir( $file ) ) {

How it should look like:

if ( '.' === $file[0] || is_dir( WP_LANG_DIR . "$dir/$file" ) ) {

Description:
Output of "scandir" function contains only filenames without full path. For some reason on the problematic line this is not taken into account. PHP tries to execute "is_dir" on for example "plugins" which does not work correctly in secured environments if "open_basedir" value is configured.
Example error being logged on each execution of wp_get_installed_translations():

is_dir(): open_basedir restriction in effect. File(plugins) is not within the allowed path(s): ({open_basedir value}) in /var/www/website.com/wp-includes/l10n.php on line 821

Fixed line will execute "is_dir()" on full path which will not return errors and should work in all environments.

Change History (3)

#1 @swissspidy
9 years ago

  • Component changed from General to I18N

#2 @ocean90
9 years ago

  • Milestone changed from Awaiting Review to 4.5
  • Owner set to ocean90
  • Status changed from new to accepted

#3 @ocean90
9 years ago

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

In 35856:

L10n: Use an absolute path for the is_dir() check when looking for installed translations.

Avoids warnings when open_basedir restrictions are in effect.

Props Profforg.
Fixes #34526.

Note: See TracTickets for help on using tickets.