Apache2 error log, php warning (solved)

I’m running open emr v7 patch 2 on ubuntu 22.04 server with mariadb sql server.

I get a lot (1000’s per day) of the following 2 warnings in the apache2 error log.

[Mon Feb 20 13:18:04.065607 2023] [php:warn] [pid 100741] [client 10.0.1.226:53972] PHP Warning:  Trying to access array offset on value of type bool in /var/www/html/openemr/library/forms.inc on line 162, referer: http://10.0.1.84/openemr/interface/main/tabs/main.php?token_main=uSDEx6yV7UK6oMn998lmyx07mbKYgqyV5vvFHQfb
[Mon Feb 20 13:18:04.065622 2023] [php:warn] [pid 100741] [client 10.0.1.226:53972] PHP Warning:  Undefined array key 1 in /var/www/html/openemr/library/forms.inc on line 163, referer: http://10.0.1.84/openemr/interface/main/tabs/main.php?token_main=uSDEx6yV7UK6oMn998lmyx07mbKYgqyV5vvFHQfb

The code in forms.inc is

function hasFormPermission($formDir)
{
    // get the aco spec from registry table
    $formRow = sqlQuery("SELECT aco_spec FROM registry WHERE directory = ?", array($formDir));
    $permission = explode('|', $formRow['aco_spec']);
    return AclMain::aclCheckCore($permission[0], $permission[1]);
}

With line 162 and 163 being the last two lines before the closing curly brace.

I check the registry data table it only has 23 rows in it. Each “aco_spec” field has two words separated by the pipe character.

Possibly the query isn’t returning any results?

Maybe the query is looking for a “directory” that doesn’t exist? How would I tell exactly what that query is asking for in the variables?

Thanks.

Hi D C bearzillasquatch

I think $formRow variable return empty array so its return undefined index error.Can you Check whether your passed directory its correct or not.

If you want to fix this issue change code like this.

function hasFormPermission($formDir)
{
// get the aco spec from registry table
$formRow = sqlQuery(“SELECT aco_spec FROM registry WHERE directory = ?”, array($formDir));
$permission = explode(’|’, $formRow[‘aco_spec’]);
return AclMain::aclCheckCore(isset($permission[0])?$permission[0]:’’, isset($permission[1])?$permission[1]:’’);

}

Thanks
Param
help@capminds.com

@Param_CapMinds thanks for the help. I’m definitely going to change the code so it checks if it’s set. I’ll also investigate what directory is being passed. It might be a good idea to know if I’m missing something that should be there.

Thanks.