v3.77 - General Settings - Server Info display bug

7 posts by 3 authors in: Forums > CMS Builder
Last Post: June 11   (RSS)

Hey

When loading /admin.php?menu=admin&action=general, it errors with:

absPath(): Argument #1 ($inputPath) must be of type string, bool given, called in /var/www/html/clinicAdmin/lib/menus/admin/general_server_info.php on line 425

as per attached screenshot.

Coming from:


general_server_info.php L425:

$loadedPhpIni  = absPath(php_ini_loaded_file(), \CMS::$rootDir);

file_functions L10:

function absPath(string $inputPath, string $baseDir = '.'): string {

Not sure if it's something specific to my server config causing this, but it's happening in both DEV and PROD.

Obviously not fatal, but annoying none the less as it triggers a Dev Log error email everytime someone accesses this page.

Cheers

Rob

Attachments:

General Settings.png 129K

Hi Rob,

php_ini_loaded_file() could return a false if PHP can't determine if an actual PHP.ini file is being loaded. This could mean your servers are running with default values and not the values you specified in a PHP.ini file when setting up PHP. One way you could check if this is the case is to go onto your server command line and run

"php --ini" 

and see if the file path it reports actually points to the php.ini file you think it does. If they file doesn't exist, it may be running on defaults which could be problematic if you are running a production server.

You can also check phpinfo() and see what it pulls in for settings and which file it reads from. 

The problem is that if PHP is not reporting a php.ini file being loaded, it returns false to absPath which expects a string (perhaps we can make that section more robust as well) and hence the error you are seeing. 

Let us know what you find out. :)

Tim Hurd
Senior Web Programmer
Interactivetools.com

Hi Rob,

Thanks for the additional information. So digging into the issue a bit I did stumble across some info saying that some docker images don't have the php.ini and may require additional steps to put one in. That in fact, and you show this, it steps through the conf.d directory for additional .ini.

When it comes to docker, this means that the php_ini_loaded_file() could very well return false while still being absolutely fine (or found a php.ini in a conf.d directory to load in). I will bring this up with Dave as we should probably make sure that the code there is more robust for cases where php_ini_loaded_file() would return false. I would certainly say it is a bug in the fact we don't account for the false value.

Thanks for reporting!

Tim Hurd
Senior Web Programmer
Interactivetools.com

Thanks Tim 👍

Hi All, 

Thanks for the report, we've fixed this for the next release.  Here's a patch:

In /cmsb/lib/menus/admin/general_server_info.php, search for $loadedPhpIni and replace this: 

$loadedPhpIni  = absPath(php_ini_loaded_file(), CMS::$rootDir);
$configFiles = [  // check which local config files are in use
                  $cmsbHtaccess  => str_contains(ini_get('highlight.html').ini_get('date.default_latitude'), 'CMSB_CONFIG_HTACCESS') || ($_SERVER['CMSB_APACHE_HTACCESS'] ?? $_SERVER['REDIRECT_CMSB_APACHE_HTACCESS'] ?? false),
                  $cmsbUserIni   => str_contains(ini_get('highlight.string').ini_get('date.default_longitude'), 'CMSB_CONFIG_USER_INI'),    // || in_array('102M', $_maxSizes)
                  $cmsbPhpIni    => str_contains(ini_get('highlight.comment').ini_get('date.sunrise_zenith'), 'CMSB_CONFIG_PHP_INI'),      // || in_array('103M', $_maxSizes)
                  $loadedPhpIni  => 1, // add last as it will overwrite previous entry if they're the same and in that case we want isLoaded to be true
];

with this:

$configFiles = [  // path => isLoaded, check which local config files are in use
                  $cmsbHtaccess  => str_contains(ini_get('highlight.html').ini_get('date.default_latitude'), 'CMSB_CONFIG_HTACCESS') || ($_SERVER['CMSB_APACHE_HTACCESS'] ?? $_SERVER['REDIRECT_CMSB_APACHE_HTACCESS'] ?? false),
                  $cmsbUserIni   => str_contains(ini_get('highlight.string').ini_get('date.default_longitude'), 'CMSB_CONFIG_USER_INI'),    // || in_array('102M', $_maxSizes)
                  $cmsbPhpIni    => str_contains(ini_get('highlight.comment').ini_get('date.sunrise_zenith'), 'CMSB_CONFIG_PHP_INI'),      // || in_array('103M', $_maxSizes)
];
if ($loadedPhpIni = php_ini_loaded_file()) {
    $configFiles[$loadedPhpIni] = 1; // add last as it will overwrite previous entry if they're the same and in that case we want isLoaded to be true
}

Let me know if that works for you.

Thanks!

Dave Edis - Senior Developer
interactivetools.com

Thanks - and yup, that fixes the issue.