From 6bfb119e18e5241b6719a4ad69223d91c465a58e Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Wed, 6 Mar 2019 11:46:34 +0100 Subject: [PATCH] Remove some unnecessary error handler setting A few non-standard exceptions thrown on zpp failures will change to TypeError due to this. --- ext/soap/soap.c | 12 +++++----- ext/spl/spl_directory.c | 51 ++++++++++++++++------------------------- 2 files changed, 26 insertions(+), 37 deletions(-) diff --git a/ext/soap/soap.c b/ext/soap/soap.c index 6f495b6bd17..1b27ec1e906 100644 --- a/ext/soap/soap.c +++ b/ext/soap/soap.c @@ -1111,12 +1111,12 @@ PHP_METHOD(SoapServer, __construct) zend_long cache_wsdl; HashTable *typemap_ht = NULL; - SOAP_SERVER_BEGIN_CODE(); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "z|a", &wsdl, &options) == FAILURE) { - php_error_docref(NULL, E_ERROR, "Invalid parameters"); + return; } + SOAP_SERVER_BEGIN_CODE(); + if (Z_TYPE_P(wsdl) != IS_STRING && Z_TYPE_P(wsdl) != IS_NULL) { php_error_docref(NULL, E_ERROR, "Invalid parameters"); } @@ -2267,12 +2267,12 @@ PHP_METHOD(SoapClient, __construct) HashTable *typemap_ht = NULL; zval *this_ptr = ZEND_THIS; - SOAP_CLIENT_BEGIN_CODE(); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "z|a", &wsdl, &options) == FAILURE) { - php_error_docref(NULL, E_ERROR, "Invalid parameters"); + return; } + SOAP_CLIENT_BEGIN_CODE(); + if (Z_TYPE_P(wsdl) != IS_STRING && Z_TYPE_P(wsdl) != IS_NULL) { php_error_docref(NULL, E_ERROR, "$wsdl must be string or null"); } diff --git a/ext/spl/spl_directory.c b/ext/spl/spl_directory.c index e690b946151..416cbd014e2 100644 --- a/ext/spl/spl_directory.c +++ b/ext/spl/spl_directory.c @@ -1344,15 +1344,12 @@ SPL_METHOD(SplFileInfo, setFileClass) { spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(ZEND_THIS); zend_class_entry *ce = spl_ce_SplFileObject; - zend_error_handling error_handling; - zend_replace_error_handling(EH_THROW, spl_ce_UnexpectedValueException, &error_handling); - - if (zend_parse_parameters(ZEND_NUM_ARGS(), "|C", &ce) == SUCCESS) { - intern->file_class = ce; + if (zend_parse_parameters(ZEND_NUM_ARGS(), "|C", &ce) == FAILURE) { + return; } - zend_restore_error_handling(&error_handling); + intern->file_class = ce; } /* }}} */ @@ -1362,15 +1359,12 @@ SPL_METHOD(SplFileInfo, setInfoClass) { spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(ZEND_THIS); zend_class_entry *ce = spl_ce_SplFileInfo; - zend_error_handling error_handling; - zend_replace_error_handling(EH_THROW, spl_ce_UnexpectedValueException, &error_handling ); - - if (zend_parse_parameters(ZEND_NUM_ARGS(), "|C", &ce) == SUCCESS) { - intern->info_class = ce; + if (zend_parse_parameters(ZEND_NUM_ARGS(), "|C", &ce) == FAILURE) { + return; } - zend_restore_error_handling(&error_handling); + intern->info_class = ce; } /* }}} */ @@ -1380,15 +1374,12 @@ SPL_METHOD(SplFileInfo, getFileInfo) { spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(ZEND_THIS); zend_class_entry *ce = intern->info_class; - zend_error_handling error_handling; - zend_replace_error_handling(EH_THROW, spl_ce_UnexpectedValueException, &error_handling); - - if (zend_parse_parameters(ZEND_NUM_ARGS(), "|C", &ce) == SUCCESS) { - spl_filesystem_object_create_type(ZEND_NUM_ARGS(), intern, SPL_FS_INFO, ce, return_value); + if (zend_parse_parameters(ZEND_NUM_ARGS(), "|C", &ce) == FAILURE) { + return; } - zend_restore_error_handling(&error_handling); + spl_filesystem_object_create_type(ZEND_NUM_ARGS(), intern, SPL_FS_INFO, ce, return_value); } /* }}} */ @@ -1398,22 +1389,20 @@ SPL_METHOD(SplFileInfo, getPathInfo) { spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(ZEND_THIS); zend_class_entry *ce = intern->info_class; - zend_error_handling error_handling; + size_t path_len; + char *path; - zend_replace_error_handling(EH_THROW, spl_ce_UnexpectedValueException, &error_handling); - - if (zend_parse_parameters(ZEND_NUM_ARGS(), "|C", &ce) == SUCCESS) { - size_t path_len; - char *path = spl_filesystem_object_get_pathname(intern, &path_len); - if (path) { - char *dpath = estrndup(path, path_len); - path_len = php_dirname(dpath, path_len); - spl_filesystem_object_create_info(intern, dpath, path_len, 1, ce, return_value); - efree(dpath); - } + if (zend_parse_parameters(ZEND_NUM_ARGS(), "|C", &ce) == FAILURE) { + return; } - zend_restore_error_handling(&error_handling); + path = spl_filesystem_object_get_pathname(intern, &path_len); + if (path) { + char *dpath = estrndup(path, path_len); + path_len = php_dirname(dpath, path_len); + spl_filesystem_object_create_info(intern, dpath, path_len, 1, ce, return_value); + efree(dpath); + } } /* }}} */