Browse Source

Fixed bug #42798 (__autoload() not triggered for classes used in method signature).

PECL
Dmitry Stogov 19 years ago
parent
commit
3a3a7e7441
  1. 2
      NEWS
  2. 15
      Zend/tests/bug42798.phpt
  3. 6
      Zend/zend_constants.c
  4. 3
      Zend/zend_execute_API.c

2
NEWS

@ -32,6 +32,8 @@ PHP NEWS
- Improved and cleaned CGI code. FastCGI is now always enabled and can not be
disabled. See sapi/cgi/CHANGES for more details. (Dmitry)
- Fixed bug #42798 (__autoload() not triggered for classes used in method
signature). (Dmitry)
- Fixed bug #42657 (ini_get() returns incorrect value when default is NULL).
(Jani)
- Fixed bug #42069 (parse_ini_file() allows using some non-alpha numeric

15
Zend/tests/bug42798.phpt

@ -0,0 +1,15 @@
--TEST--
Bug #42798 (_autoload() not triggered for classes used in method signature)
--FILE--
<?php
function __autoload($className) {
print "$className\n";
exit();
}
function foo($c = ok::constant) {
}
foo();
--EXPECT--
ok

6
Zend/zend_constants.c

@ -355,8 +355,10 @@ ZEND_API int zend_get_constant_ex(char *name, uint name_len, zval *result, zend_
}
efree(lcname);
/* Check for class */
ce = zend_fetch_class(class_name, class_name_len, flags TSRMLS_CC);
if ((flags & IS_CONSTANT_RT_NS_CHECK) == 0) {
/* Check for class */
ce = zend_fetch_class(class_name, class_name_len, flags TSRMLS_CC);
}
}
if (retval && ce) {

3
Zend/zend_execute_API.c

@ -451,6 +451,7 @@ ZEND_API int zend_is_true(zval *op)
#define IS_VISITED_CONSTANT IS_CONSTANT_INDEX
#define IS_CONSTANT_VISITED(p) (Z_TYPE_P(p) & IS_VISITED_CONSTANT)
#define Z_REAL_TYPE_P(p) (Z_TYPE_P(p) & ~IS_VISITED_CONSTANT)
#define MARK_CONSTANT_VISITED(p) Z_TYPE_P(p) |= IS_VISITED_CONSTANT
ZEND_API int zval_update_constant_ex(zval **pp, void *arg, zend_class_entry *scope TSRMLS_DC)
@ -474,7 +475,7 @@ ZEND_API int zval_update_constant_ex(zval **pp, void *arg, zend_class_entry *sco
refcount = p->refcount;
is_ref = p->is_ref;
if (!zend_get_constant_ex(p->value.str.val, p->value.str.len, &const_value, scope, Z_TYPE_P(p) TSRMLS_CC)) {
if (!zend_get_constant_ex(p->value.str.val, p->value.str.len, &const_value, scope, Z_REAL_TYPE_P(p) TSRMLS_CC)) {
if ((colon = memchr(Z_STRVAL_P(p), ':', Z_STRLEN_P(p))) && colon[1] == ':') {
zend_error(E_ERROR, "Undefined class constant '%s'", Z_STRVAL_P(p));
}

Loading…
Cancel
Save