[ZBX-9365] "Create host" page gives error: array_combine(): Both parameters should have at least 1 element... Created: 2015 Mar 04  Updated: 2017 May 30  Resolved: 2015 Mar 23

Status: Closed
Project: ZABBIX BUGS AND ISSUES
Component/s: Frontend (F)
Affects Version/s: 2.4.4
Fix Version/s: 2.2.10rc1, 2.4.5rc1, 2.5.0

Type: Incident report Priority: Critical
Reporter: Taras Dyshkant Assignee: Unassigned
Resolution: Fixed Votes: 0
Labels: php, regression
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

CentOS release 6.6 (Final) with latest updates
Linux grenada 2.6.32-504.8.1.el6.x86_64 #1 SMP Wed Jan 28 21:11:36 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux


Attachments: Text File yum-info-zabbix.txt     Text File yum-list-installed-zabbix.txt     PNG File zabbix-create-host.png     File zabbix_server.log    
Issue Links:
Duplicate

 Description   

When I go to Configuration -> Hosts and click on "Create host" button I see this error at the bottom of the page:

array_combine(): Both parameters should have at least 1 element [hosts.php:794 ? CView->render() ? include() ? array_combine() in /usr/share/zabbix/include/views/configuration.host.edit.php:201]}}


 Comments   
Comment by Oleksii Zagorskyi [ 2015 Mar 05 ]

Of course it's not reproducible on 2.4.4.

One strange thing is that your yum-info shows different zabbix versions installed simultaneously - 1.8, 2.0, 2.2, 2.4
Not sure what exactly does it mean.

The line #201 is 3rd in next code:

// groups for normal hosts
if (!$isDiscovered) {
	$hostGroups = array_combine($hostGroups, $hostGroups);
	$grp_tb = new CTweenBox($frmHost, 'groups', $hostGroups, 10);

I suppose something is wrong (broken) in your database related to host groups.

Comment by Taras Dyshkant [ 2015 Mar 05 ]

Correct installed packages list yum-list-installed-zabbix.txt

Comment by Taras Dyshkant [ 2015 Mar 05 ]

I'm sorry I messed up that list yum-info-zabbix.txt. It also includes available packages. I attached a correct one yum-list-installed-zabbix.txt.
As for the database I followed this steps.

Comment by Oleksii Zagorskyi [ 2015 Mar 06 ]

What is PHP version ?
Do you want to say that you used zabbix sources 2.4.4 to create database and you have created it just recently ?
What is databasse type ?

Comment by Taras Dyshkant [ 2015 Mar 06 ]

It Is a fresh installation.
I just tested it on a CentOS 6.6 x86_64 VM.
So here's how I did it:


  1. Installed CentOS 6.6 x86_64 Minimal
  2. Updated the system:
    # yum update -y
  3. Disabled selinux and firewall:
    # sed -i 's/^SELINUX=.*/SELINUX=disabled/' /etc/selinux/config
    # chkconfig iptables off
    # chkconfig ip6tables off
    
  4. Rebooted
  5. Installed apache2, php and mysql-server:
    # yum install -y httpd php{,-gd,-bcmath,-mbstring,-xml,-mysql} mysql-server
  6. Added zabbix repo:
    # rpm -ivh http://repo.zabbix.com/zabbix/2.4/rhel/6/x86_64/zabbix-release-2.4-1.el6.noarch.rpm
  7. Installed zabbix:
    # yum install -y zabbix-server-mysql zabbix-web-mysql
  8. Started mysql-server service:
    # service mysqld start
  9. Secured mysql-server:
    # mysql_secure_installation
    
    
    
    NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
          SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!
    
    
    In order to log into MySQL to secure it, we'll need the current
    password for the root user.  If you've just installed MySQL, and
    you haven't set the root password yet, the password will be blank,
    so you should just press enter here.
    
    Enter current password for root (enter for none): 
    OK, successfully used password, moving on...
    
    Setting the root password ensures that nobody can log into the MySQL
    root user without the proper authorisation.
    
    Set root password? [Y/n]    
    New password: 
    Re-enter new password: 
    Password updated successfully!
    Reloading privilege tables..
     ... Success!
    
    
    By default, a MySQL installation has an anonymous user, allowing anyone
    to log into MySQL without having to have a user account created for
    them.  This is intended only for testing, and to make the installation
    go a bit smoother.  You should remove them before moving into a
    production environment.
    
    Remove anonymous users? [Y/n] 
     ... Success!
    
    Normally, root should only be allowed to connect from 'localhost'.  This
    ensures that someone cannot guess at the root password from the network.
    
    Disallow root login remotely? [Y/n] 
     ... Success!
    
    By default, MySQL comes with a database named 'test' that anyone can
    access.  This is also intended only for testing, and should be removed
    before moving into a production environment.
    
    Remove test database and access to it? [Y/n] 
     - Dropping test database...
     ... Success!
     - Removing privileges on test database...
     ... Success!
    
    Reloading the privilege tables will ensure that all changes made so far
    will take effect immediately.
    
    Reload privilege tables now? [Y/n] 
     ... Success!
    
    Cleaning up...
    
    
    
    All done!  If you've completed all of the above steps, your MySQL
    installation should now be secure.
    
    Thanks for using MySQL!
    
  10. Created zabbix database:
    # mysql -uroot -p
    mysql> create database zabbix character set utf8 collate utf8_bin;
    mysql> grant all privileges on zabbix.* to zabbix@localhost identified by '<password>';
    mysql> quit;
    # cd /usr/share/doc/zabbix-server-mysql-2.4.4/create
    # mysql -uzabbix -p zabbix < schema.sql
    # mysql -uzabbix -p zabbix < images.sql
    # mysql -uzabbix -p zabbix < data.sql
    
  11. Set "DBPassword" in /etc/zabbix/zabbix_server.conf:
    ...
    DBPassword=<password>
    ...
    
  12. Set correct timezone in /etc/httpd/conf.d/zabbix.conf:
    ...
    php_value date.timezone Europe/Kiev
    ...
    
  13. Started apache2 service:
    # service httpd start
  14. Started zabbix-server service:
    # service zabbix-server start
  15. Finished installation on http://server.ip/zabbix
  16. Same error as I described above

# yum list installed php*
...
php.x86_64                            5.3.3-40.el6_6                    @updates
php-bcmath.x86_64                     5.3.3-40.el6_6                    @updates
php-cli.x86_64                        5.3.3-40.el6_6                    @updates
php-common.x86_64                     5.3.3-40.el6_6                    @updates
php-gd.x86_64                         5.3.3-40.el6_6                    @updates
php-mbstring.x86_64                   5.3.3-40.el6_6                    @updates
php-mysql.x86_64                      5.3.3-40.el6_6                    @updates
php-pdo.x86_64                        5.3.3-40.el6_6                    @updates
php-xml.x86_64                        5.3.3-40.el6_6                    @updates

Please let me know what I might did wrong or if you need some more information.

Comment by Oleksii Zagorskyi [ 2015 Mar 06 ]

https://www.zabbix.com/documentation/2.4/manual/installation/requirements requires PHP 5.3.0 or later

http://php.net/manual/en/function.array-combine.php says that:

Changelog ΒΆ
Version	Description
5.4.0	Previous versions issued E_WARNING and returned FALSE for empty arrays.

PHP on my debian host is 5.6.5-2 and of course I don't see such error.

The array-combine() function usage introduced in ZBX-8448 in zabbix release 2.4.4
I guess it should be reviewed.

Comment by Oleksii Zagorskyi [ 2015 Mar 06 ]

Issue confirmed as it requires to be checked by devs.

Comment by Oleksii Zagorskyi [ 2015 Mar 06 ]

Trivial -> Critical

Comment by Ivo Kurzemnieks [ 2015 Mar 09 ]

(1) No translation string changes.

oleg.egorov CLOSED

Comment by Ivo Kurzemnieks [ 2015 Mar 09 ]

array_combine() exists since 2.0 (PHP 5.1.6) and is used only in one place, which seems to work and can't be broken.
This problem also exists in 2.2 (PHP 5.3.0) in template edit form

array_combine() [<a href='function.array-combine'>function.array-combine</a>]: Both parameters should have at least 1 element [templates.php:464 ? CView->render() ? include() ? array_combine() in C:\Development\zabbix-2.2\frontends\php\include\views\configuration.template.edit.php:173]

and in API hostgroup.massupdate.
I created separate development branches, since 2.2 will not merge well with 2.4 and trunk due to different code in each branches.
RESOLVED in:

  • 2.2 => svn://svn.zabbix.com/branches/dev/ZBX-9365
  • 2.4 => svn://svn.zabbix.com/branches/dev/ZBX-9365-24
  • trunk => svn://svn.zabbix.com/branches/dev/ZBX-9365-trunk
Comment by Oleg Egorov (Inactive) [ 2015 Mar 20 ]

TESTED

Comment by Ivo Kurzemnieks [ 2015 Mar 20 ]

Fixed in:

  • pre-2.2.10rc1 r52808
  • pre-2.4.5rc1 r52809
  • pre-2.5.0 (trunk) r52810
Comment by Geoff Maciolek [ 2015 Jul 23 ]

I very nearly opened a duplicate of this issue; 2.2.9 on CentOS 5, MySQL 5.0.95, PHP 5.3.3 (all w/OS patches). Just confirming I have this happen in 2.2.9; but for me this only happens on create Template, not on create Host.

array_combine() [<a href='function.array-combine'>function.array-combine</a>]: Both parameters should have at least 1 element [templates.php:464 β†’ CView->render() β†’ include() β†’ array_combine() in /var/www/html/include/views/configuration.template.edit.php:173]

Is it safe for me to create a host or template? I'm concerned about database corruption etc.

iivs Should be safe for 2.2.9, since it is just a frontend runtime warning, but 2.2.10 is relased and it's even safer there.

Generated at Fri Apr 26 01:49:31 EEST 2024 using Jira 9.12.4#9120004-sha1:625303b708afdb767e17cb2838290c41888e9ff0.