[ZBX-11549] Notice "A non well formed numeric value encountered" in dashboard with PHP 7.1 Created: 2016 Dec 02  Updated: 2024 Apr 10  Resolved: 2017 May 14

Status: Closed
Project: ZABBIX BUGS AND ISSUES
Component/s: Frontend (F)
Affects Version/s: 3.0.5, 3.2.1
Fix Version/s: 3.0.10rc1, 3.2.7rc1, 3.4.0alpha1

Type: Incident report Priority: Major
Reporter: Gunars Pujats (Inactive) Assignee: Unassigned
Resolution: Fixed Votes: 4
Labels: dashboard, notices, php
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
is duplicated by ZBX-13139 Invalid implementation of str2mem (fr... Closed
Team: Team C
Team: Team C
Sprint: Sprint 4, Sprint 5, Sprint 6, Sprint 7
Story Points: 0.5

 Description   

PHP 7.1 produces notices in Zabbix dashboard view


A non well formed numeric value encountered : zabbix.php:21 ? require_once() ? ZBase->run() ? ZBase->processRequest() ? CView->getOutput() ? include() ? make_status_of_zbx() ? CFrontendSetup->checkRequirements() ? CFrontendSetup->checkPhpMemoryLimit() ? str2mem() in include/func.inc.php:410
A non well formed numeric value encountered : zabbix.php:21 ? require_once() ? ZBase->run() ? ZBase->processRequest() ? CView->getOutput() ? include() ? make_status_of_zbx() ? CFrontendSetup->checkRequirements() ? CFrontendSetup->checkPhpPostMaxSize() ? str2mem() in include/func.inc.php:410
A non well formed numeric value encountered zabbix.php:21 ? require_once() ? ZBase->run() ? ZBase->processRequest() ? CView->getOutput() ? include() ? make_status_of_zbx() ? CFrontendSetup->checkRequirements() ? CFrontendSetup->checkPhpUploadMaxFilesize() ? str2mem() in include/func.inc.php:410



 Comments   
Comment by Gunars Pujats (Inactive) [ 2016 Dec 02 ]

More info about PHP changes here: https://wiki.php.net/rfc/invalid_strings_in_arithmetic

Comment by Thomas Stein [ 2017 Jan 06 ]

Hi Devs.

I see this too with my php-7.1 installation. Any patches i can test welcome.

thanks and cheers

Comment by Nikolay Kondratev [ 2017 Jan 11 ]

The same problem for me. php 7.1

Comment by Sebastian Żmijewski [ 2017 Jan 17 ]

File include/func.inc.php

    function str2mem($val) {
        $val = trim($val);
        $last = strtolower(substr($val, -1));

        switch ($last) {
                case 'g':
                        $val = (int) $val * 1024;
                        /* falls through */
                case 'm':
                        $val = (int) $val * 1024;
                        /* falls through */
                case 'k':
                        $val = (int) $val * 1024;

        }

        return $val;
}

Comment by Thomas Stein [ 2017 Jan 17 ]

Thanks. Solves the problem for me.

cheers
t.

Comment by Hugo [ 2017 Jan 25 ]

trying Sebastian Żmijewski changes with php 7.1.1 I still got the warning.
so i stripped the last char

function str2mem($val) {
        $val = trim($val);
        $last = strtolower(substr($val, -1));

        $val = substr_replace($val, "", -1);

        switch ($last) {
                case 'g':
                        $val *= $val * 1024;
                        /* falls through */
                case 'm':
                        $val *= $val * 1024;
                        /* falls through */
                case 'k':
                        $val *= $val * 1024;
        }

        return $val;
}
Comment by Oleksandr Natalenko [ 2017 Mar 05 ]

Still on 3.2.4. Fixed by adding "$val = (int)$val;" before switch statement.

Comment by Gregory Chalenko [ 2017 Mar 20 ]

In PHP7 strings containing hexadecimal numbers are no longer considered to be numeric.
http://php.net/manual/en/migration70.incompatible.php#migration70.incompatible.strings.hex

Comment by Gregory Chalenko [ 2017 Mar 20 ]

Fixed in: svn://svn.zabbix.com/branches/dev/ZBX-11549 r66565

Comment by tarmo [ 2017 May 07 ]

Can anyone please explain how to apply this fix provided by Gregory Chalenko ?
I have zabbix 3.2 installed in ubuntu 16.04 machine.

Comment by Oleksandr Natalenko [ 2017 May 07 ]

tarmo, it's the same fix I've suggested previously

https://www.zabbix.org/websvn/wsvn/zabbix.com?op=comp&compare[]=/branches/dev/ZBX-11549/@66564&compare[]=/branches/dev/ZBX-11549/@66565

Wait for new package or go and edit relevant file directly.

Comment by Gregory Chalenko [ 2017 May 09 ]

Fixed in:

  • 3.0 r67967
  • 3.2 r67968
  • 3.4.0alpha1 (trunk) r67969
Generated at Fri Apr 19 21:59:12 EEST 2024 using Jira 9.12.4#9120004-sha1:625303b708afdb767e17cb2838290c41888e9ff0.