ZABBIX BUGS AND ISSUES

"mysql" extension is deprecated for PHP 5.5, zabbix frontend should be ready for this

Details

  • Type: Improvement Improvement
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 2.0.4, 2.1.0
  • Fix Version/s: 2.0.8rc1, 2.1.2
  • Component/s: Frontend (F)
  • Labels:
  • Environment:
    PHP 5.5 +
  • Zabbix ID:
    RTD

Description

When I use PHP 5.5, top of any page I have a red warning:
mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead [include/db.inc.php:77]

See any function for the "mysql" extension, for example http://php.net/manual/en/function.mysql-connect.php

PHP 5.5 is not released yet (as for 2012-12-22), only 5.5.0 Alpha2 is available, but would be good to be ready to 5.5.0 release.
  1. db.inc.patch
    2013 Jul 11 09:59
    3 kB
    Michel Meyers
  2. mysqli.diff
    2013 Jun 04 21:34
    2 kB
    Daniele Sluijters

Activity

Hide
Oleksiy Zagorskyi added a comment -
Show
Oleksiy Zagorskyi added a comment - A wiki page https://wiki.php.net/rfc/mysql_deprecation
Hide
Alexei Vladishev added a comment -

I do not think Zabbix 2.2 will be ready for a combo of PHP 5.5 and MySQL.

Show
Alexei Vladishev added a comment - I do not think Zabbix 2.2 will be ready for a combo of PHP 5.5 and MySQL.
Hide
Alexey Pustovalov added a comment - - edited

For some distributives PHP 5.5 has been introduced already!

Oleksiy Zagorskyi I as know dotheft meant Gentoo Linux.
But ... at the moment only PHP 5.5.0 beta1 available http://php.net/

Oleksiy Zagorskyi update. 5.5.0 has been released already - 20-Jun-2013

Show
Alexey Pustovalov added a comment - - edited For some distributives PHP 5.5 has been introduced already! Oleksiy Zagorskyi I as know dotheft meant Gentoo Linux. But ... at the moment only PHP 5.5.0 beta1 available http://php.net/ Oleksiy Zagorskyi update. 5.5.0 has been released already - 20-Jun-2013
Hide
Daniele Sluijters added a comment - - edited

I just attached the mysqli.diff.

This is my first attempt. It should get you started.

However, I get stuck on mysqli_real_escape_string now complaining that hte first argument is null which would mean $DB['DB'] is null but I'm pretty sure it would've exploded earlier if it were.

My PHP debugging skills are pretty much non-existant so if someone can take it from here that'd be great.

Show
Daniele Sluijters added a comment - - edited I just attached the mysqli.diff. This is my first attempt. It should get you started. However, I get stuck on mysqli_real_escape_string now complaining that hte first argument is null which would mean $DB['DB'] is null but I'm pretty sure it would've exploded earlier if it were. My PHP debugging skills are pretty much non-existant so if someone can take it from here that'd be great.
Hide
Michel Meyers added a comment -

@Daniele Sluijters: The problem is simple: $DB isn't available within that function, so $DB is empty. To make it available, add this line:

global $DB;

Right after this one:

function zbx_dbstr($var) {

Show
Michel Meyers added a comment - @Daniele Sluijters: The problem is simple: $DB isn't available within that function, so $DB is empty. To make it available, add this line: global $DB; Right after this one: function zbx_dbstr($var) {
Hide
Volker Fröhlich added a comment -

Fedora also introduced PHP 5.5 in version 19, which is the current release, published a few weeks ago.

Show
Volker Fröhlich added a comment - Fedora also introduced PHP 5.5 in version 19, which is the current release, published a few weeks ago.
Hide
Vilius Šumskas added a comment -

Just wanted to add what others are saying. This should be looked at faster. Most of the distributions already have PHP 5.5 as a default. Zabbix is completely broken on those. It's not just about warning message PHP produces, but because of that also all Graphs are missing.

Show
Vilius Šumskas added a comment - Just wanted to add what others are saying. This should be looked at faster. Most of the distributions already have PHP 5.5 as a default. Zabbix is completely broken on those. It's not just about warning message PHP produces, but because of that also all Graphs are missing.
Hide
Volker Fröhlich added a comment -

While I know the guidelines speak out against global variables, that's still a lot better than shipping it in this broken state in Fedora. Gilboa Davara confirmed db.inc.patch to do the job on https://bugzilla.redhat.com/show_bug.cgi?id=983096. I'll include this patch in lack of alternatives.

Show
Volker Fröhlich added a comment - While I know the guidelines speak out against global variables, that's still a lot better than shipping it in this broken state in Fedora. Gilboa Davara confirmed db.inc.patch to do the job on https://bugzilla.redhat.com/show_bug.cgi?id=983096. I'll include this patch in lack of alternatives.
Hide
Pavels Jelisejevs added a comment -

Volker, thank you for the patch. This issue will be fixed in 2.0 and 2.2.

Show
Pavels Jelisejevs added a comment - Volker, thank you for the patch. This issue will be fixed in 2.0 and 2.2.
Hide
Volker Fröhlich added a comment -

(The patch isn't mine.)

Good to hear!

Show
Volker Fröhlich added a comment - (The patch isn't mine.) Good to hear!
Hide
Ivo Kurzemnieks added a comment -

We decided that changing functions from mysql to mysqli for ZABBIX 2.0 would be a serious change in system requirements. So for ZABBIX 2.0 and users with PHP version > 5.3, deprecated errors will be suppressed.

Show
Ivo Kurzemnieks added a comment - We decided that changing functions from mysql to mysqli for ZABBIX 2.0 would be a serious change in system requirements. So for ZABBIX 2.0 and users with PHP version > 5.3, deprecated errors will be suppressed.
Hide
Vilius Šumskas added a comment -

Does this mean that suppressing error will make Graphs working again?

Show
Vilius Šumskas added a comment - Does this mean that suppressing error will make Graphs working again?
Hide
Ivo Kurzemnieks added a comment -

Yes, graphs will work again.

Show
Ivo Kurzemnieks added a comment - Yes, graphs will work again.
Hide
Ivo Kurzemnieks added a comment -

RESOLVED for 2.0 in svn://svn.zabbix.com/branches/dev/ZBX-6020 r37703
RESOLVED for 2.2 in svn://svn.zabbix.com/branches/dev/ZBX-6020-trunk r37717 (additional coding style fix provided in r37718)

Show
Ivo Kurzemnieks added a comment - RESOLVED for 2.0 in svn://svn.zabbix.com/branches/dev/ZBX-6020 r37703 RESOLVED for 2.2 in svn://svn.zabbix.com/branches/dev/ZBX-6020-trunk r37717 (additional coding style fix provided in r37718)
Hide
tim.tian added a comment - - edited

Zabbix server version 2.0.7
Mysql server version 5.6.13
php version 5.5.0

db.inc.php
71 $DB['TYPE'] = zbx_strtoupper($DB['TYPE']);
72
73 switch ($DB['TYPE']) {
74 case ZBX_DB_MYSQL:
75 $DB['DB'] = mysqli_connect($DB['SERVER'], $DB['USER'], $DB['PASSWORD'], $DB['DATABASE'], $DB['PORT'] );
76
77 if (!$DB['DB']) { 78 $error = 'Error connecting to database ['.mysqli_connect_error().']'; 79 $result = false; 80 }
81 else { 82 DBexecute('SET NAMES utf8'); 83 }
84 break;
nginx log
2013/08/13 11:13:45 [error] 30696#0: *7 FastCGI sent in stderr: "PHP Fatal error: Call to undefined function mysqli_connect() in /opt/app/nginx/html/zabbix/include/db.inc.php on line 75" while reading response header from upstream, client: 192.168.19.112, server: localhost, request: "GET /zabbix/ HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "192.168.67.26"

Where is my question?
Please help answer.

Show
tim.tian added a comment - - edited Zabbix server version 2.0.7 Mysql server version 5.6.13 php version 5.5.0 db.inc.php 71 $DB['TYPE'] = zbx_strtoupper($DB['TYPE']); 72 73 switch ($DB['TYPE']) { 74 case ZBX_DB_MYSQL: 75 $DB['DB'] = mysqli_connect($DB['SERVER'], $DB['USER'], $DB['PASSWORD'], $DB['DATABASE'], $DB['PORT'] ); 76 77 if (!$DB['DB']) { 78 $error = 'Error connecting to database ['.mysqli_connect_error().']'; 79 $result = false; 80 } 81 else { 82 DBexecute('SET NAMES utf8'); 83 } 84 break; nginx log 2013/08/13 11:13:45 [error] 30696#0: *7 FastCGI sent in stderr: "PHP Fatal error: Call to undefined function mysqli_connect() in /opt/app/nginx/html/zabbix/include/db.inc.php on line 75" while reading response header from upstream, client: 192.168.19.112, server: localhost, request: "GET /zabbix/ HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "192.168.67.26" Where is my question? Please help answer.
Hide
Pavels Jelisejevs added a comment -

tim.tian, it looks like you don't have the mysqli extension installed or enabled. Please refer to the PHP documentation for information on how to install the extension:

http://www.php.net/manual/en/mysqli.installation.php

Show
Pavels Jelisejevs added a comment - tim.tian, it looks like you don't have the mysqli extension installed or enabled. Please refer to the PHP documentation for information on how to install the extension: http://www.php.net/manual/en/mysqli.installation.php
Hide
Pavels Jelisejevs added a comment - - edited

(1) I've made some changes to the 2.0 fix in r37755. Please review.

Ivo Kurzemnieks REVIEWED
Please, see minor update in r37760

Pavels Jelisejevs Right, thanks. CLOSED.

Show
Pavels Jelisejevs added a comment - - edited (1) I've made some changes to the 2.0 fix in r37755. Please review. Ivo Kurzemnieks REVIEWED Please, see minor update in r37760 Pavels Jelisejevs Right, thanks. CLOSED.
Hide
Pavels Jelisejevs added a comment - - edited

(2) Trunk fix: in setup.php we still check for mysql functions to get a list of supported databases.

Ivo Kurzemnieks RESOLVED in r37763

Pavels Jelisejevs CLOSED.

Show
Pavels Jelisejevs added a comment - - edited (2) Trunk fix: in setup.php we still check for mysql functions to get a list of supported databases. Ivo Kurzemnieks RESOLVED in r37763 Pavels Jelisejevs CLOSED.
Hide
Pavels Jelisejevs added a comment - - edited

(3) Zabbix 2.2 will now require the "mysqli" PHP extension instead of "mysql". This must be documented.

<richlv> both requirements page and upgrade notes

Martins Valkovskis Updated documentation for review:

https://www.zabbix.com/documentation/2.2/manual/installation/upgrade_notes_220#mysqli_php_extension_required
https://www.zabbix.com/documentation/2.2/manual/installation/requirements#frontend

<richlv> looking good, CLOSED

Show
Pavels Jelisejevs added a comment - - edited (3) Zabbix 2.2 will now require the "mysqli" PHP extension instead of "mysql". This must be documented. <richlv> both requirements page and upgrade notes Martins Valkovskis Updated documentation for review: https://www.zabbix.com/documentation/2.2/manual/installation/upgrade_notes_220#mysqli_php_extension_required https://www.zabbix.com/documentation/2.2/manual/installation/requirements#frontend <richlv> looking good, CLOSED
Hide
Pavels Jelisejevs added a comment -

Both branches are TESTED.

Show
Pavels Jelisejevs added a comment - Both branches are TESTED.
Hide
Ivo Kurzemnieks added a comment -

Fixed in pre-2.0.8rc1 r37776 and pre-2.1.2 (trunk) r37779

Show
Ivo Kurzemnieks added a comment - Fixed in pre-2.0.8rc1 r37776 and pre-2.1.2 (trunk) r37779
Hide
richlv added a comment - - edited
Show
richlv added a comment - - edited (4) actually, this must also be documented in whatsnew for 2.0.8 Martins Valkovskis For review: https://www.zabbix.com/documentation/2.0/manual/introduction/whatsnew208#suppressed_warning_messages_about_deprecated_mysql_extension Pavels Jelisejevs CLOSED.
Hide
Huender Pereira added a comment -

I'm having the same problem, I installed Debian 7.1 version of zabbix 2.0.7 and mysql-server-5.5 apache2.
What should I do to stop this error?
Thank you.

Show
Huender Pereira added a comment - I'm having the same problem, I installed Debian 7.1 version of zabbix 2.0.7 and mysql-server-5.5 apache2. What should I do to stop this error? Thank you.
Hide
Volker Fröhlich added a comment -

svn co the 2.0 branch, obtain the diff between r37776 and whatever is before that, apply to your frontend, done!

https://www.zabbix.org/wiki/Get_Zabbix

Show
Volker Fröhlich added a comment - svn co the 2.0 branch, obtain the diff between r37776 and whatever is before that, apply to your frontend, done! https://www.zabbix.org/wiki/Get_Zabbix
Hide
Pavels Jelisejevs added a comment - - edited

(5) User history does not work with a new database. This is because mysqli_fetch_assoc() returns null instead of false if no results exist. if mysqli_fetch_assoc() returns null, DBfetch must return false to avoid changing the signature of the function. Other functions must also be reviewed for this problem.

Ivo Kurzemnieks RESOLVED in svn://svn.zabbix.com/branches/dev/ZBX-6020 r37947

Pavels Jelisejevs I've made the changes we discussed in r37964. Please review.

Ivo Kurzemnieks REVIEWED.

Looks good, thanks!

As I mentioned, I checked all other mysqli functions, and the ones we use, don't differ from mysql functions. Only mysqli_real_escape_string may return empty string insteal of false as mysql_real_escape_string does. But the values and DB existance is validated even before that, so it should work.

CLOSED.

Show
Pavels Jelisejevs added a comment - - edited (5) User history does not work with a new database. This is because mysqli_fetch_assoc() returns null instead of false if no results exist. if mysqli_fetch_assoc() returns null, DBfetch must return false to avoid changing the signature of the function. Other functions must also be reviewed for this problem. Ivo Kurzemnieks RESOLVED in svn://svn.zabbix.com/branches/dev/ZBX-6020 r37947 Pavels Jelisejevs I've made the changes we discussed in r37964. Please review. Ivo Kurzemnieks REVIEWED. Looks good, thanks! As I mentioned, I checked all other mysqli functions, and the ones we use, don't differ from mysql functions. Only mysqli_real_escape_string may return empty string insteal of false as mysql_real_escape_string does. But the values and DB existance is validated even before that, so it should work. CLOSED.
Hide
Pavels Jelisejevs added a comment -

TESTED.

Show
Pavels Jelisejevs added a comment - TESTED.
Hide
Ivo Kurzemnieks added a comment -

Fixed in pre-2.1.3 (trunk) r37978

Show
Ivo Kurzemnieks added a comment - Fixed in pre-2.1.3 (trunk) r37978
Hide
Volker Fröhlich added a comment - - edited

(6) Did you not add this ticket to the 2.0.8 release notes for a reason?

<richlv> indeed, it's in the changelog but missing from the release notes...

<alexei> I just updated release notes on our web site

<richlv> hmm... don't see it in http://www.zabbix.com/rn2.0.8.php ...

Show
Volker Fröhlich added a comment - - edited (6) Did you not add this ticket to the 2.0.8 release notes for a reason? <richlv> indeed, it's in the changelog but missing from the release notes... <alexei> I just updated release notes on our web site <richlv> hmm... don't see it in http://www.zabbix.com/rn2.0.8.php ...
Hide
Omar ABOU added a comment -

Hello,

I installed zabbix using yum, on Fedora 19 with MySQL 5.5, Apache 2 and PHP 5.5.

When I log to frontend, I encounter the same error.

From the previous posts, I gathered that a patch has been released. Being new to Linux, I need some guidance to apply the fix.

Can you elaborate on how to fix the problem with CLI ?

Additionnally, the dashbord displays the value 'NO' in the 'Zabbix server is running' section, although I started the zabbix-server service in CLI.

Is this a common issue ? How can I solve it ?

Thanks in advance for your help.

Show
Omar ABOU added a comment - Hello, I installed zabbix using yum, on Fedora 19 with MySQL 5.5, Apache 2 and PHP 5.5. When I log to frontend, I encounter the same error. From the previous posts, I gathered that a patch has been released. Being new to Linux, I need some guidance to apply the fix. Can you elaborate on how to fix the problem with CLI ? Additionnally, the dashbord displays the value 'NO' in the 'Zabbix server is running' section, although I started the zabbix-server service in CLI. Is this a common issue ? How can I solve it ? Thanks in advance for your help.
Hide
Pavels Jelisejevs added a comment -

CLOSED.

Show
Pavels Jelisejevs added a comment - CLOSED.

People

Vote (6)
Watch (6)

Dates

  • Created:
    Updated:
    Resolved: