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

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 👍

Thanks - and yup, that fixes the issue.