Skip to content

Commit 2fced40

Browse files
committed
MFH: - Added E_ERROR in constructors
1 parent 77ba4c0 commit 2fced40

File tree

1 file changed

+25
-34
lines changed

1 file changed

+25
-34
lines changed

ext/soap/soap.c

Lines changed: 25 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1222,10 +1222,14 @@ PHP_METHOD(SoapServer, SoapServer)
12221222

12231223
SOAP_SERVER_BEGIN_CODE();
12241224

1225-
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z!|a", &wsdl, &options) == FAILURE) {
1226-
return;
1225+
if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC, "z|a", &wsdl, &options) == FAILURE) {
1226+
php_error_docref(NULL TSRMLS_CC, E_ERROR, "Invalid parameters");
12271227
}
12281228

1229+
if (Z_TYPE_P(wsdl) != IS_STRING && Z_TYPE_P(wsdl) != IS_NULL) {
1230+
php_error_docref(NULL TSRMLS_CC, E_ERROR, "Invalid parameters");
1231+
}
1232+
12291233
service = emalloc(sizeof(soapService));
12301234
memset(service, 0, sizeof(soapService));
12311235
service->send_errors = 1;
@@ -1246,9 +1250,8 @@ PHP_METHOD(SoapServer, SoapServer)
12461250
if (zend_hash_find(ht, "uri", sizeof("uri"), (void**)&tmp) == SUCCESS &&
12471251
Z_TYPE_PP(tmp) == IS_STRING) {
12481252
service->uri = estrndup(Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp));
1249-
} else if (wsdl == NULL) {
1250-
php_error_docref(NULL TSRMLS_CC, E_WARNING, "'uri' option is required in nonWSDL mode");
1251-
return;
1253+
} else if (Z_TYPE_P(wsdl) == IS_NULL) {
1254+
php_error_docref(NULL TSRMLS_CC, E_ERROR, "'uri' option is required in nonWSDL mode");
12521255
}
12531256

12541257
if (zend_hash_find(ht, "actor", sizeof("actor"), (void**)&tmp) == SUCCESS &&
@@ -1262,8 +1265,7 @@ PHP_METHOD(SoapServer, SoapServer)
12621265

12631266
encoding = xmlFindCharEncodingHandler(Z_STRVAL_PP(tmp));
12641267
if (encoding == NULL) {
1265-
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid 'encoding' option - '%s'", Z_STRVAL_PP(tmp));
1266-
return;
1268+
php_error_docref(NULL TSRMLS_CC, E_ERROR, "Invalid 'encoding' option - '%s'", Z_STRVAL_PP(tmp));
12671269
} else {
12681270
service->encoding = encoding;
12691271
}
@@ -1299,9 +1301,8 @@ PHP_METHOD(SoapServer, SoapServer)
12991301
service->send_errors = Z_LVAL_PP(tmp);
13001302
}
13011303

1302-
} else if (wsdl == NULL) {
1303-
php_error_docref(NULL TSRMLS_CC, E_WARNING, "'uri' option is required in nonWSDL mode");
1304-
return;
1304+
} else if (Z_TYPE_P(wsdl) == IS_NULL) {
1305+
php_error_docref(NULL TSRMLS_CC, E_ERROR, "'uri' option is required in nonWSDL mode");
13051306
}
13061307

13071308
service->version = version;
@@ -1310,7 +1311,7 @@ PHP_METHOD(SoapServer, SoapServer)
13101311
service->soap_functions.ft = emalloc(sizeof(HashTable));
13111312
zend_hash_init(service->soap_functions.ft, 0, NULL, ZVAL_PTR_DTOR, 0);
13121313

1313-
if (wsdl) {
1314+
if (Z_TYPE_P(wsdl) != IS_NULL) {
13141315
service->sdl = get_sdl(this_ptr, Z_STRVAL_P(wsdl), cache_wsdl TSRMLS_CC);
13151316
if (service->uri == NULL) {
13161317
if (service->sdl->target_ns) {
@@ -2501,8 +2502,7 @@ PHP_FUNCTION(is_soap_fault)
25012502
PHP_METHOD(SoapClient, SoapClient)
25022503
{
25032504

2504-
zval *wsdl;
2505-
zval *options = NULL;
2505+
zval *wsdl, *options = NULL;
25062506
int soap_version = SOAP_1_1;
25072507
php_stream_context *context = NULL;
25082508
long cache_wsdl;
@@ -2511,16 +2511,12 @@ PHP_METHOD(SoapClient, SoapClient)
25112511

25122512
SOAP_CLIENT_BEGIN_CODE();
25132513

2514-
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z|a", &wsdl, &options) == FAILURE) {
2515-
return;
2514+
if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC, "z|a", &wsdl, &options) == FAILURE) {
2515+
php_error_docref(NULL TSRMLS_CC, E_ERROR, "Invalid parameters");
25162516
}
25172517

2518-
if (Z_TYPE_P(wsdl) == IS_STRING) {
2519-
} else if (Z_TYPE_P(wsdl) != IS_NULL ) {
2520-
php_error_docref(NULL TSRMLS_CC, E_WARNING, "$wsdl must be string or null");
2521-
return;
2522-
} else {
2523-
wsdl = NULL;
2518+
if (Z_TYPE_P(wsdl) != IS_STRING && Z_TYPE_P(wsdl) != IS_NULL) {
2519+
php_error_docref(NULL TSRMLS_CC, E_ERROR, "$wsdl must be string or null");
25242520
}
25252521

25262522
cache_wsdl = SOAP_GLOBAL(cache);
@@ -2529,14 +2525,13 @@ PHP_METHOD(SoapClient, SoapClient)
25292525
HashTable *ht = Z_ARRVAL_P(options);
25302526
zval **tmp;
25312527

2532-
if (wsdl == NULL) {
2528+
if (Z_TYPE_P(wsdl) == IS_NULL) {
25332529
/* Fetching non-WSDL mode options */
25342530
if (zend_hash_find(ht, "uri", sizeof("uri"), (void**)&tmp) == SUCCESS &&
25352531
Z_TYPE_PP(tmp) == IS_STRING) {
25362532
add_property_stringl(this_ptr, "uri", Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp), 1);
25372533
} else {
2538-
php_error_docref(NULL TSRMLS_CC, E_WARNING, "'uri' option is required in nonWSDL mode");
2539-
return;
2534+
php_error_docref(NULL TSRMLS_CC, E_ERROR, "'uri' option is required in nonWSDL mode");
25402535
}
25412536

25422537
if (zend_hash_find(ht, "style", sizeof("style"), (void**)&tmp) == SUCCESS &&
@@ -2560,9 +2555,8 @@ PHP_METHOD(SoapClient, SoapClient)
25602555
if (zend_hash_find(ht, "location", sizeof("location"), (void**)&tmp) == SUCCESS &&
25612556
Z_TYPE_PP(tmp) == IS_STRING) {
25622557
add_property_stringl(this_ptr, "location", Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp), 1);
2563-
} else if (wsdl == NULL) {
2564-
php_error_docref(NULL TSRMLS_CC, E_WARNING, "'location' option is required in nonWSDL mode");
2565-
return;
2558+
} else if (Z_TYPE_P(wsdl) == IS_NULL) {
2559+
php_error_docref(NULL TSRMLS_CC, E_ERROR, "'location' option is required in nonWSDL mode");
25662560
}
25672561

25682562
if (zend_hash_find(ht, "soap_version", sizeof("soap_version"), (void**)&tmp) == SUCCESS) {
@@ -2638,8 +2632,7 @@ PHP_METHOD(SoapClient, SoapClient)
26382632

26392633
encoding = xmlFindCharEncodingHandler(Z_STRVAL_PP(tmp));
26402634
if (encoding == NULL) {
2641-
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid 'encoding' option - '%s'", Z_STRVAL_PP(tmp));
2642-
return;
2635+
php_error_docref(NULL TSRMLS_CC, E_ERROR, "Invalid 'encoding' option - '%s'", Z_STRVAL_PP(tmp));
26432636
} else {
26442637
xmlCharEncCloseFunc(encoding);
26452638
add_property_stringl(this_ptr, "_encoding", Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp), 1);
@@ -2690,15 +2683,13 @@ PHP_METHOD(SoapClient, SoapClient)
26902683
Z_TYPE_PP(tmp) == IS_STRING) {
26912684
add_property_stringl(this_ptr, "_user_agent", Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp), 1);
26922685
}
2693-
2694-
} else if (wsdl == NULL) {
2695-
php_error_docref(NULL TSRMLS_CC, E_WARNING, "'location' and 'uri' options are required in nonWSDL mode");
2696-
return;
2686+
} else if (Z_TYPE_P(wsdl) == IS_NULL) {
2687+
php_error_docref(NULL TSRMLS_CC, E_ERROR, "'location' and 'uri' options are required in nonWSDL mode");
26972688
}
26982689

26992690
add_property_long(this_ptr, "_soap_version", soap_version);
27002691

2701-
if (wsdl) {
2692+
if (Z_TYPE_P(wsdl) != IS_NULL) {
27022693
int old_soap_version, ret;
27032694

27042695
old_soap_version = SOAP_GLOBAL(soap_version);

0 commit comments

Comments
 (0)