From: Dmitry Stogov Date: Mon, 9 Feb 2009 09:20:35 +0000 (+0000) Subject: Fixed bug #47320 ($php_errormsg out of scope in functions) X-Git-Tag: RELEASE_1_3_5~164 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c277ebc6c8076ffdabad78d76b05538345207685;p=php Fixed bug #47320 ($php_errormsg out of scope in functions) --- diff --git a/NEWS b/NEWS index 18aae13b05..ef89228a81 100644 --- a/NEWS +++ b/NEWS @@ -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-- + +--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);