diff options
author | Aaron Piotrowski <aaron@trowski.com> | 2015-07-05 02:37:49 -0500 |
---|---|---|
committer | Aaron Piotrowski <aaron@trowski.com> | 2015-07-05 12:16:57 -0500 |
commit | 907476f34c0dbe34e311c4a99cc07eb40fd2954b (patch) | |
tree | 58c26abe27284c5c221182161cb89fdc90cadc1e | |
parent | 550bbf8f4614a5c868010195f562be3e9ee6bb00 (diff) | |
download | php-git-907476f34c0dbe34e311c4a99cc07eb40fd2954b.tar.gz |
Convert E_ERROR to thrown Error in extensions
31 files changed, 141 insertions, 79 deletions
diff --git a/ext/date/php_date.c b/ext/date/php_date.c index 2f52353ce2..fbb142b66d 100644 --- a/ext/date/php_date.c +++ b/ext/date/php_date.c @@ -28,6 +28,7 @@ #include "ext/standard/php_math.h" #include "php_date.h" #include "zend_interfaces.h" +#include "zend_exceptions.h" #include "lib/timelib.h" #include <time.h> @@ -3699,7 +3700,8 @@ PHP_METHOD(DateTimeZone, __set_state) php_date_instantiate(date_ce_timezone, return_value); tzobj = Z_PHPTIMEZONE_P(return_value); if(php_date_timezone_initialize_from_hash(&return_value, &tzobj, myht) != SUCCESS) { - php_error_docref(NULL, E_ERROR, "Timezone initialization failed"); + zend_throw_error(zend_ce_error, "Timezone initialization failed"); + RETURN_FALSE; } } /* }}} */ @@ -3717,7 +3719,8 @@ PHP_METHOD(DateTimeZone, __wakeup) myht = Z_OBJPROP_P(object); if(php_date_timezone_initialize_from_hash(&return_value, &tzobj, myht) != SUCCESS) { - php_error_docref(NULL, E_ERROR, "Timezone initialization failed"); + zend_throw_error(zend_ce_error, "Timezone initialization failed"); + RETURN_FALSE; } } /* }}} */ @@ -5015,7 +5018,8 @@ static zval *date_period_read_property(zval *object, zval *member, int type, voi { zval *zv; if (type != BP_VAR_IS && type != BP_VAR_R) { - php_error_docref(NULL, E_ERROR, "Retrieval of DatePeriod properties for modification is unsupported"); + zend_throw_error(zend_ce_error, "Retrieval of DatePeriod properties for modification is unsupported"); + return NULL; } Z_OBJPROP_P(object); /* build properties hash table */ @@ -5033,7 +5037,7 @@ static zval *date_period_read_property(zval *object, zval *member, int type, voi /* {{{ date_period_write_property */ static void date_period_write_property(zval *object, zval *member, zval *value, void **cache_slot) { - php_error_docref(NULL, E_ERROR, "Writing to DatePeriod properties is unsupported"); + zend_throw_error(zend_ce_error, "Writing to DatePeriod properties is unsupported"); } /* }}} */ diff --git a/ext/date/tests/bug68942.phpt b/ext/date/tests/bug68942.phpt index a26ce8867b..9a9a5cfb88 100644 --- a/ext/date/tests/bug68942.phpt +++ b/ext/date/tests/bug68942.phpt @@ -6,4 +6,9 @@ $data = unserialize('a:2:{i:0;O:12:"DateTimeZone":2:{s:13:"timezone_type";a:2:{i var_dump($data); ?> --EXPECTF-- -Fatal error: DateTimeZone::__wakeup(): Timezone initialization failed in %s%ebug68942.php on line %d +Fatal error: Uncaught Error: Timezone initialization failed in %s:%d +Stack trace: +#0 [internal function]: DateTimeZone->__wakeup() +#1 %s(%d): unserialize('a:2:{i:0;O:12:"...') +#2 {main} + thrown in %s on line %d diff --git a/ext/dom/document.c b/ext/dom/document.c index 0ab0e498c8..4a6c178d71 100644 --- a/ext/dom/document.c +++ b/ext/dom/document.c @@ -2223,11 +2223,13 @@ PHP_METHOD(domdocument, registerNodeClass) DOM_GET_OBJ(docp, id, xmlDocPtr, intern); if (dom_set_doc_classmap(intern->document, basece, ce) == FAILURE) { - php_error_docref(NULL, E_ERROR, "Class %s could not be registered.", ZSTR_VAL(ce->name)); + zend_throw_error(zend_ce_error, "Class %s could not be registered.", ZSTR_VAL(ce->name)); + RETURN_FALSE; } RETURN_TRUE; } else { - php_error_docref(NULL, E_ERROR, "Class %s is not derived from %s.", ZSTR_VAL(ce->name), ZSTR_VAL(basece->name)); + zend_throw_error(zend_ce_error, "Class %s is not derived from %s.", ZSTR_VAL(ce->name), ZSTR_VAL(basece->name)); + RETURN_FALSE; } RETURN_FALSE; diff --git a/ext/dom/php_dom.c b/ext/dom/php_dom.c index 35900a5829..517d645e74 100644 --- a/ext/dom/php_dom.c +++ b/ext/dom/php_dom.c @@ -286,7 +286,7 @@ PHP_DOM_EXPORT dom_object *php_dom_object_get_data(xmlNodePtr obj) /* {{{ dom_read_na */ static int dom_read_na(dom_object *obj, zval *retval) { - php_error_docref(NULL, E_ERROR, "Cannot read property"); + zend_throw_error(zend_ce_error, "Cannot read property"); return FAILURE; } /* }}} */ @@ -294,7 +294,7 @@ static int dom_read_na(dom_object *obj, zval *retval) /* {{{ dom_write_na */ static int dom_write_na(dom_object *obj, zval *newval) { - php_error_docref(NULL, E_ERROR, "Cannot write property"); + zend_throw_error(zend_ce_error, "Cannot write property"); return FAILURE; } /* }}} */ diff --git a/ext/imap/php_imap.c b/ext/imap/php_imap.c index 841143f5b3..245a3555ca 100644 --- a/ext/imap/php_imap.c +++ b/ext/imap/php_imap.c @@ -4448,7 +4448,7 @@ static zend_string* _php_rfc822_write_address(ADDRESS *addresslist) char address[SENDBUFLEN]; if (_php_imap_address_size(addresslist) >= SENDBUFLEN) { - php_error_docref(NULL, E_ERROR, "Address buffer overflow"); + zend_throw_error(zend_ce_error, "Address buffer overflow"); return NULL; } address[0] = 0; diff --git a/ext/intl/idn/idn.c b/ext/intl/idn/idn.c index 6e699604df..fed184e618 100644 --- a/ext/intl/idn/idn.c +++ b/ext/intl/idn/idn.c @@ -27,6 +27,7 @@ #include <unicode/uidna.h> #include <unicode/ustring.h> +#include "zend_exceptions.h" #include "ext/standard/php_string.h" #include "intl_error.h" @@ -165,7 +166,10 @@ static void php_intl_idn_to_46(INTERNAL_FUNCTION_PARAMETERS, RETURN_FALSE; } if (len >= 255) { - php_error_docref(NULL, E_ERROR, "ICU returned an unexpected length"); + zend_throw_error(zend_ce_error, "ICU returned an unexpected length"); + uidna_close(uts46); + zend_string_free(buffer); + RETURN_FALSE; } ZSTR_VAL(buffer)[len] = '\0'; diff --git a/ext/intl/transliterator/transliterator_class.c b/ext/intl/transliterator/transliterator_class.c index ce8c7e6291..9a4cee97b0 100644 --- a/ext/intl/transliterator/transliterator_class.c +++ b/ext/intl/transliterator/transliterator_class.c @@ -183,7 +183,7 @@ err: "Could not clone transliterator", 0 ); err_msg = intl_error_get_message( TRANSLITERATOR_ERROR_P( to_orig ) ); - php_error_docref( NULL, E_ERROR, "%s", ZSTR_VAL(err_msg) ); + zend_throw_error( zend_ce_error, "%s", ZSTR_VAL(err_msg) ); zend_string_free( err_msg ); /* if it's changed into a warning */ /* do not destroy tempz; we need to return something */ } diff --git a/ext/ldap/ldap.c b/ext/ldap/ldap.c index 945f065a76..57d12ece80 100644 --- a/ext/ldap/ldap.c +++ b/ext/ldap/ldap.c @@ -1822,8 +1822,9 @@ PHP_FUNCTION(ldap_modify_batch) oper = LDAP_MOD_REPLACE; break; default: - php_error_docref(NULL, E_ERROR, "Unknown and uncaught modification type."); - RETURN_FALSE; + zend_throw_error(zend_ce_error, "Unknown and uncaught modification type."); + RETVAL_FALSE; + goto cleanup; } /* fill in the basic info */ @@ -1868,7 +1869,7 @@ PHP_FUNCTION(ldap_modify_batch) } else RETVAL_TRUE; /* clean up */ - { + cleanup: { for (i = 0; i < num_mods; i++) { /* attribute */ efree(ldap_mods[i]->mod_type); diff --git a/ext/mbstring/php_mbregex.c b/ext/mbstring/php_mbregex.c index 88f8772d34..8f548fad4c 100644 --- a/ext/mbstring/php_mbregex.c +++ b/ext/mbstring/php_mbregex.c @@ -28,6 +28,7 @@ #if HAVE_MBREGEX +#include "zend_exceptions.h" #include "zend_smart_str.h" #include "ext/standard/info.h" #include "php_mbregex.h" @@ -943,8 +944,9 @@ static void _php_mb_regex_ereg_replace_exec(INTERNAL_FUNCTION_PARAMETERS, OnigOp /* do eval */ if (zend_eval_stringl(ZSTR_VAL(eval_buf.s), ZSTR_LEN(eval_buf.s), &v, description) == FAILURE) { efree(description); - php_error_docref(NULL,E_ERROR, "Failed evaluating code: %s%s", PHP_EOL, ZSTR_VAL(eval_buf.s)); - /* zend_error() does not return in this case */ + zend_throw_error(zend_ce_error, "Failed evaluating code: %s%s", PHP_EOL, ZSTR_VAL(eval_buf.s)); + onig_region_free(regs, 0); + RETVAL_EMPTY_STRING(); } /* result of eval */ diff --git a/ext/mbstring/tests/bug43301.phpt b/ext/mbstring/tests/bug43301.phpt index 2a5f748c5b..9c629ec38c 100644 --- a/ext/mbstring/tests/bug43301.phpt +++ b/ext/mbstring/tests/bug43301.phpt @@ -15,7 +15,14 @@ echo mb_ereg_replace($ptr,'$1',$txt,'e'); ?> --EXPECTF-- -Parse error: syntax error, unexpected %s, expecting %s or '$' in %sbug43301.php(%d) : mbregex replace on line %d +Fatal error: Uncaught ParseError: syntax error, unexpected '1' (T_LNUMBER), expecting variable (T_VARIABLE) or '{' or '$' in %sbug43301.php(%d) : mbregex replace:1 +Stack trace: +#0 %sbug43301.php(%d): mb_ereg_replace('hello', '$1', 'hello, I have g...', 'e') +#1 {main} -Fatal error: mb_ereg_replace(): Failed evaluating code: -$1 in %sbug43301.php on line %d +Next Error: Failed evaluating code: +$1 in %sbug43301.php:%d +Stack trace: +#0 %sbug43301.php(%d): mb_ereg_replace('hello', '$1', 'hello, I have g...', 'e') +#1 {main} + thrown in %sbug43301.php on line %d diff --git a/ext/mysqli/mysqli.c b/ext/mysqli/mysqli.c index 8039244b5c..b357f4b057 100644 --- a/ext/mysqli/mysqli.c +++ b/ext/mysqli/mysqli.c @@ -282,7 +282,7 @@ static void mysqli_warning_free_storage(zend_object *object) /* {{{ mysqli_read_na */ static zval *mysqli_read_na(mysqli_object *obj, zval *retval) { - php_error_docref(NULL, E_ERROR, "Cannot read property"); + zend_throw_error(zend_ce_error, "Cannot read property"); return NULL; } /* }}} */ @@ -290,7 +290,7 @@ static zval *mysqli_read_na(mysqli_object *obj, zval *retval) /* {{{ mysqli_write_na */ static int mysqli_write_na(mysqli_object *obj, zval *newval) { - php_error_docref(NULL, E_ERROR, "Cannot write property"); + zend_throw_error(zend_ce_error, "Cannot write property"); return FAILURE; } /* }}} */ diff --git a/ext/openssl/openssl.c b/ext/openssl/openssl.c index b3ef5ad003..277814f789 100644 --- a/ext/openssl/openssl.c +++ b/ext/openssl/openssl.c @@ -31,6 +31,7 @@ #include "php_openssl.h" /* PHP Includes */ +#include "zend_exceptions.h" #include "ext/standard/file.h" #include "ext/standard/info.h" #include "ext/standard/php_fopen_wrappers.h" @@ -1795,7 +1796,7 @@ zend_string* php_openssl_x509_fingerprint(X509 *peer, const char *method, zend_b php_error_docref(NULL, E_WARNING, "Unknown signature algorithm"); return NULL; } else if (!X509_digest(peer, mdtype, md, &n)) { - php_error_docref(NULL, E_ERROR, "Could not generate signature"); + zend_throw_error(zend_ce_error, "Could not generate signature"); return NULL; } diff --git a/ext/pdo_odbc/pdo_odbc.c b/ext/pdo_odbc/pdo_odbc.c index 7f16434009..515e22436f 100644 --- a/ext/pdo_odbc/pdo_odbc.c +++ b/ext/pdo_odbc/pdo_odbc.c @@ -24,6 +24,7 @@ #include "php.h" #include "php_ini.h" +#include "zend_exceptions.h" #include "ext/standard/info.h" #include "pdo/php_pdo.h" #include "pdo/php_pdo_driver.h" @@ -123,7 +124,7 @@ PHP_MINIT_FUNCTION(pdo_odbc) } else if (*pooling_val == '\0' || strcasecmp(pooling_val, "off") == 0) { pdo_odbc_pool_on = SQL_CP_OFF; } else { - php_error_docref(NULL, E_ERROR, "Error in pdo_odbc.connection_pooling configuration. Value MUST be one of 'strict', 'relaxed' or 'off'"); + zend_throw_error(zend_ce_error, "Error in pdo_odbc.connection_pooling configuration. Value MUST be one of 'strict', 'relaxed' or 'off'"); return FAILURE; } diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c index 463cbd6a3a..4684954567 100644 --- a/ext/reflection/php_reflection.c +++ b/ext/reflection/php_reflection.c @@ -88,7 +88,7 @@ ZEND_DECLARE_MODULE_GLOBALS(reflection) #define METHOD_NOTSTATIC(ce) \ if (!Z_OBJ(EX(This)) || !instanceof_function(Z_OBJCE(EX(This)), ce)) { \ - php_error_docref(NULL, E_ERROR, "%s() cannot be called statically", get_active_function_name()); \ + zend_throw_error(zend_ce_error, "%s() cannot be called statically", get_active_function_name()); \ return; \ } \ @@ -106,7 +106,8 @@ ZEND_DECLARE_MODULE_GLOBALS(reflection) intern = Z_REFLECTION_P(getThis()); \ if (intern == NULL || intern->ptr == NULL) { \ RETURN_ON_EXCEPTION \ - php_error_docref(NULL, E_ERROR, "Internal error: Failed to retrieve the reflection object"); \ + zend_throw_error(zend_ce_error, "Internal error: Failed to retrieve the reflection object"); \ + return; \ } \ #define GET_REFLECTION_OBJECT_PTR(target) \ @@ -1473,7 +1474,8 @@ static parameter_reference *_reflection_param_get_default_param(INTERNAL_FUNCTIO if (EG(exception) && EG(exception)->ce == reflection_exception_ptr) { return NULL; } - php_error_docref(NULL, E_ERROR, "Internal error: Failed to retrieve the reflection object"); + zend_throw_error(zend_ce_error, "Internal error: Failed to retrieve the reflection object"); + return NULL; } param = intern->ptr; @@ -4955,8 +4957,8 @@ ZEND_METHOD(reflection_class, isSubclassOf) if (instanceof_function(Z_OBJCE_P(class_name), reflection_class_ptr)) { argument = Z_REFLECTION_P(class_name); if (argument == NULL || argument->ptr == NULL) { - php_error_docref(NULL, E_ERROR, "Internal error: Failed to retrieve the argument's reflection object"); - /* Bails out */ + zend_throw_error(zend_ce_error, "Internal error: Failed to retrieve the argument's reflection object"); + return; } class_ce = argument->ptr; break; @@ -4999,8 +5001,8 @@ ZEND_METHOD(reflection_class, implementsInterface) if (instanceof_function(Z_OBJCE_P(interface), reflection_class_ptr)) { argument = Z_REFLECTION_P(interface); if (argument == NULL || argument->ptr == NULL) { - php_error_docref(NULL, E_ERROR, "Internal error: Failed to retrieve the argument's reflection object"); - /* Bails out */ + zend_throw_error(zend_ce_error, "Internal error: Failed to retrieve the argument's reflection object"); + return; } interface_ce = argument->ptr; break; @@ -5395,7 +5397,7 @@ ZEND_METHOD(reflection_property, getValue) return; } if (Z_TYPE(CE_STATIC_MEMBERS(intern->ce)[ref->prop.offset]) == IS_UNDEF) { - php_error_docref(NULL, E_ERROR, "Internal error: Could not find the property %s::%s", ZSTR_VAL(intern->ce->name), ZSTR_VAL(ref->prop.name)); + zend_throw_error(zend_ce_error, "Internal error: Could not find the property %s::%s", ZSTR_VAL(intern->ce->name), ZSTR_VAL(ref->prop.name)); /* Bails out */ } ZVAL_DUP(return_value, &CE_STATIC_MEMBERS(intern->ce)[ref->prop.offset]); @@ -5447,8 +5449,8 @@ ZEND_METHOD(reflection_property, setValue) } if (Z_TYPE(CE_STATIC_MEMBERS(intern->ce)[ref->prop.offset]) == IS_UNDEF) { - php_error_docref(NULL, E_ERROR, "Internal error: Could not find the property %s::%s", ZSTR_VAL(intern->ce->name), ZSTR_VAL(ref->prop.name)); - /* Bails out */ + zend_throw_error(zend_ce_error, "Internal error: Could not find the property %s::%s", ZSTR_VAL(intern->ce->name), ZSTR_VAL(ref->prop.name)); + return; } variable_ptr = &CE_STATIC_MEMBERS(intern->ce)[ref->prop.offset]; if (variable_ptr != value) { diff --git a/ext/session/mod_user.c b/ext/session/mod_user.c index 1196d867af..1f3a4e5e93 100644 --- a/ext/session/mod_user.c +++ b/ext/session/mod_user.c @@ -20,6 +20,7 @@ #include "php.h" #include "php_session.h" +#include "zend_exceptions.h" #include "mod_user.h" ps_module ps_mod_user = { @@ -191,12 +192,12 @@ PS_CREATE_SID_FUNC(user) } zval_ptr_dtor(&retval); } else { - php_error_docref(NULL, E_ERROR, "No session id returned by function"); + zend_throw_error(zend_ce_error, "No session id returned by function"); return NULL; } if (!id) { - php_error_docref(NULL, E_ERROR, "Session id must be a string"); + zend_throw_error(zend_ce_error, "Session id must be a string"); return NULL; } diff --git a/ext/session/session.c b/ext/session/session.c index ef17b86bad..e77aee9574 100644 --- a/ext/session/session.c +++ b/ext/session/session.c @@ -40,6 +40,7 @@ #include "rfc1867.h" #include "php_variables.h" #include "php_session.h" +#include "zend_exceptions.h" #include "ext/standard/md5.h" #include "ext/standard/sha1.h" #include "ext/standard/php_var.h" @@ -339,7 +340,7 @@ PHPAPI zend_string *php_session_create_id(PS_CREATE_SID_ARGS) /* {{{ */ case PS_HASH_FUNC_OTHER: if (!PS(hash_ops)) { efree(buf); - php_error_docref(NULL, E_ERROR, "Invalid session hash function"); + zend_throw_error(zend_ce_error, "Invalid session hash function"); return NULL; } @@ -351,7 +352,7 @@ PHPAPI zend_string *php_session_create_id(PS_CREATE_SID_ARGS) /* {{{ */ #endif /* HAVE_HASH_EXT */ default: efree(buf); - php_error_docref(NULL, E_ERROR, "Invalid session hash function"); + zend_throw_error(zend_ce_error, "Invalid session hash function"); return NULL; } efree(buf); @@ -480,7 +481,7 @@ static void php_session_initialize(void) /* {{{ */ zend_string *val = NULL; if (!PS(mod)) { - php_error_docref(NULL, E_ERROR, "No storage module chosen - failed to initialize session"); + zend_throw_error(zend_ce_error, "No storage module chosen - failed to initialize session"); return; } @@ -488,7 +489,7 @@ static void php_session_initialize(void) /* {{{ */ if (PS(mod)->s_open(&PS(mod_data), PS(save_path), PS(session_name)) == FAILURE /* || PS(mod_data) == NULL */ /* FIXME: open must set valid PS(mod_data) with success */ ) { - php_error_docref(NULL, E_ERROR, "Failed to initialize storage module: %s (path: %s)", PS(mod)->s_name, PS(save_path)); + zend_throw_error(zend_ce_error, "Failed to initialize storage module: %s (path: %s)", PS(mod)->s_name, PS(save_path)); return; } @@ -496,7 +497,7 @@ static void php_session_initialize(void) /* {{{ */ if (!PS(id)) { PS(id) = PS(mod)->s_create_sid(&PS(mod_data)); if (!PS(id)) { - php_error_docref(NULL, E_ERROR, "Failed to create session ID: %s (path: %s)", PS(mod)->s_name, PS(save_path)); + zend_throw_error(zend_ce_error, "Failed to create session ID: %s (path: %s)", PS(mod)->s_name, PS(save_path)); return; } if (PS(use_cookies)) { @@ -1829,7 +1830,7 @@ static PHP_FUNCTION(session_set_save_handler) add_next_index_zval(&PS(mod_user_names).names[i], obj); add_next_index_str(&PS(mod_user_names).names[i], zend_string_copy(func_name)); } else { - php_error_docref(NULL, E_ERROR, "Session handler's function table is corrupt"); + zend_throw_error(zend_ce_error, "Session handler's function table is corrupt"); RETURN_FALSE; } diff --git a/ext/session/tests/bug60860.phpt b/ext/session/tests/bug60860.phpt index 83185862f0..ddcd9803db 100644 --- a/ext/session/tests/bug60860.phpt +++ b/ext/session/tests/bug60860.phpt @@ -12,6 +12,12 @@ echo "ok\n"; ?> --EXPECTF-- -Warning: session_start(): user session functions not defined in %s on line 3 +Warning: session_start(): user session functions not defined in %s on line %d -Fatal error: session_start(): Failed to initialize storage module: user (path:%s) in %s on line 3 +Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at %s:%d) in %s on line %d + +Fatal error: Uncaught Error: Failed to initialize storage module: user (path: ) in %s:%d +Stack trace: +#0 %s(%d): session_start() +#1 {main} + thrown in %s on line %d diff --git a/ext/session/tests/session_module_name_variation3.phpt b/ext/session/tests/session_module_name_variation3.phpt index de49195fe8..241f53225d 100644 --- a/ext/session/tests/session_module_name_variation3.phpt +++ b/ext/session/tests/session_module_name_variation3.phpt @@ -41,11 +41,14 @@ ob_end_flush(); string(%d) "%s" string(4) "user" -Warning: Uncaught Exception: Stop...! in %s:%d +Fatal error: Uncaught Exception: Stop...! in %s:%d Stack trace: #0 [internal function]: open('', 'PHPSESSID') #1 %s(%d): session_start() #2 {main} - thrown in %s on line %d -Fatal error: session_start(): Failed to initialize storage module: %s in %s%esession_module_name_variation3.php on line %d +Next Error: Failed to initialize storage module: user (path: ) in %s:%d +Stack trace: +#0 %s(%d): session_start() +#1 {main} + thrown in %s on line %d diff --git a/ext/session/tests/session_save_path_variation4.phpt b/ext/session/tests/session_save_path_variation4.phpt index 80db6caf7d..ce949d807c 100644 --- a/ext/session/tests/session_save_path_variation4.phpt +++ b/ext/session/tests/session_save_path_variation4.phpt @@ -56,5 +56,8 @@ string(0) "" Warning: session_start(): open_basedir restriction in effect. File(%s) is not within the allowed path(s): (.) in %s on line %d -Fatal error: session_start(): Failed to initialize storage module: files (path: ) in %s on line %d - +Fatal error: Uncaught Error: Failed to initialize storage module: files (path: ) in %s:%d +Stack trace: +#0 %s(%d): session_start() +#1 {main} + thrown in %s on line %d diff --git a/ext/session/tests/session_set_save_handler_error3.phpt b/ext/session/tests/session_set_save_handler_error3.phpt index fdf306a4a5..cc1fe3934d 100644 --- a/ext/session/tests/session_set_save_handler_error3.phpt +++ b/ext/session/tests/session_set_save_handler_error3.phpt @@ -34,11 +34,14 @@ ob_end_flush(); --EXPECTF-- *** Testing session_set_save_handler() : error functionality *** -Warning: Uncaught Exception: Do something bad..! in %s:%d +Fatal error: Uncaught Exception: Do something bad..! in %s:%d Stack trace: #0 [internal function]: open('', 'PHPSESSID') #1 %s(%d): session_start() #2 {main} - thrown in %s on line %d -Fatal error: session_start(): Failed to initialize storage module: %s in %ssession_set_save_handler_error3.php on line %d +Next Error: Failed to initialize storage module: user (path: ) in %s:%d +Stack trace: +#0 %s(%d): session_start() +#1 {main} + thrown in %s on line %d
\ No newline at end of file diff --git a/ext/session/tests/session_set_save_handler_sid_002.phpt b/ext/session/tests/session_set_save_handler_sid_002.phpt index f9a72aebca..1d00586e89 100644 --- a/ext/session/tests/session_set_save_handler_sid_002.phpt +++ b/ext/session/tests/session_set_save_handler_sid_002.phpt @@ -74,4 +74,13 @@ session_unset(); --EXPECTF-- *** Testing session_set_save_handler() function: create_sid *** -Fatal error: session_start(): Session id must be a string in %s on line %d +Fatal error: Uncaught Error: Session id must be a string in %s:%d +Stack trace: +#0 %s(%d): session_start() +#1 {main} + +Next Error: Failed to create session ID: user (path: ) in %s:%d +Stack trace: +#0 %s(%d): session_start() +#1 {main} + thrown in %s on line %d diff --git a/ext/simplexml/simplexml.c b/ext/simplexml/simplexml.c index a54362fe4b..bcc77134c4 100644 --- a/ext/simplexml/simplexml.c +++ b/ext/simplexml/simplexml.c @@ -250,7 +250,7 @@ static zval *sxe_prop_dim_read(zval *object, zval *member, zend_bool elements, z elements = 1; } else if (!member) { /* This happens when the user did: $sxe[]->foo = $value */ - php_error_docref(NULL, E_ERROR, "Cannot create unnamed attribute"); + zend_throw_error(zend_ce_error, "Cannot create unnamed attribute"); return NULL; } name = NULL; @@ -277,7 +277,7 @@ static zval *sxe_prop_dim_read(zval *object, zval *member, zend_bool elements, z if (!member && node && node->parent && node->parent->type == XML_DOCUMENT_NODE) { /* This happens when the user did: $sxe[]->foo = $value */ - php_error_docref(NULL, E_ERROR, "Cannot create unnamed attribute"); + zend_throw_error(zend_ce_error, "Cannot create unnamed attribute"); return NULL; } } @@ -459,7 +459,7 @@ static int sxe_prop_dim_write(zval *object, zval *member, zval *value, zend_bool * and could also be E_PARSE, but we use this only during parsing * and this is during runtime. */ - php_error_docref(NULL, E_ERROR, "Cannot create unnamed attribute"); + zend_throw_error(zend_ce_error, "Cannot create unnamed attribute"); return FAILURE; } } else { @@ -498,7 +498,7 @@ static int sxe_prop_dim_write(zval *object, zval *member, zval *value, zend_bool * and could also be E_PARSE, but we use this only during parsing * and this is during runtime. */ - php_error_docref(NULL, E_ERROR, "Cannot create unnamed attribute"); + zend_throw_error(zend_ce_error, "Cannot create unnamed attribute"); return FAILURE; } if (attribs && !node && sxe->iter.type == SXE_ITER_ELEMENT) { @@ -571,7 +571,7 @@ static int sxe_prop_dim_write(zval *object, zval *member, zval *value, zend_bool if (elements) { if (!member || Z_TYPE_P(member) == IS_LONG) { if (node->type == XML_ATTRIBUTE_NODE) { - php_error_docref(NULL, E_ERROR, "Cannot create duplicate attribute"); + zend_throw_error(zend_ce_error, "Cannot create duplicate attribute"); return FAILURE; } diff --git a/ext/simplexml/tests/012.phpt b/ext/simplexml/tests/012.phpt index 2fc9bec41e..abbb10b8d3 100644 --- a/ext/simplexml/tests/012.phpt +++ b/ext/simplexml/tests/012.phpt @@ -37,4 +37,7 @@ Warning: main(): Cannot write or create unnamed attribute in %s012.php on line % <?xml version="1.0" encoding="ISO-8859-1"?> <foo attr="new value"/> -Fatal error: main(): Cannot create unnamed attribute in %s012.php on line %d +Fatal error: Uncaught Error: Cannot create unnamed attribute in %s012.php:%d +Stack trace: +#0 {main} + thrown in %s012.php on line %d diff --git a/ext/spl/php_spl.c b/ext/spl/php_spl.c index e89caa2059..7cb6661033 100644 --- a/ext/spl/php_spl.c +++ b/ext/spl/php_spl.c @@ -356,7 +356,7 @@ PHP_FUNCTION(spl_autoload) ex->opline->opcode != ZEND_NEW) { zend_throw_exception_ex(spl_ce_LogicException, 0, "Class %s could not be loaded", ZSTR_VAL(class_name)); } else { - php_error_docref(NULL, E_ERROR, "Class %s could not be loaded", ZSTR_VAL(class_name)); + zend_throw_error(zend_ce_error, "Class %s could not be loaded", ZSTR_VAL(class_name)); } } } /* }}} */ diff --git a/ext/spl/spl_array.c b/ext/spl/spl_array.c index 2835876e33..44f201d9b9 100644 --- a/ext/spl/spl_array.c +++ b/ext/spl/spl_array.c @@ -787,7 +787,10 @@ static HashTable *spl_array_get_properties(zval *object) /* {{{ */ HashTable *result; if (intern->nApplyCount > 1) { - php_error_docref(NULL, E_ERROR, "Nesting level too deep - recursive dependency?"); + zend_throw_error(zend_ce_error, "Nesting level too deep - recursive dependency?"); + ALLOC_HASHTABLE(result); + ZEND_INIT_SYMTABLE(result); + return result; } intern->nApplyCount++; diff --git a/ext/spl/spl_directory.c b/ext/spl/spl_directory.c index bf23c644c9..45803b311c 100644 --- a/ext/spl/spl_directory.c +++ b/ext/spl/spl_directory.c @@ -196,7 +196,7 @@ static inline void spl_filesystem_object_get_file_name(spl_filesystem_object *in case SPL_FS_INFO: case SPL_FS_FILE: if (!intern->file_name) { - php_error_docref(NULL, E_ERROR, "Object not initialized"); + zend_throw_error(zend_ce_error, "Object not initialized"); } break; case SPL_FS_DIR: @@ -359,8 +359,8 @@ static zend_object *spl_filesystem_object_clone(zval *zobject) intern->u.dir.index = index; break; case SPL_FS_FILE: - php_error_docref(NULL, E_ERROR, "An object of class %s cannot be cloned", ZSTR_VAL(old_object->ce->name)); - break; + zend_throw_error(zend_ce_error, "An object of class %s cannot be cloned", ZSTR_VAL(old_object->ce->name)); + return NULL; } intern->file_class = source->file_class; diff --git a/ext/spl/spl_iterators.c b/ext/spl/spl_iterators.c index 504065e7fd..fe837307ba 100644 --- a/ext/spl/spl_iterators.c +++ b/ext/spl/spl_iterators.c @@ -1392,7 +1392,7 @@ int spl_dual_it_call_method(char *method, INTERNAL_FUNCTION_PARAMETERS) ZVAL_STRING(&func, method, 0); if (!zend_is_callable(&func, 0, &method)) { - php_error_docref(NULL, E_ERROR, "Method %s::%s() does not exist", intern->inner.ce->name, method); + zend_throw_error(zend_ce_error, "Method %s::%s() does not exist", intern->inner.ce->name, method); return FAILURE; } @@ -1413,7 +1413,7 @@ int spl_dual_it_call_method(char *method, INTERNAL_FUNCTION_PARAMETERS) success = SUCCESS; } else { - php_error_docref(NULL, E_ERROR, "Unable to call %s::%s()", intern->inner.ce->name, method); + zend_throw_error(zend_ce_error, "Unable to call %s::%s()", intern->inner.ce->name, method); success = FAILURE; } @@ -1641,13 +1641,6 @@ SPL_METHOD(dual_it, getInnerIterator) } } /* }}} */ -static inline void spl_dual_it_require(spl_dual_it_object *intern) -{ - if (!intern->inner.iterator) { - php_error_docref(NULL, E_ERROR, "The inner constructor wasn't initialized with an iterator instance"); - } -} - static inline void spl_dual_it_free(spl_dual_it_object *intern) { if (intern->inner.iterator && intern->inner.iterator->funcs->invalidate_current) { @@ -1720,8 +1713,9 @@ static inline void spl_dual_it_next(spl_dual_it_object *intern, int do_free) { if (do_free) { spl_dual_it_free(intern); - } else { - spl_dual_it_require(intern); + } else if (!intern->inner.iterator) { + zend_throw_error(zend_ce_error, "The inner constructor wasn't initialized with an iterator instance"); + return; } intern->inner.iterator->funcs->move_forward(intern->inner.iterator); intern->current.pos++; diff --git a/ext/spl/tests/bug38325.phpt b/ext/spl/tests/bug38325.phpt index ddb2829da4..376a6e8053 100644 --- a/ext/spl/tests/bug38325.phpt +++ b/ext/spl/tests/bug38325.phpt @@ -6,4 +6,8 @@ spl_autoload_register(); new ThisClassDoesNotExistEverFoo(); ?> --EXPECTF-- -Fatal error: spl_autoload(): Class ThisClassDoesNotExistEverFoo could not be loaded in %s on line 3 +Fatal error: Uncaught Error: Class ThisClassDoesNotExistEverFoo could not be loaded in %s:%d +Stack trace: +#0 %s(%d): spl_autoload('ThisClassDoesNo...') +#1 {main} + thrown in %s on line %d diff --git a/ext/tidy/tidy.c b/ext/tidy/tidy.c index edd0bcf85e..41d268218a 100644 --- a/ext/tidy/tidy.c +++ b/ext/tidy/tidy.c @@ -28,6 +28,7 @@ #if HAVE_TIDY #include "php_ini.h" +#include "zend_exceptions.h" #include "ext/standard/info.h" #include "tidy.h" @@ -1816,7 +1817,7 @@ static TIDY_NODE_METHOD(getParent) __constructor for tidyNode. */ static TIDY_NODE_METHOD(__construct) { - php_error_docref(NULL, E_ERROR, "You should not create a tidyNode manually"); + zend_throw_error(zend_ce_error, "You should not create a tidyNode manually"); } /* }}} */ diff --git a/ext/xmlrpc/xmlrpc-epi-php.c b/ext/xmlrpc/xmlrpc-epi-php.c index 62bc39dba4..5ea2894300 100644 --- a/ext/xmlrpc/xmlrpc-epi-php.c +++ b/ext/xmlrpc/xmlrpc-epi-php.c @@ -66,6 +66,7 @@ #endif #include "php.h" +#include "zend_exceptions.h" #include "ext/standard/info.h" #include "ext/standard/php_string.h" #include "ext/date/php_date.h" @@ -548,7 +549,7 @@ static XMLRPC_VALUE PHP_to_XMLRPC_worker (const char* key, zval* in_val, int dep ht = HASH_OF(&val); if (ht && ht->u.v.nApplyCount > 1) { - php_error_docref(NULL, E_ERROR, "XML-RPC doesn't support circular references"); + zend_throw_error(zend_ce_error, "XML-RPC doesn't support circular references"); return NULL; } diff --git a/ext/zip/php_zip.c b/ext/zip/php_zip.c index 85bc51f152..fca40d20f0 100644 --- a/ext/zip/php_zip.c +++ b/ext/zip/php_zip.c @@ -24,6 +24,7 @@ #include "php.h" #include "php_ini.h" +#include "zend_exceptions.h" #include "ext/standard/info.h" #include "ext/standard/file.h" #include "ext/standard/php_string.h" @@ -590,7 +591,7 @@ int php_zip_glob(char *pattern, int pattern_len, zend_long flags, zval *return_v globfree(&globbuf); return globbuf.gl_pathc; #else - php_error_docref(NULL, E_ERROR, "Glob support is not available"); + zend_throw_error(zend_ce_error, "Glob support is not available"); return 0; #endif /* HAVE_GLOB */ } |