FAQ
Hi.

After upgrading to php 5.3.7, whenever I use is_a($object, 'ClassName');
the autoloader of classes is now called.

This did not happen in earlier versions of php 5.3 that I used before.
But I cannot find any mention of it anywhere, no open bugs for it, and
nothing in the changelogs.

Is it a bug or is it intentional that it has started behaving this way?

--
Mads Lie Jensen - mads@gartneriet.dk - ICQ #25478403
Gartneriet - http://www.gartneriet.dk/

Search Discussions

  • Kalle Sommer Nielsen at Aug 22, 2011 at 6:10 am
    Hi

    2011/8/22 Mads Lie Jensen <mads@gartneriet.dk>:
    Hi.

    After upgrading to php 5.3.7, whenever I use is_a($object, 'ClassName');
    the autoloader of classes is now called.

    This did not happen in earlier versions of php 5.3 that I used before.
    But I cannot find any  mention of it anywhere, no open bugs for it, and
    nothing in the changelogs.

    Is it a bug or is it intentional that it has started behaving this way?
    I'm unable to reproduce your case in 5.3.4RC1, 5.3.7 and 5.3-svn:
    http://pastie.org/2410070

    Please open a bug report [1] and attach a script to reproduce the
    behaviour you are seeing (should be a 10 liner script for this
    incident)

    [1] http://bugs.php.net/

    --
    regards,

    Kalle Sommer Nielsen
    kalle@php.net
  • Mads Lie Jensen at Aug 22, 2011 at 6:22 am

    On Mon, 22 Aug 2011 08:10:28 +0200, kalle@php.net (Kalle Sommer Nielsen) wrote:
    After upgrading to php 5.3.7, whenever I use is_a($object, 'ClassName');
    the autoloader of classes is now called.

    This did not happen in earlier versions of php 5.3 that I used before.
    But I cannot find any  mention of it anywhere, no open bugs for it, and
    nothing in the changelogs.

    Is it a bug or is it intentional that it has started behaving this way?
    I'm unable to reproduce your case in 5.3.4RC1, 5.3.7 and 5.3-svn:
    http://pastie.org/2410070
    Ah, I now see that it only happens when trying to check something which
    is not actually an object:

    <?php

    function __autoload($class) {
    echo "Would load: " . $class . PHP_EOL;
    }

    $var = "test";
    var_dump(is_a($var, 'B'));

    $obj = new Stdclass;
    var_dump(is_a($obj, 'C'));

    ?>

    But still, it did not happen in earlier phpversions.
    --
    Mads Lie Jensen - mads@gartneriet.dk - ICQ #25478403
    Gartneriet - http://www.gartneriet.dk/
  • Hannes Magnusson at Aug 22, 2011 at 8:00 am

    On Mon, Aug 22, 2011 at 08:22, Mads Lie Jensen wrote:
    On Mon, 22 Aug 2011 08:10:28 +0200, kalle@php.net (Kalle Sommer Nielsen)
    wrote:
    After upgrading to php 5.3.7, whenever I use is_a($object, 'ClassName');
    the autoloader of classes is now called.

    This did not happen in earlier versions of php 5.3 that I used before.
    But I cannot find any  mention of it anywhere, no open bugs for it, and
    nothing in the changelogs.

    Is it a bug or is it intentional that it has started behaving this way?
    I'm unable to reproduce your case in 5.3.4RC1, 5.3.7 and 5.3-svn:
    http://pastie.org/2410070
    Ah, I now see that it only happens when trying to check something which
    is not actually an object:

    <?php

    function __autoload($class) {
    echo "Would load: " . $class . PHP_EOL;
    }

    $var = "test";
    var_dump(is_a($var, 'B'));

    $obj = new Stdclass;
    var_dump(is_a($obj, 'C'));

    ?>

    But still, it did not happen in earlier phpversions.

    I can reproduce that in 5.3-svn and 5.4-svn.

    Please file a bug report for it, this should probably be fixed in 5.3.8 too.

    -Hannes
  • Mads Lie Jensen at Aug 22, 2011 at 8:17 am

    On Mon, 22 Aug 2011 10:00:11 +0200, hannes.magnusson@gmail.com (Hannes Magnusson) wrote:

    I can reproduce that in 5.3-svn and 5.4-svn.

    Please file a bug report for it, this should probably be fixed in 5.3.8 too.
    Done:

    Bug #55475 is_a() triggers autoloader
    --
    Mads Lie Jensen - mads@gartneriet.dk - ICQ #25478403
    Gartneriet - http://www.gartneriet.dk/
  • Kalle Sommer Nielsen at Aug 22, 2011 at 10:34 am

    2011/8/22 Mads Lie Jensen <mads@gartneriet.dk>:
    On Mon, 22 Aug 2011 10:00:11 +0200, hannes.magnusson@gmail.com (Hannes
    Magnusson) wrote:
    I can reproduce that in 5.3-svn and 5.4-svn.

    Please file a bug report for it, this should probably be fixed in 5.3.8 too.
    Done:

    Bug #55475      is_a() triggers autoloader
    I have attached a simple one liner patch to the report, which like
    Hannes said, should go into 5.3.8 to keep BC.

    --
    regards,

    Kalle Sommer Nielsen
    kalle@php.net
  • Ilia Alshanetsky at Aug 22, 2011 at 1:12 pm
    The fix looks good, Dmitry can you please review it, if it is good
    let's get it into 5.3.8
    On Mon, Aug 22, 2011 at 6:33 AM, Kalle Sommer Nielsen wrote:
    2011/8/22 Mads Lie Jensen <mads@gartneriet.dk>:
    On Mon, 22 Aug 2011 10:00:11 +0200, hannes.magnusson@gmail.com (Hannes
    Magnusson) wrote:
    I can reproduce that in 5.3-svn and 5.4-svn.

    Please file a bug report for it, this should probably be fixed in 5.3.8 too.
    Done:

    Bug #55475      is_a() triggers autoloader
    I have attached a simple one liner patch to the report, which like
    Hannes said, should go into 5.3.8 to keep BC.

    --
    regards,

    Kalle Sommer Nielsen
    kalle@php.net

    --
    PHP Internals - PHP Runtime Development Mailing List
    To unsubscribe, visit: http://www.php.net/unsub.php
  • Etienne Kneuss at Aug 22, 2011 at 1:23 pm
    The actual question is whether the "fix" makes sense or not in the first place.

    Please debate in the bug report directly to avoid a schizophrenic discussion.

    Best,
    On Mon, Aug 22, 2011 at 15:12, Ilia Alshanetsky wrote:
    The fix looks good, Dmitry can you please review it, if it is good
    let's get it into 5.3.8
    On Mon, Aug 22, 2011 at 6:33 AM, Kalle Sommer Nielsen wrote:
    2011/8/22 Mads Lie Jensen <mads@gartneriet.dk>:
    On Mon, 22 Aug 2011 10:00:11 +0200, hannes.magnusson@gmail.com (Hannes
    Magnusson) wrote:
    I can reproduce that in 5.3-svn and 5.4-svn.

    Please file a bug report for it, this should probably be fixed in 5.3.8 too.
    Done:

    Bug #55475      is_a() triggers autoloader
    I have attached a simple one liner patch to the report, which like
    Hannes said, should go into 5.3.8 to keep BC.

    --
    regards,

    Kalle Sommer Nielsen
    kalle@php.net

    --
    PHP Internals - PHP Runtime Development Mailing List
    To unsubscribe, visit: http://www.php.net/unsub.php
    --
    PHP Internals - PHP Runtime Development Mailing List
    To unsubscribe, visit: http://www.php.net/unsub.php


    --
    Etienne Kneuss
    http://www.colder.ch
  • Etienne Kneuss at Aug 22, 2011 at 8:20 am
    Hi,
    On Mon, Aug 22, 2011 at 08:22, Mads Lie Jensen wrote:
    On Mon, 22 Aug 2011 08:10:28 +0200, kalle@php.net (Kalle Sommer Nielsen)
    wrote:
    After upgrading to php 5.3.7, whenever I use is_a($object, 'ClassName');
    the autoloader of classes is now called.

    This did not happen in earlier versions of php 5.3 that I used before.
    But I cannot find any  mention of it anywhere, no open bugs for it, and
    nothing in the changelogs.

    Is it a bug or is it intentional that it has started behaving this way?
    I'm unable to reproduce your case in 5.3.4RC1, 5.3.7 and 5.3-svn:
    http://pastie.org/2410070
    Ah, I now see that it only happens when trying to check something which
    is not actually an object:

    <?php

    function __autoload($class) {
    echo "Would load: " . $class . PHP_EOL;
    }

    $var = "test";
    var_dump(is_a($var, 'B'));

    $obj = new Stdclass;
    var_dump(is_a($obj, 'C'));

    ?>

    But still, it did not happen in earlier phpversions.
    Here is the situation:

    1) The underlying implementation is shared between is_a and is_subclass_of.
    2) Previously, strings as first argument was not permitted by is_a but
    was for is_subclass_of,
    3) is_subclass_of always triggered autoload in such cases.
    4) Following a fix from Dmitry, the underlying implementation now
    allows a string as first argument for is_a as well.

    Conclusion: it is now consistent, but if you wrongly used is_a with a
    string before, it now triggers autoload because it actually accepts
    it.

    Best,
    --
    Mads Lie Jensen - mads@gartneriet.dk - ICQ #25478403
    Gartneriet - http://www.gartneriet.dk/

    --
    PHP Internals - PHP Runtime Development Mailing List
    To unsubscribe, visit: http://www.php.net/unsub.php


    --
    Etienne Kneuss
    http://www.colder.ch
  • Stas Malyshev at Aug 22, 2011 at 6:38 pm
    Hi!
    On 8/21/11 11:22 PM, Mads Lie Jensen wrote:
    Ah, I now see that it only happens when trying to check something which
    is not actually an object:

    <?php

    function __autoload($class) {
    echo "Would load: " . $class . PHP_EOL;
    }

    $var = "test";
    var_dump(is_a($var, 'B'));

    $obj = new Stdclass;
    var_dump(is_a($obj, 'C'));

    ?>
    Not a bug. $var is interpreted as a class name. To know if one class
    extends another, the class in question (first one) should be loaded.
    There's no need to load the second one since if it's unknown nothing can
    be instance of it and existing classes can not extend it.
    --
    Stanislav Malyshev, Software Architect
    SugarCRM: http://www.sugarcrm.com/
    (408)454-6900 ext. 227

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupphp-internals @
categoriesphp
postedAug 22, '11 at 5:47a
activeAug 22, '11 at 6:38p
posts10
users6
websitephp.net

People

Translate

site design / logo © 2022 Grokbase