0

We recently upgraded from PHP 5 to 7.4, and out Pear MBD2 package is spamming our Apache2 log with a bunch of ridiculous notices.

PHP Notice:  A non well formed numeric value encountered in /usr/share/php/MDB2/Driver/mysqli.php on line 1154, referer:

Our web apps are working fine, and I know its not best practice at all, but how do we shut this notice up?

Is there any way to configure or upgrade Pear/MDB2 to stop?

Pear and MDB2 was installed via docker image, so I'll have to dig for the exact line where its throwing this.

Any help or wisdom would be appreciated.

This is the line it's throwing an issue over:

 $statement_name = sprintf($this->options['statement_format'], $this->phptype, $prep_statement_counter++ . sha1(microtime() + mt_rand()));
Powermaster Prime
  • 402
  • 1
  • 2
  • 16
  • 2
    You upgraded from PHP 5 to what? What is happening on and around line `1154`? – Chris Haas Feb 23 '22 at 17:50
  • To 7.4. The package is installed via docker image instructions, so let me get back to one details. – Powermaster Prime Feb 23 '22 at 17:58
  • What is the code? Newer versions of PHP might have fatal error on it, so suppressing in that case would be a bad choice. – user3783243 Feb 23 '22 at 18:17
  • Bad code is bad code. `microtime()` returns an _array_ and then that code tries to add a number to it which is bad and now raises an error. Normally I would say "upgrade the library", but the last _non-beta_ release of MDB2 was in _2007_ circa PHP 5.2, and even the last beta release was 2012. You probably shouldn't be using this library at all anymore. – Sammitch Feb 23 '22 at 20:37
  • Any recommended replacements for this? I need to do more research on exactly what the functionality is anyway. – Powermaster Prime Feb 23 '22 at 20:40
  • 1
    It's a DB abstraction layer, so why not use the one built into PHP? PDO. I'd wager that that's why development on MDB2 died. https://www.php.net/manual/en/book.pdo.php – Sammitch Feb 23 '22 at 23:57
  • I know Stackoverflow rules dictate I shouldn't reply with a thankyou, but I'm doing it anyway haha. I'll be reading more about it today, and see what I can do. – Powermaster Prime Feb 24 '22 at 13:40

1 Answers1

1

To get rid of the notices, disable logging of E_NOTICE messages.

At the beginning of your code, add

error_reporting(error_reporting() & ~E_NOTICE);

.. or disable it in the php.ini configuration file by adjusting the error_reporting setting.

cweiske
  • 30,033
  • 14
  • 133
  • 194