[ZBX-6020] "mysql" extension is deprecated for PHP 5.5, zabbix frontend should be ready for this Created: 2012 Dec 22  Updated: 2017 May 30  Resolved: 2013 Oct 23

Status: Closed
Project: ZABBIX BUGS AND ISSUES
Component/s: Frontend (F)
Affects Version/s: 2.0.4, 2.1.0
Fix Version/s: 2.0.8rc1, 2.1.2

Type: Incident report Priority: Major
Reporter: Oleksii Zagorskyi Assignee: Unassigned
Resolution: Fixed Votes: 6
Labels: compatibility, php
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

PHP 5.5 +


Attachments: Text File db.inc.patch     File mysqli.diff    

 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.



 Comments   
Comment by Oleksii Zagorskyi [ 2012 Dec 22 ]

A wiki page https://wiki.php.net/rfc/mysql_deprecation

Comment by Alexei Vladishev [ 2012 Dec 28 ]

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

Comment by Alexey Pustovalov [ 2013 Mar 27 ]

For some distributives PHP 5.5 has been introduced already!

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

zalex_ua update. 5.5.0 has been released already - 20-Jun-2013

Comment by Daniele Sluijters [ 2013 Jun 04 ]

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.

Comment by Michel Meyers [ 2013 Jul 11 ]

@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) {

Comment by Volker Fröhlich [ 2013 Jul 31 ]

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

Comment by Vilius Šumskas [ 2013 Jul 31 ]

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.

Comment by Volker Fröhlich [ 2013 Aug 04 ]

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.

Comment by Pavels Jelisejevs (Inactive) [ 2013 Aug 05 ]

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

Comment by Volker Fröhlich [ 2013 Aug 05 ]

(The patch isn't mine.)

Good to hear!

Comment by Ivo Kurzemnieks [ 2013 Aug 09 ]

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.

Comment by Vilius Šumskas [ 2013 Aug 09 ]

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

Comment by Ivo Kurzemnieks [ 2013 Aug 09 ]

Yes, graphs will work again.

Comment by Ivo Kurzemnieks [ 2013 Aug 09 ]

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)

Comment by tim.tian [ 2013 Aug 13 ]

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.

Comment by Pavels Jelisejevs (Inactive) [ 2013 Aug 13 ]

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

Comment by Pavels Jelisejevs (Inactive) [ 2013 Aug 13 ]

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

iivs REVIEWED
Please, see minor update in r37760

jelisejev Right, thanks. CLOSED.

Comment by Pavels Jelisejevs (Inactive) [ 2013 Aug 13 ]

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

iivs RESOLVED in r37763

jelisejev CLOSED.

Comment by Pavels Jelisejevs (Inactive) [ 2013 Aug 13 ]

(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-v 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

Comment by Pavels Jelisejevs (Inactive) [ 2013 Aug 13 ]

Both branches are TESTED.

Comment by Ivo Kurzemnieks [ 2013 Aug 13 ]

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

Comment by richlv [ 2013 Aug 14 ]

(4) actually, this must also be documented in whatsnew for 2.0.8

martins-v For review: https://www.zabbix.com/documentation/2.0/manual/introduction/whatsnew208#suppressed_warning_messages_about_deprecated_mysql_extension

jelisejev CLOSED.

Comment by Huender Pereira [ 2013 Aug 17 ]

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.

Comment by Volker Fröhlich [ 2013 Aug 17 ]

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

Comment by Pavels Jelisejevs (Inactive) [ 2013 Aug 19 ]

(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.

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

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

iivs 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.

Comment by Pavels Jelisejevs (Inactive) [ 2013 Aug 20 ]

TESTED.

Comment by Ivo Kurzemnieks [ 2013 Aug 20 ]

Fixed in pre-2.1.3 (trunk) r37978

Comment by Volker Fröhlich [ 2013 Aug 24 ]

(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 ...

Comment by Omar ABOU [ 2013 Aug 24 ]

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.

Comment by Pavels Jelisejevs (Inactive) [ 2013 Oct 23 ]

CLOSED.

Comment by deepanshu [ 2014 Dec 27 ]

how to use these patches and mysqli.diff

Comment by Volker Fröhlich [ 2014 Dec 27 ]

You don't need a patch. Just upgrade to 2.0.8 or later.

Generated at Thu Apr 18 07:38:36 EEST 2024 using Jira 9.12.4#9120004-sha1:625303b708afdb767e17cb2838290c41888e9ff0.