is_a() in PHP 5.3.7

Two days ago the new PHP version 5.3.7 was released. Since it fixed a few major security issues I installed it on one of my testing systems and began  running a few programs to test stability and compatibility.

To my surprise one of the changes must have been essential. Many of the old tests relying on PEAR did produce failures because an autoloader was triggered and the handler I use in tests fails by default.

What happened? Well… is_a() was called with a string as first argument. Instead of just returning an error, it called the autoloader to load a class by the name of the string given.

Reading the release notes – again – I stumbled upon the following line:

Removed warning when argument of is_a() or is_subclass_of() is not a known class. (Stas)

Looking at the source code showed that this change was not only removing a warning message but also changing the semantics of is_a() to match that of is_subclass_of(). Thanks, PHP team!

I created a simple patch to match the previous behavior. If someone is interested, just ask.

2 responses to “is_a() in PHP 5.3.7

  1. I found the same problem … my mail was silently erring out. Not sure if they’ll revert behavior, but this change worked for me in /usr/share/pear/PEAR.php:

    function isError($data, $code = null)
    {
    if (!is_object($data) || !is_a($data, ‘PEAR_Error’)) {
    false;

    If $data is a string, it now triggers the __autoload.

  2. It’s not just only PEAR.php, but many PEAR packages as well. My three options were changing my autoloader, changing the PEAR packages or change the PHP interpreter to use the old behavior. I decided for the latter because it was the easiest way.

    PHP 5.4 uses the new behavior, too, so I think the change will not be reverted in 5.3.8 which will be released as a bug fix release for crypt() in a few days.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.