summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile.global1
-rw-r--r--NEWS6
-rw-r--r--Zend/tests/bug64979.phpt18
-rw-r--r--Zend/tests/bug65322.phpt22
-rw-r--r--Zend/tests/errmsg_045.phpt18
-rw-r--r--Zend/zend.c4
-rw-r--r--Zend/zend_generators.c28
-rw-r--r--ext/ldap/ldap.c1
-rw-r--r--ext/ldap/tests/ldap_search_variation6.phpt20
9 files changed, 101 insertions, 17 deletions
diff --git a/Makefile.global b/Makefile.global
index 05c5d151b7..c56ef992d9 100644
--- a/Makefile.global
+++ b/Makefile.global
@@ -125,6 +125,7 @@ distclean: clean
rm -f sapi/fpm/php-fpm.conf sapi/fpm/init.d.php-fpm sapi/fpm/php-fpm.service sapi/fpm/php-fpm.8 sapi/fpm/status.html
rm -f ext/iconv/php_have_bsd_iconv.h ext/iconv/php_have_glibc_iconv.h ext/iconv/php_have_ibm_iconv.h ext/iconv/php_have_iconv.h ext/iconv/php_have_libiconv.h ext/iconv/php_iconv_aliased_libiconv.h ext/iconv/php_iconv_supports_errno.h ext/iconv/php_php_iconv_h_path.h ext/iconv/php_php_iconv_impl.h
rm -f ext/phar/phar.phar ext/phar/phar.php
+ rm -f pear/install-pear-nozlib.phar
if test "$(srcdir)" != "$(builddir)"; then \
rm -f ext/phar/phar/phar.inc; \
fi
diff --git a/NEWS b/NEWS
index c03d319056..1b1f9c4bdf 100644
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,10 @@ PHP NEWS
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
?? ??? 2013, PHP 5.5.5
+- Core:
+ . Fixed bug #64979 (Wrong behavior of static variables in closure generators).
+ (Nikita)
+
- CLI server:
. Fixed bug #65633 (built-in server treat some http headers as
case-sensitive). (Adam)
@@ -39,7 +43,7 @@ PHP NEWS
. Fix bug #64782 (SplFileObject constructor make $context optional / give it
a default value). (Nikita)
-?? ??? 2013, PHP 5.5.4
+19 Sep 2013, PHP 5.5.4
- Core:
. Fixed bug #60598 (cli/apache sapi segfault on objects manipulation).
diff --git a/Zend/tests/bug64979.phpt b/Zend/tests/bug64979.phpt
index 09de555546..5bc8e5a6ab 100644
--- a/Zend/tests/bug64979.phpt
+++ b/Zend/tests/bug64979.phpt
@@ -1,15 +1,13 @@
--TEST--
-Bug #64578 (Closures with static variables can be generators)
---XFAIL--
-Bug #64979 not fixed yet.
+Bug #64979 (Wrong behavior of static variables in closure generators)
--FILE--
<?php
function new_closure_gen() {
- return function() {
- static $foo = 0;
- yield ++$foo;
- };
+ return function() {
+ static $foo = 0;
+ yield ++$foo;
+ };
}
$closure1 = new_closure_gen();
@@ -20,9 +18,9 @@ $gen2 = $closure1();
$gen3 = $closure2();
foreach (array($gen1, $gen2, $gen3) as $gen) {
- foreach ($gen as $val) {
- print "$val\n";
- }
+ foreach ($gen as $val) {
+ var_dump($val);
+ }
}
?>
diff --git a/Zend/tests/bug65322.phpt b/Zend/tests/bug65322.phpt
new file mode 100644
index 0000000000..aab163d915
--- /dev/null
+++ b/Zend/tests/bug65322.phpt
@@ -0,0 +1,22 @@
+--TEST--
+Bug #65322: compile time errors won't trigger auto loading
+--FILE--
+<?php
+
+spl_autoload_register(function($class) {
+ var_dump($class);
+ class B {}
+});
+
+set_error_handler(function($_, $msg, $file) {
+ var_dump($msg, $file);
+ new B;
+});
+
+eval('class A { function a() {} function __construct() {} }');
+
+?>
+--EXPECTF--
+string(50) "Redefining already defined constructor for class A"
+string(%d) "%s(%d) : eval()'d code"
+string(1) "B"
diff --git a/Zend/tests/errmsg_045.phpt b/Zend/tests/errmsg_045.phpt
new file mode 100644
index 0000000000..b27f67ade4
--- /dev/null
+++ b/Zend/tests/errmsg_045.phpt
@@ -0,0 +1,18 @@
+--TEST--
+Error message in error handler during compilation
+--FILE--
+<?php
+
+set_error_handler(function($_, $msg, $file) {
+ var_dump($msg, $file);
+ echo $undefined;
+});
+
+eval('class A { function a() {} function __construct() {} }');
+
+?>
+--EXPECTF--
+string(50) "Redefining already defined constructor for class A"
+string(%d) "%s(%d) : eval()'d code"
+
+Notice: Undefined variable: undefined in %s on line %d
diff --git a/Zend/zend.c b/Zend/zend.c
index f9069c8e1b..11baf34c93 100644
--- a/Zend/zend.c
+++ b/Zend/zend.c
@@ -1184,7 +1184,7 @@ ZEND_API void zend_error(int type, const char *format, ...) /* {{{ */
* such scripts recursivly, but some CG() variables may be
* inconsistent. */
- in_compilation = zend_is_compiling(TSRMLS_C);
+ in_compilation = CG(in_compilation);
if (in_compilation) {
saved_class_entry = CG(active_class_entry);
CG(active_class_entry) = NULL;
@@ -1196,6 +1196,7 @@ ZEND_API void zend_error(int type, const char *format, ...) /* {{{ */
SAVE_STACK(declare_stack);
SAVE_STACK(list_stack);
SAVE_STACK(context_stack);
+ CG(in_compilation) = 0;
}
if (call_user_function_ex(CG(function_table), NULL, orig_user_error_handler, &retval, 5, params, 1, NULL TSRMLS_CC) == SUCCESS) {
@@ -1220,6 +1221,7 @@ ZEND_API void zend_error(int type, const char *format, ...) /* {{{ */
RESTORE_STACK(declare_stack);
RESTORE_STACK(list_stack);
RESTORE_STACK(context_stack);
+ CG(in_compilation) = 1;
}
if (!EG(user_error_handler)) {
diff --git a/Zend/zend_generators.c b/Zend/zend_generators.c
index 1a805bbd6d..0af20f4593 100644
--- a/Zend/zend_generators.c
+++ b/Zend/zend_generators.c
@@ -226,6 +226,16 @@ static zend_object_value zend_generator_create(zend_class_entry *class_type TSRM
}
/* }}} */
+static void copy_closure_static_var(zval **var TSRMLS_DC, int num_args, va_list args, zend_hash_key *key) /* {{{ */
+{
+ HashTable *target = va_arg(args, HashTable *);
+
+ SEPARATE_ZVAL_TO_MAKE_IS_REF(var);
+ Z_ADDREF_PP(var);
+ zend_hash_quick_update(target, key->arKey, key->nKeyLength, key->h, var, sizeof(zval *), NULL);
+}
+/* }}} */
+
/* Requires globals EG(scope), EG(current_scope), EG(This),
* EG(active_symbol_table) and EG(current_execute_data). */
ZEND_API zval *zend_generator_create_zval(zend_op_array *op_array TSRMLS_DC) /* {{{ */
@@ -242,7 +252,23 @@ ZEND_API zval *zend_generator_create_zval(zend_op_array *op_array TSRMLS_DC) /*
if (op_array->fn_flags & ZEND_ACC_CLOSURE) {
zend_op_array *op_array_copy = (zend_op_array*)emalloc(sizeof(zend_op_array));
*op_array_copy = *op_array;
- function_add_ref((zend_function *) op_array_copy);
+
+ (*op_array->refcount)++;
+ op_array->run_time_cache = NULL;
+ if (op_array->static_variables) {
+ ALLOC_HASHTABLE(op_array_copy->static_variables);
+ zend_hash_init(
+ op_array_copy->static_variables,
+ zend_hash_num_elements(op_array->static_variables),
+ NULL, ZVAL_PTR_DTOR, 0
+ );
+ zend_hash_apply_with_arguments(
+ op_array->static_variables TSRMLS_CC,
+ (apply_func_args_t) copy_closure_static_var,
+ 1, op_array_copy->static_variables
+ );
+ }
+
op_array = op_array_copy;
}
diff --git a/ext/ldap/ldap.c b/ext/ldap/ldap.c
index 3cfa2092e7..71d57d6d9b 100644
--- a/ext/ldap/ldap.c
+++ b/ext/ldap/ldap.c
@@ -2107,6 +2107,7 @@ PHP_FUNCTION(ldap_set_rebind_proc)
/* unregister rebind procedure */
if (ld->rebindproc != NULL) {
zval_dtor(ld->rebindproc);
+ FREE_ZVAL(ld->rebindproc);
ld->rebindproc = NULL;
ldap_set_rebind_proc(ld->link, NULL, NULL);
}
diff --git a/ext/ldap/tests/ldap_search_variation6.phpt b/ext/ldap/tests/ldap_search_variation6.phpt
index a29e4524df..5139ebb77d 100644
--- a/ext/ldap/tests/ldap_search_variation6.phpt
+++ b/ext/ldap/tests/ldap_search_variation6.phpt
@@ -217,14 +217,26 @@ array(2) {
[1]=>
resource(%d) of type (ldap result)
}
-NULL
-NULL
+array(1) {
+ ["count"]=>
+ int(0)
+}
+array(1) {
+ ["count"]=>
+ int(0)
+}
array(2) {
[0]=>
resource(%d) of type (ldap result)
[1]=>
resource(%d) of type (ldap result)
}
-NULL
-NULL
+array(1) {
+ ["count"]=>
+ int(0)
+}
+array(1) {
+ ["count"]=>
+ int(0)
+}
===DONE===