php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #42994 is_callable and __autoload
Submitted: 2007-10-16 15:22 UTC Modified: 2007-10-25 01:00 UTC
Votes:3
Avg. Score:3.0 ± 0.8
Reproduced:3 of 3 (100.0%)
Same Version:1 (33.3%)
Same OS:1 (33.3%)
From: arnout at argeweb dot nl Assigned:
Status: No Feedback Package: Unknown/Other Function
PHP Version: 5.2.4 OS: BSD
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2007-10-16 15:22 UTC] arnout at argeweb dot nl
Description:
------------
When using is_callable on non-existing static class functions __autoload will be called twice with some encoded (and thus non-existent) classname.


Reproduce code:
---------------
autoload.php
<?php

class test{
    function notest(){
    }
}

function __autoload( $classname ){
    echo "let's require $classname!<br/>\n";
}

if( is_callable( array( 'test', 'test' ) ) ){
    echo "test::test exists.";
}else{
    echo "test::test doesn't exist.";
}

?>

Expected result:
----------------
test::test doesn't exist.

(no __autoload execution at all)

Actual result:
--------------
let's require 9akf!
let's require 9akf!
test::test doesn't exist.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-10-16 20:12 UTC] crrodriguez at suse dot de
Your exact code works just fine here, it does not call __autoload at all... what is your exact PHP version ?
 [2007-10-17 07:22 UTC] arnout at argeweb dot nl
I tried both 5.2.3 and 5.2.4.

5.2.3:

apache_mod on apache 2.0, FreeBSD 6.2-RELEASE-p5, can't turn zend optimizer off there.


5.2.4:

Tried with Zend optimizer on and off.
php 5.2.4 apache_mod on apache 2.2
OS: FreeBSD 6.2-RELEASE-p3

'./configure' '--with-layout=GNU' '--with-config-file-scan-dir=/usr/local/etc/php' '--disable-all' '--enable-libxml' '--with-libxml-dir=/usr/local' '--enable-reflection' '--program-prefix=' '--disable-cgi' '--with-apxs2=/usr/local/sbin/apxs' '--with-regex=php' '--with-zend-vm=CALL' '--disable-ipv6' '--prefix=/usr/local' '--mandir=/usr/local/man' '--infodir=/usr/local/info/'

I hope that helps...
 [2007-10-17 07:55 UTC] johannes@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5.2-latest.tar.gz
 
For Windows (zip):
 
  http://snaps.php.net/win32/php5.2-win32-latest.zip

For Windows (installer):

  http://snaps.php.net/win32/php5.2-win32-installer-latest.msi

For me it works fine. Please make sure you're using proper source - no FreeBSD patches or something.
 [2007-10-17 08:46 UTC] arnout at argeweb dot nl
"no FreeBSD patches or something"

I asked the sysadmin.
It has probably been patched by ports. I'll try to get a clean version but that might take a while.

I'll try the snapshot too.

If it's the freebsd ports that messes up where do I need to go to get it fixed?
 [2007-10-17 09:00 UTC] johannes@php.net
In case plain PHP works report it to the FreeBSD guys.
Please keep this bug on "Feedback" till you tested it with clean sources.
 [2007-10-25 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 [2010-04-01 14:22 UTC] sb at lia dot ch
I've seen the same thing on PHP 5.2.9 FreeBSD 7.1-RELEASE-p3:

  <?
  function __autoload($class){ print "trying to load $class\n"; }

  class foo {}

  is_callable(array("foo", "bar"));
  ?>

And I get

  trying to load ffe
  trying to load ffe

Instead of no output.
 [2013-02-25 16:16 UTC] info at tueena dot com
I have a similar problem here: Debian Linux PHP package "PHP 5.3.3-7+squeeze14 with Suhosin-Patch (cli) (built: Aug  6 2012 14:18:06)":

Reproduce code:
---------------
<?php

spl_autoload_register('testAutoloader');

is_callable(array('A', 'mymethod'));
is_callable(array('Foo', 'mymethod'));
is_callable(array('ALongerClassName', 'mymethod'));

function testAutoloader($sClassName)
{
	print $sClassName . "\n";
}

Expected result:
----------------
A
Foo
ALongerClassName

Actual result:
--------------
A
w
A
w
A
Foo
ffe
Foo
ffe
Foo
ALongerClassName
q9998tg6zai2xxrw
ALongerClassName
q9998tg6zai2xxrw
ALongerClassName
 
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Wed Aug 10 23:05:51 2022 UTC