[ZBX-23567] v6.0.22 install fails DB connect @ install, error: "Trying to access array offset on value of type null in .../CCookieSession.php" Created: 2023 Oct 18  Updated: 2024 Apr 10  Resolved: 2024 Mar 18

Status: Closed
Project: ZABBIX BUGS AND ISSUES
Component/s: Frontend (F), Installation (I)
Affects Version/s: 6.0.22, 6.4.7, 7.0.0alpha7
Fix Version/s: 6.0.28rc1, 6.4.13rc1, 7.0.0beta2, 7.0 (plan)

Type: Problem report Priority: Major
Reporter: _ Assignee: Miks Kronkalns
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Team: Team B
Sprint: Sprint 106 (Nov 2023), Sprint 107 (Dec 2023), S2401, S24-W10/11
Story Points: 1

 Description   

on

	lsb_release -rd
		Description:    Fedora release 38 (Thirty Eight)
		Release:        38

	rpm -qa zabbix\* | sort
		zabbix-6.0.22-1.fc38.x86_64
		zabbix-agent-6.0.22-1.fc38.x86_64
		zabbix-dbfiles-mysql-6.0.22-1.fc38.noarch
		zabbix-proxy-6.0.22-1.fc38.noarch
		zabbix-proxy-mysql-6.0.22-1.fc38.x86_64
		zabbix-selinux-6.0.22-1.fc38.noarch
		zabbix-server-6.0.22-1.fc38.noarch
		zabbix-server-mysql-6.0.22-1.fc38.x86_64
		zabbix-web-6.0.22-1.fc38.noarch
		zabbix-web-mysql-6.0.22-1.fc38.noarch

with

	php -v
		PHP 8.2.11 (cli) (built: Sep 26 2023 11:11:58) (NTS gcc x86_64)
		Copyright (c) The PHP Group
	Zend Engine v4.2.11, Copyright (c) Zend Technologies
		with Zend OPcache v8.2.11, Copyright (c), by Zend Technologies
		with Xdebug v3.2.2, Copyright (c) 2002-2023, by Derick Rethans

	mariadb -V
		/usr/bin/mariadb  Ver 15.1 Distrib 10.11.5-MariaDB, for Linux (x86_64) using  EditLine wrapper

i've setup/launched zabbix server & proxy,

zabbix_server -V
    zabbix_server (Zabbix) 6.0.22
    Revision 2b0090fc371 25 September 2023, compilation time: Oct  4 2023 00:00:00
    ...

zabbix_proxy -V
    zabbix_proxy (Zabbix) 6.0.22
    Revision 2b0090fc371 25 September 2023, compilation time: Oct  4 2023 00:00:00
    ...

systemctl status zabbix-server zabbix-proxy -n0
    ● zabbix-server.service - zabbix
         Loaded: loaded (/etc/systemd/system/zabbix-server.service; enabled; preset: disabled)
        Drop-In: /usr/lib/systemd/system/service.d
                 └─10-timeout-abort.conf
         Active: active (running) since Tue 2023-10-17 16:31:13 EDT; 3s ago
        Process: 24411 ExecStart=/usr/sbin/zabbix_server -c $CONFFILE (code=exited, status=0/SUCCESS)
       Main PID: 24413 (zabbix_server)
          Tasks: 1 (limit: 9830)
         Memory: 2.3M
            CPU: 9ms
         CGroup: /system.slice/zabbix-server.service
                 └─24413 /usr/sbin/zabbix_server -c /usr/local/etc/zabbix/zabbix_server.conf

    ● zabbix-proxy.service - zabbix-proxy
         Loaded: loaded (/etc/systemd/system/zabbix-proxy.service; enabled; preset: disabled)
        Drop-In: /usr/lib/systemd/system/service.d
                 └─10-timeout-abort.conf
         Active: active (running) since Tue 2023-10-17 16:31:14 EDT; 3s ago
        Process: 24417 ExecStart=/usr/sbin/zabbix_proxy -c $CONFFILE (code=exited, status=0/SUCCESS)
       Main PID: 24419 (zabbix_proxy)
          Tasks: 1 (limit: 9830)
         Memory: 2.5M
            CPU: 9ms
         CGroup: /system.slice/zabbix-proxy.service
                 └─24419 /usr/sbin/zabbix_proxy -c /usr/local/etc/zabbix/zabbix_proxy.conf

where

id zabbix zabbixsrv wwwrun
    uid=970(zabbix) gid=962(zabbix) groups=962(zabbix)
    uid=972(zabbixsrv) gid=964(zabbixsrv) groups=964(zabbixsrv),984(www)

db config's consistent

grep ^DB /usr/local/etc/zabbix/zabbix*conf
    /usr/local/etc/zabbix/zabbix_proxy.conf:DBName=zabbix_proxy
    /usr/local/etc/zabbix/zabbix_proxy.conf:DBHost=localhost
    /usr/local/etc/zabbix/zabbix_proxy.conf:DBSocket='/run/mariadb/mariadb.sock'
    /usr/local/etc/zabbix/zabbix_proxy.conf:DBUser='zabbix_user
    /usr/local/etc/zabbix/zabbix_proxy.conf:DBPassword='ABcfEFGH-iJKLMm-oPQ12Rst'
    /usr/local/etc/zabbix/zabbix_server.conf:DBName=zabbix
    /usr/local/etc/zabbix/zabbix_server.conf:DBHost=localhost
    /usr/local/etc/zabbix/zabbix_server.conf:DBSocket='/run/mariadb/mariadb.sock'
    /usr/local/etc/zabbix/zabbix_server.conf:DBUser='zabbix_user
    /usr/local/etc/zabbix/zabbix_server.conf:DBPassword='ABcfEFGH-iJKLMm-oPQ12Rst'

ls -al /usr/share/zabbix/etc/zabbix/web/zabbix.conf.php
    lrwxrwxrwx 1 wwwrun www 37 Oct 17 15:35 /usr/share/zabbix/etc/zabbix/web/zabbix.conf.php -> /usr/local/etc/zabbix/zabbix.conf.php

cat /usr/share/zabbix/etc/zabbix/web/zabbix.conf.php
    <?php

    global $DB;

    $DB['TYPE']           = 'MYSQL';
    $DB['SERVER']         = 'localhost:/run/mariadb/mariadb.sock';
    $DB['PORT']           = '0';
    $DB['DATABASE']       = 'zabbix';
    $DB['USER']           = 'zabbix_user;
    $DB['PASSWORD']       = 'ABcfEFGH-iJKLMm-oPQ12Rst';
    $DB['ENCRYPTION']     = 'false';
    $DB['VERIFY_HOST']    = 'false';
    $ZBX_SERVER           = 'zabbix-server.example.com';
    $ZBX_SERVER_PORT      = '10052';
    $ZBX_SERVER_NAME      = 'Zabbix Server';
    $IMAGE_FORMAT_DEFAULT = IMAGE_FORMAT_PNG;
    ?>

testing db connection from local shell works

sudo -u zabbixsrv 
mariadb 
 --user=&#39;zabbix_user 
 --password=&#39;ABcfEFGH-iJKLMm-oPQ12Rst&#39; 
 --host=localhost 
 --protocol=socket 
 --socket=/run/mariadb/mariadb.sock 
 --execute=&quot;SHOW DATABASES;&quot;
    +--------------------+
    | Database           |
    +--------------------+
    | information_schema |
    | zabbix             |
    | zabbix_proxy       |
    +--------------------+

at nav to

https://zabbix.example.com

'Welcome' and 'Check of pre-requisites' are OK

at next redirect to

-> https://zabbix.example.com/setup.php

    Configure DB connection

    Please create database manually, and set the configuration parameters for connection to this database. Press "Next step" button when done.

    Database type:	MYSQL

    Database host:	localhost:/run/mariadb/mariadb.sock
    Database port:	0
    Database name:	zabbix
    Store credentials in:	Plain text
    User:	zabbix_user
    Password:	ABcfEFGH-iJKLMm-oPQ12Rst
    Database TLS encryption: [ ]

fails with,

Details Cannot connect to the database.

    No such file or directory

and in logs

==&gt; /var/log/nginx/php-fpm-[www.log|http://www.log] &lt;==
[17-Oct-2023 16:44:51 America/New_York] PHP Warning:  Trying to access array offset on value of type null in /usr/share/zabbix/include/classes/core/CCookieSession.php on line 194
[17-Oct-2023 16:44:51 America/New_York] PHP Stack trace:
[17-Oct-2023 16:44:51 America/New_York] PHP   1. {main}() /usr/share/zabbix/setup.php:0
[17-Oct-2023 16:44:51 America/New_York] PHP   2. session_write_close() /usr/share/zabbix/setup.php:193
[17-Oct-2023 16:44:51 America/New_York] PHP   3. CCookieSession-&gt;write($id = &#39;5c38685f8ae0b5998e57f11cb04bb8e4&#39;, $data = &#39;sessionid|s:32:&quot;5c38685f8ae0b5998e57f11cb04bb8e4&quot;;check_fields_result|b:1;default_lang|s:5:&quot;en_US&quot;;default_timezone|s:6:&quot;system&quot;;default_theme|s:10:&quot;blue-theme&quot;;step|i:3;DB_TYPE|s:5:&quot;MYSQL&quot;;DB_SERVER|s:9:&quot;localhost&quot;;DB_PORT|s:1:&quot;0&quot;;DB_DATABASE|s:6:&quot;zabbix&quot;;DB_USER|s:19:&quot;zabbix_user&quot;;DB_PASSWORD|s:26:&quot;&#39;ABcfEFGH-iJKLMm-oPQ12Rst&#39;&quot;;DB_SCHEMA|s:0:&quot;&quot;;DB_ENCRYPTION|b:0;DB_ENCRYPTION_ADVANCED|b:0;DB_VERIFY_HOST|b:0;DB_KEY_FILE|s:0:&quot;&quot;;DB_CERT_FILE|s:0:&quot;&quot;;DB_CA_FILE|s:0:&quot;&quot;;DB_CIPHER_LIST|s:0:&quot;&quot;;DB_CREDS_STORA&#39;...) /usr/share/zabbix/setup.php:193
[17-Oct-2023 16:44:51 America/New_York] PHP   4. CCookieSession-&gt;isAutologinEnabled() /usr/share/zabbix/include/classes/core/CCookieSession.php:127



 Comments   
Comment by _ [ 2023 Oct 18 ]

clean-reinstalled / upgraded to Zabbix 6.4.7, same issue.

Comment by dimir [ 2023 Oct 20 ]

Cross-reference: coming from https://www.zabbix.com/forum/zabbix-troubleshooting-and-problems/472407-webui-db-install-fails-array-offset-on-value-of-type-null-in-ccookiesession-php#post472617

Comment by dimir [ 2023 Oct 20 ]

Do I understand it correctly that you can specify database socket file for Server and Proxy but you can't do so for Frontend?

Comment by _ [ 2023 Oct 20 ]

@dimir

yes. or, so it seems.

i can MDB confirm connectivity @ shell:

	sudo -u zabbixsrv \
	mariadb \
	 --user='zabbix_user' \
	 --password='ABcfEFGH-iJKLMm-oPQ12Rst' \
	 --host=localhost \
	 --protocol=socket \
	 --socket=/run/mariadb/mariadb.sock \
	 --execute="SHOW DATABASES;"

then, with same DB creds in

	zabbix_server.conf

&/or

	zabbix_proxy.conf

both server & proxy launch OK.

but, on nav to frontend webui, once I get to the DB credential-entry form, using same DB credentials, I get the error as in OP.

Comment by dimir [ 2023 Oct 25 ]

While for Server and Proxy there is an option to specify MySQL socket file:

### Option: DBSocket
#       Path to MySQL socket.
#
# Mandatory: no
# Default:
# DBSocket=

there is no similar one for the frontend. Suggestion is to add option

$DB['socket'] 

and pass it along when initiating a connection to MySQL database.

Comment by _ [ 2023 Oct 25 ]
$DB['socket'] 

can be called out specifically, or, as for zabbix-{server,proxy}.conf,

$DB['SERVER']         = 'localhost:/run/mariadb/mariadb.sock';

can be used to imply/extract the socket usage

Comment by Ivo Kurzemnieks [ 2024 Jan 10 ]

Field "Database host" does not allow a socket file. It was decided not to add any additional parameters like $DB['SOCKET']. A custom socket file can be defined in the php.ini if needed.

PHP error fixed in development branch feature/ZBX-23567-6.0

Comment by Miks Kronkalns [ 2024 Mar 15 ]

Fixed in:

Generated at Sat May 31 03:13:38 EEST 2025 using Jira 9.12.4#9120004-sha1:625303b708afdb767e17cb2838290c41888e9ff0.