OCSInventory-NG / OCSInventory-Server

Communication server of OCS Inventory
http://www.ocsinventory-ng.org/
GNU General Public License v2.0
340 stars 138 forks source link

Error after migration from Oracle Linux 7 to 9 and php 7.3 to 8.2. PHP Fatal error: Uncaught Error: Undefined constant "SSL_MODE" #444

Closed Vermiz closed 8 months ago

Vermiz commented 8 months ago

General informations

Operating system : Oracle Linux 9.2

Server informations

Perl version : v5.32.1 Mariadb: 10.11.5 php: 8.2.12

OCS Inventory informations

Ocs server version : 2.12.1

Problem's description

After migrating OCS from os: Oracle Linux 7.9, PHP: 7.3.33, MariaDB: 10.1.48 to the above Oracle Linux 9.2 server i start httpd and see blank white page. I check php-fpm log and see this error:

[08-Nov-2023 10:32:13 UTC] PHP Fatal error:  Uncaught Error: Undefined constant "SSL_MODE" in /usr/share/ocsinventory-reports/ocsreports/require/function_commun.php:169
Stack trace:
#0 /usr/share/ocsinventory-reports/ocsreports/require/header.php(96): dbconnect('localhost', 'ocs', 'password', 'ocsweb', '', '', '', '3306')
#1 /usr/share/ocsinventory-reports/ocsreports/index.php(44): require('/usr/share/ocsi...')
#2 {main}
  thrown in /usr/share/ocsinventory-reports/ocsreports/require/function_commun.php on line 169

I have the SSL_MODE variable in the file dbconfig.inc.php but it looks as if function_commun.php doesn't see it. This is my dbconfig.inc.php

<?php
define("DB_NAME","ocsweb");
define("SERVER_READ","localhost");
define("SERVER_WRITE","localhost");
define("SERVER_PORT", 3306);
define("COMPTE_BASE","ocs");
define("PSWD_BASE","password");
define("ENABLE_SSL",0);
define("SSL_MODE","");
define("SSL_KEY","");
define("SSL_CERT","");
define("CA_CERT","");
?>

I solved this problem by replacing the value from $sslmode = SSL_MODE to $sslmode = "" in line169 of the function_commun.php file. I don't know why the function_commun.php file doesn't read the SSL_MODE value from the dbconfig.inc.php file correctly.

On my new server with php 8.2 is PHP Fatal error: Uncaught Error: Undefined constant "SSL_MODE" but on my old server with php 7.3 is only warrning:

 [Wed Nov 08 16:54:23.436705 2023] [php7:warn] [pid 1482] [client 192.168.0.2:64030] PHP Warning:  Use of undefined constant SSL_MODE - assumed 'SSL_MODE' (this will throw an Error in a future version of PHP) in /usr/share/ocsinventory-reports/ocsreports/require/function_commun.php on line 169

Does anyone know what could be causing the problem and why the function_commun.php file doesn't read the SSL_MODE value from the dbconfig.inc.php file correctly?