diff options
author | Dmitry Stogov <dmitry@php.net> | 2009-02-09 09:20:35 +0000 |
---|---|---|
committer | Dmitry Stogov <dmitry@php.net> | 2009-02-09 09:20:35 +0000 |
commit | c277ebc6c8076ffdabad78d76b05538345207685 (patch) | |
tree | 4af03990d43e5cb50b8973f375a3b6268ae3743c | |
parent | c13177f18299b671dc7f157f3b7bf2eadbb38f4d (diff) | |
download | php-git-c277ebc6c8076ffdabad78d76b05538345207685.tar.gz |
Fixed bug #47320 ($php_errormsg out of scope in functions)
-rw-r--r-- | NEWS | 1 | ||||
-rw-r--r-- | Zend/tests/bug47320.phpt | 26 | ||||
-rw-r--r-- | Zend/zend_execute_API.c | 16 | ||||
-rw-r--r-- | main/main.c | 30 |
4 files changed, 55 insertions, 18 deletions
@@ -1,6 +1,7 @@ PHP NEWS ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| ?? ??? 2009, PHP 5.3.0 Beta 2 +- Fixed bug #47320 ($php_errormsg out of scope in functions). (Dmitry) - Fixed bug #47265 (generating phar.phar failes because of safe_mode). (Greg) - Fixed bug #47229 (preg_quote() should escape the '-' char). (Nuno) - Fixed bug #47085 (rename() returns true even if the file in PHAR does not exist). (Greg) diff --git a/Zend/tests/bug47320.phpt b/Zend/tests/bug47320.phpt new file mode 100644 index 0000000000..47db35edac --- /dev/null +++ b/Zend/tests/bug47320.phpt @@ -0,0 +1,26 @@ +--TEST-- +Bug #47320 ($php_errormsg out of scope in functions) +--INI-- +display_errors=0 +track_errors=1 +--FILE-- +<?php +if (!@substr('no 2nd parameter')) { + echo '$php_errormsg in global: ' . $php_errormsg . "\n"; +} + +function foo() { + if (!@strpos('no 2nd parameter')) { + echo '$php_errormsg in function: ' . $php_errormsg . "\n"; + + echo '$GLOBALS[php_errormsg] in function: ' . + $GLOBALS['php_errormsg'] . "\n"; + } +} + +foo(); +?> +--EXPECT-- +$php_errormsg in global: substr() expects at least 2 parameters, 1 given +$php_errormsg in function: strpos() expects at least 2 parameters, 1 given +$GLOBALS[php_errormsg] in function: substr() expects at least 2 parameters, 1 given diff --git a/Zend/zend_execute_API.c b/Zend/zend_execute_API.c index 3bdfc5b6e0..36240eefce 100644 --- a/Zend/zend_execute_API.c +++ b/Zend/zend_execute_API.c @@ -1631,15 +1631,15 @@ ZEND_API void zend_rebuild_symbol_table(TSRMLS_D) /* {{{ */ return; } - if (EG(symtable_cache_ptr)>=EG(symtable_cache)) { - /*printf("Cache hit! Reusing %x\n", symtable_cache[symtable_cache_ptr]);*/ - EG(active_symbol_table) = *(EG(symtable_cache_ptr)--); - } else { - ALLOC_HASHTABLE(EG(active_symbol_table)); - zend_hash_init(EG(active_symbol_table), 0, NULL, ZVAL_PTR_DTOR, 0); - /*printf("Cache miss! Initialized %x\n", EG(active_symbol_table));*/ - } if (ex && ex->op_array) { + if (EG(symtable_cache_ptr)>=EG(symtable_cache)) { + /*printf("Cache hit! Reusing %x\n", symtable_cache[symtable_cache_ptr]);*/ + EG(active_symbol_table) = *(EG(symtable_cache_ptr)--); + } else { + ALLOC_HASHTABLE(EG(active_symbol_table)); + zend_hash_init(EG(active_symbol_table), 0, NULL, ZVAL_PTR_DTOR, 0); + /*printf("Cache miss! Initialized %x\n", EG(active_symbol_table));*/ + } ex->symbol_table = EG(active_symbol_table); if (ex->op_array->this_var != -1 && diff --git a/main/main.c b/main/main.c index 0687c90001..d98aafe4fd 100644 --- a/main/main.c +++ b/main/main.c @@ -750,12 +750,17 @@ PHPAPI void php_verror(const char *docref, const char *params, int type, const c efree(docref_buf); } - if (PG(track_errors) && module_initialized && EG(active_symbol_table) && + if (PG(track_errors) && module_initialized && (!EG(user_error_handler) || !(EG(user_error_handler_error_reporting) & type))) { - zval *tmp; - ALLOC_INIT_ZVAL(tmp); - ZVAL_STRINGL(tmp, buffer, buffer_len, 1); - zend_hash_update(EG(active_symbol_table), "php_errormsg", sizeof("php_errormsg"), (void **) &tmp, sizeof(zval *), NULL); + if (!EG(active_symbol_table)) { + zend_rebuild_symbol_table(TSRMLS_C); + } + if (EG(active_symbol_table)) { + zval *tmp; + ALLOC_INIT_ZVAL(tmp); + ZVAL_STRINGL(tmp, buffer, buffer_len, 1); + zend_hash_update(EG(active_symbol_table), "php_errormsg", sizeof("php_errormsg"), (void **) &tmp, sizeof(zval *), NULL); + } } efree(buffer); @@ -1033,11 +1038,16 @@ static void php_error_cb(int type, const char *error_filename, const uint error_ return; } - if (PG(track_errors) && module_initialized && EG(active_symbol_table)) { - zval *tmp; - ALLOC_INIT_ZVAL(tmp); - ZVAL_STRINGL(tmp, buffer, buffer_len, 1); - zend_hash_update(EG(active_symbol_table), "php_errormsg", sizeof("php_errormsg"), (void **) & tmp, sizeof(zval *), NULL); + if (PG(track_errors) && module_initialized) { + if (!EG(active_symbol_table)) { + zend_rebuild_symbol_table(TSRMLS_C); + } + if (EG(active_symbol_table)) { + zval *tmp; + ALLOC_INIT_ZVAL(tmp); + ZVAL_STRINGL(tmp, buffer, buffer_len, 1); + zend_hash_update(EG(active_symbol_table), "php_errormsg", sizeof("php_errormsg"), (void **) & tmp, sizeof(zval *), NULL); + } } efree(buffer); |