rasmus                                   Fri, 23 Sep 2011 09:52:09 +0000

Revision: http://svn.php.net/viewvc?view=revision&revision=317183

Log:
Re-committing Alan's is_a revert/fix for bug #55475
Dmitry had done so earlier, but reverted pending discussion.
It is completely clear that this should never have been changed in the
5.3 branch in the first place giving the number of things that broke
because of it.

Bug: https://bugs.php.net/55475 (Assigned) is_a() triggers autoloader
      
Changed paths:
    U   php/php-src/branches/PHP_5_3/Zend/zend_builtin_functions.c
    U   php/php-src/branches/PHP_5_3/Zend/zend_ini_scanner.c
    U   php/php-src/branches/PHP_5_3/Zend/zend_ini_scanner_defs.h

Modified: php/php-src/branches/PHP_5_3/Zend/zend_builtin_functions.c
===================================================================
--- php/php-src/branches/PHP_5_3/Zend/zend_builtin_functions.c  2011-09-23 
09:29:27 UTC (rev 317182)
+++ php/php-src/branches/PHP_5_3/Zend/zend_builtin_functions.c  2011-09-23 
09:52:09 UTC (rev 317183)
@@ -816,13 +816,19 @@
        int class_name_len;
        zend_class_entry *instance_ce;
        zend_class_entry **ce;
+       zend_bool allow_string = only_subclass;
        zend_bool retval;

-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zs", &obj, 
&class_name, &class_name_len) == FAILURE) {
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zs|b", &obj, 
&class_name, &class_name_len, &allow_string) == FAILURE) {
                return;
        }
-
-       if (Z_TYPE_P(obj) == IS_STRING) {
+       /*
+          allow_string - is_a default is no, is_subclass_of is yes.
+          if it's allowed, then the autoloader will be called if the class 
does not exist.
+          default behaviour is different, as 'is_a' usage is normally to test 
mixed return values
+       */
+
+       if (allow_string && Z_TYPE_P(obj) == IS_STRING) {
                zend_class_entry **the_ce;
                if (zend_lookup_class(Z_STRVAL_P(obj), Z_STRLEN_P(obj), &the_ce 
TSRMLS_CC) == FAILURE) {
                        RETURN_FALSE;
@@ -848,7 +854,7 @@
 }


-/* {{{ proto bool is_subclass_of(object object, string class_name)
+/* {{{ proto bool is_subclass_of(mixed object_or_string, string class_name [, 
bool allow_string=true])
    Returns true if the object has this class as one of its parents */
 ZEND_FUNCTION(is_subclass_of)
 {
@@ -857,8 +863,8 @@
 /* }}} */


-/* {{{ proto bool is_a(object object, string class_name)
-   Returns true if the object is of this class or has this class as one of its 
parents */
+/* {{{ proto bool is_a(mixed object_or_string, string class_name [, bool 
allow_string=false])
+   Returns true if the first argument is an object and is this class or has 
this class as one of its parents, */
 ZEND_FUNCTION(is_a)
 {
        is_a_impl(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0);

Modified: php/php-src/branches/PHP_5_3/Zend/zend_ini_scanner.c
===================================================================
--- php/php-src/branches/PHP_5_3/Zend/zend_ini_scanner.c        2011-09-23 
09:29:27 UTC (rev 317182)
+++ php/php-src/branches/PHP_5_3/Zend/zend_ini_scanner.c        2011-09-23 
09:52:09 UTC (rev 317183)
@@ -1,4 +1,4 @@
-/* Generated by re2c 0.13.5 on Sun Aug  1 12:07:43 2010 */
+/* Generated by re2c 0.13.5 on Fri Aug 26 18:01:17 2011 */
 #line 1 "Zend/zend_ini_scanner.l"
 /*
    +----------------------------------------------------------------------+

Modified: php/php-src/branches/PHP_5_3/Zend/zend_ini_scanner_defs.h
===================================================================
--- php/php-src/branches/PHP_5_3/Zend/zend_ini_scanner_defs.h   2011-09-23 
09:29:27 UTC (rev 317182)
+++ php/php-src/branches/PHP_5_3/Zend/zend_ini_scanner_defs.h   2011-09-23 
09:52:09 UTC (rev 317183)
@@ -1,4 +1,4 @@
-/* Generated by re2c 0.13.5 on Sun Aug  1 12:07:43 2010 */
+/* Generated by re2c 0.13.5 on Fri Aug 26 18:01:17 2011 */
 #line 3 "Zend/zend_ini_scanner_defs.h"

 enum YYCONDTYPE {

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to