Warning: file_exists(): open_basedir restriction in effect.

4 posts by 2 authors in: Forums > CMS Builder
Last Post: April 5, 2018   (RSS)

By Deborah - March 27, 2018

Question for Interactive Tools...

I'm seeing an error on a specific installation with version 3.13, that I've not seen before. The error displays when when viewing the General Settings page when logged in as Admin and is logged in the Developer Log.

Warning: file_exists(): open_basedir restriction in effect. File(/etc/php/7.0/fpm/php.ini) is not within the allowed path(s): (/var/www/clients/client44/web48/web:/var/www/clients/client44/web48/private:/var/www/clients/client44/web48/tmp:/var/www/[removed]/web:/srv/www/[removed]/web:/usr/share/php5:/usr/share/php:/tmp:/usr/share/phpmyadmin:/etc/phpmyadmin:/var/lib/phpmyadmin:/dev/random:/dev/urandom) in /var/www/clients/client44/web48/web/cms/lib/menus/admin/general.php on line 867

This is on a University website and I do not have direct access to the server configuration. Their server techs have responded to my concern with this:

"The cause of the warning appears to be precisely what the error statement says: /etc/php/7.0/fpm/php.ini isn't listed as accessible in the open_basedir directive, so when your CMS checks whether it exists, it returns as not found, when in fact it's just not in a directory that file_exists is allowed to look in. 

I've looked through the script that the CMS is actually using when it throws this error. the path /etc/php/7.0/fpm/php.ini is pulled by php_ini_loaded_file() which simply returns the path of whatever php.ini file is already loaded. In other words, that file is already loaded and accessible, so whether it can be found by file_exists should be inconsequential. That said, if you are seeing any other adverse issues with your CMS, please let us know, so we can investigate whether they're related."

I'm just beginning to build this site, so I don't know if there will be any adverse issues. If you feel that this is not of concern, is there a way to comment out the CMSB code is checking for this so my Developer Log doesn't get overloaded?

Hoping for the easiest solution! Thanks.
~ Deborah

By Dave - April 4, 2018

Hi Deborah, 

That section is mostly just debugging information, letting you know which config files are being used, so that error can safely be ignored.  We're double checking if config files exist, but the open_basedir restriction can prevent us from doing that.  Here's a patch to hide the error:

Replace this

foreach ($configFiles as $configFile => $isLoaded) {
  $filePath = absPath($configFile, SCRIPT_DIR); 
  if     (!file_exists($filePath)) { $configFilesList .= "<li style='color: #C00;'>$filePath (file not found)</li>\n"; }
  elseif ($isLoaded)               { $configFilesList .= "<li>$filePath</li>\n"; }
}

With this:

foreach ($configFiles as $configFile => $isLoaded) {
  $filePath           = absPath($configFile, SCRIPT_DIR); 
  $fileExists         = @file_exists($filePath);
  $isOpenBaseDirError = preg_match("/open_basedir restriction in effect/i", error_get_last()['message']);
  if     (!$fileExists && !$isOpenBaseDirError) { $configFilesList .= "<li style='color: #C00;'>$filePath (file not found)</li>\n"; }
  elseif ($isLoaded)                            { $configFilesList .= "<li>$filePath</li>\n"; }
}

Hope that helps, let me know any questions.

Dave Edis - Senior Developer
interactivetools.com

By Deborah - April 5, 2018

Dave, thank you so much!

I was concerned that the server setup might not be compatible w/CMSB and am relieved. Your code replacement has stopped the error logging.

~ Deborah