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

Hey

Both PROD and DEV are inside Docker containers, so maybe that's contributing to this?

phpinfo():

Configuration File (php.ini) Path: /usr/local/etc/php

php --ini:

Configuration File (php.ini) Path: /usr/local/etc/php
Loaded Configuration File:         (none)
Scan for additional .ini files in: /usr/local/etc/php/conf.d
Additional .ini files parsed:      /usr/local/etc/php/conf.d/docker-php-ext-gd.ini,
/usr/local/etc/php/conf.d/docker-php-ext-mysqli.ini,
/usr/local/etc/php/conf.d/docker-php-ext-sodium.ini,
/usr/local/etc/php/conf.d/docker-php-ext-zip.ini,
/usr/local/etc/php/conf.d/uploads.ini

So php --ini inside the container doesn't seem to report a loaded config file, but that's ok (I think) as we haven't seen any problems with this config for years now...! Pretty sure everything is well handled by the docker container base image. We are setting a few non-defaults in uploads.ini

Thoughts?

Cheers
Rob

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.