After upgrading from RHEL 5x to CentOS 6x, I started seeing these errors in my httpd log:
PHP Strict Standards: Non-static method PEAR::isError() should not be called statically in /web/sites/blah/somescript.php on line 33
I saw similar errors for MDB2. More on that in a sec.
somescript.php:
32 $mdb2_dbx = MDB2::factory($dsn_mdb2, $mdb2_options);
33 if (PEAR::isError($mdb2_dbx))
34 {
35 $err = '<p>Cannot connect to database: ' . $mdb2_dbx->getMessage();
36 errorHandler($err);
37 }
The first thing I did was edit /etc/php.ini
and add & ~E_STRICT
to error reporting. Restarted httpd to load the new config. Still getting these error messages.
Others mentioned the same problem with MDB2, so I updated these packages to the beta releases. This seemed to address MDB2 errors, but I'm still getting the PEAR error messages in httpd log file.
System info:
# pear list
PEAR 1.9.4 stable
MDB2 2.5.0b5 beta
MDB2_Driver_mysql 1.5.0b4 beta
MDB2_Driver_mysqli 1.5.0b4 beta
# php --version
PHP 5.4.20 (cli) (built: Sep 18 2013 19:55:33)
# cat /etc/centos-release
CentOS release 6.4 (Final)
# apachectl -v
Server version: Apache/2.2.15 (Unix)
Question
Is there a different way of invoking PEAR::isError()
that will not produce errors?
I'm afraid @johannes is incorrect - this is very doable. Simply substitute this in your recipe:
if ((new PEAR)->isError($mdb2_dbx)) {
// Victory! Er, I mean, Error!
...
}
It may be worth noting that that calling PEAR::isError($obj)
with one argument is equivalent to is_a($obj, 'PEAR_Error')
, if you're updating your own code. I know it is not best practice to "unwrap" a library method like that, but it is basically just an "instance of" check.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With