@@ -2217,14 +2217,13 @@ static bool do_request(zval *this_ptr, xmlDoc *request, const char *location, co
2217
2217
2218
2218
static void do_soap_call (zend_execute_data * execute_data ,
2219
2219
zval * this_ptr ,
2220
- char * function ,
2221
- size_t function_len ,
2220
+ const zend_string * function ,
2222
2221
uint32_t arg_count ,
2223
2222
zval * real_args ,
2224
2223
zval * return_value ,
2225
- char * location ,
2226
- char * soap_action ,
2227
- char * call_uri ,
2224
+ const zend_string * location ,
2225
+ const zend_string * soap_action ,
2226
+ const zend_string * call_uri ,
2228
2227
HashTable * soap_headers ,
2229
2228
zval * output_headers
2230
2229
) /* {{{ */
@@ -2260,7 +2259,7 @@ static void do_soap_call(zend_execute_data *execute_data,
2260
2259
if (location == NULL ) {
2261
2260
tmp = Z_CLIENT_LOCATION_P (this_ptr );
2262
2261
if (Z_TYPE_P (tmp ) == IS_STRING ) {
2263
- location = Z_STRVAL_P (tmp );
2262
+ location = Z_STR_P (tmp );
2264
2263
}
2265
2264
}
2266
2265
@@ -2308,7 +2307,7 @@ static void do_soap_call(zend_execute_data *execute_data,
2308
2307
2309
2308
zend_try {
2310
2309
if (sdl != NULL ) {
2311
- fn = get_function (sdl , function );
2310
+ fn = get_function (sdl , ZSTR_VAL ( function ) );
2312
2311
if (fn != NULL ) {
2313
2312
sdlBindingPtr binding = fn -> binding ;
2314
2313
bool one_way = 0 ;
@@ -2319,17 +2318,20 @@ static void do_soap_call(zend_execute_data *execute_data,
2319
2318
one_way = 1 ;
2320
2319
}
2321
2320
2321
+ const char * location_c_str ;
2322
2322
if (location == NULL ) {
2323
- location = binding -> location ;
2324
- ZEND_ASSERT (location );
2323
+ location_c_str = binding -> location ;
2324
+ ZEND_ASSERT (location_c_str );
2325
+ } else {
2326
+ location_c_str = ZSTR_VAL (location );
2325
2327
}
2326
2328
if (binding -> bindingType == BINDING_SOAP ) {
2327
2329
sdlSoapBindingFunctionPtr fnb = (sdlSoapBindingFunctionPtr )fn -> bindingAttributes ;
2328
2330
request = serialize_function_call (this_ptr , fn , NULL , fnb -> input .ns , real_args , arg_count , soap_version , soap_headers );
2329
- ret = do_request (this_ptr , request , location , fnb -> soapAction , soap_version , one_way , & response );
2331
+ ret = do_request (this_ptr , request , location_c_str , fnb -> soapAction , soap_version , one_way , & response );
2330
2332
} else {
2331
2333
request = serialize_function_call (this_ptr , fn , NULL , sdl -> target_ns , real_args , arg_count , soap_version , soap_headers );
2332
- ret = do_request (this_ptr , request , location , NULL , soap_version , one_way , & response );
2334
+ ret = do_request (this_ptr , request , location_c_str , NULL , soap_version , one_way , & response );
2333
2335
}
2334
2336
2335
2337
xmlFreeDoc (request );
@@ -2346,7 +2348,7 @@ static void do_soap_call(zend_execute_data *execute_data,
2346
2348
} else {
2347
2349
smart_str error = {0 };
2348
2350
smart_str_appends (& error ,"Function (\"" );
2349
- smart_str_appends (& error ,function );
2351
+ smart_str_append (& error ,function );
2350
2352
smart_str_appends (& error ,"\") is not a valid method for this service" );
2351
2353
smart_str_0 (& error );
2352
2354
add_soap_fault (this_ptr , "Client" , ZSTR_VAL (error .s ), NULL , NULL );
@@ -2360,28 +2362,28 @@ static void do_soap_call(zend_execute_data *execute_data,
2360
2362
add_soap_fault (this_ptr , "Client" , "Error could not find \"location\" property" , NULL , NULL );
2361
2363
} else {
2362
2364
if (call_uri == NULL ) {
2363
- call_uri = Z_STRVAL_P (uri );
2365
+ call_uri = Z_STR_P (uri );
2364
2366
}
2365
- request = serialize_function_call (this_ptr , NULL , function , call_uri , real_args , arg_count , soap_version , soap_headers );
2367
+ request = serialize_function_call (this_ptr , NULL , ZSTR_VAL ( function ), ZSTR_VAL ( call_uri ) , real_args , arg_count , soap_version , soap_headers );
2366
2368
2367
2369
if (soap_action == NULL ) {
2368
- smart_str_appends (& action , call_uri );
2370
+ smart_str_append (& action , call_uri );
2369
2371
smart_str_appendc (& action , '#' );
2370
- smart_str_appends (& action , function );
2372
+ smart_str_append (& action , function );
2371
2373
} else {
2372
- smart_str_appends (& action , soap_action );
2374
+ smart_str_append (& action , soap_action );
2373
2375
}
2374
2376
smart_str_0 (& action );
2375
2377
2376
- ret = do_request (this_ptr , request , location , ZSTR_VAL (action .s ), soap_version , 0 , & response );
2378
+ ret = do_request (this_ptr , request , ZSTR_VAL ( location ) , ZSTR_VAL (action .s ), soap_version , 0 , & response );
2377
2379
2378
2380
smart_str_free (& action );
2379
2381
xmlFreeDoc (request );
2380
2382
request = NULL ;
2381
2383
2382
2384
if (ret && Z_TYPE (response ) == IS_STRING ) {
2383
2385
encode_reset_ns ();
2384
- ret = parse_packet_soap (this_ptr , Z_STRVAL (response ), Z_STRLEN (response ), NULL , function , return_value , output_headers );
2386
+ ret = parse_packet_soap (this_ptr , Z_STRVAL (response ), Z_STRLEN (response ), NULL , NULL , return_value , output_headers );
2385
2387
encode_finish ();
2386
2388
}
2387
2389
@@ -2449,71 +2451,22 @@ static void verify_soap_headers_array(HashTable *ht) /* {{{ */
2449
2451
/* }}} */
2450
2452
2451
2453
/* {{{ Calls a SOAP function */
2452
- void soap_client_call_impl (INTERNAL_FUNCTION_PARAMETERS , bool is_soap_call )
2453
- {
2454
- char * function , * location = NULL , * soap_action = NULL , * uri = NULL ;
2455
- size_t function_len ;
2456
- int i = 0 ;
2457
- HashTable * soap_headers = NULL ;
2458
- zval * options = NULL ;
2459
- zval * headers = NULL ;
2460
- zval * output_headers = NULL ;
2461
- zval * args ;
2462
- zval * real_args = NULL ;
2463
- zval * param ;
2464
- uint32_t arg_count ;
2465
- zval * tmp ;
2466
- bool free_soap_headers = 0 ;
2467
- zval * this_ptr ;
2468
-
2469
- if (is_soap_call ) {
2470
- if (zend_parse_parameters (ZEND_NUM_ARGS (), "sa|a!zz" ,
2471
- & function , & function_len , & args , & options , & headers , & output_headers ) == FAILURE ) {
2472
- RETURN_THROWS ();
2473
- }
2474
- } else {
2475
- if (zend_parse_parameters (ZEND_NUM_ARGS (), "sa" , & function , & function_len , & args ) == FAILURE ) {
2476
- RETURN_THROWS ();
2477
- }
2478
- }
2479
-
2480
- if (options ) {
2481
- HashTable * hto = Z_ARRVAL_P (options );
2482
- if ((tmp = zend_hash_str_find (hto , "location" , sizeof ("location" )- 1 )) != NULL &&
2483
- Z_TYPE_P (tmp ) == IS_STRING ) {
2484
- location = Z_STRVAL_P (tmp );
2485
- }
2486
-
2487
- if ((tmp = zend_hash_str_find (hto , "soapaction" , sizeof ("soapaction" )- 1 )) != NULL &&
2488
- Z_TYPE_P (tmp ) == IS_STRING ) {
2489
- soap_action = Z_STRVAL_P (tmp );
2490
- }
2491
-
2492
- if ((tmp = zend_hash_str_find (hto , "uri" , sizeof ("uri" )- 1 )) != NULL &&
2493
- Z_TYPE_P (tmp ) == IS_STRING ) {
2494
- uri = Z_STRVAL_P (tmp );
2495
- }
2496
- }
2497
-
2498
- if (headers == NULL || Z_TYPE_P (headers ) == IS_NULL ) {
2499
- } else if (Z_TYPE_P (headers ) == IS_ARRAY ) {
2500
- soap_headers = Z_ARRVAL_P (headers );
2501
- verify_soap_headers_array (soap_headers );
2502
- free_soap_headers = 0 ;
2503
- } else if (Z_TYPE_P (headers ) == IS_OBJECT &&
2504
- instanceof_function (Z_OBJCE_P (headers ), soap_header_class_entry )) {
2505
- soap_headers = zend_new_array (0 );
2506
- zend_hash_next_index_insert (soap_headers , headers );
2507
- Z_ADDREF_P (headers );
2508
- free_soap_headers = 1 ;
2509
- } else {
2510
- zend_argument_type_error (4 , "must be of type SoapHeader|array|null, %s given" , zend_zval_value_name (headers ));
2511
- RETURN_THROWS ();
2512
- }
2513
-
2454
+ static void soap_client_call_common (
2455
+ zval * this_ptr ,
2456
+ const zend_string * function ,
2457
+ HashTable * args ,
2458
+ const zend_string * location ,
2459
+ const zend_string * soap_action ,
2460
+ const zend_string * uri ,
2461
+ HashTable * soap_headers ,
2462
+ bool free_soap_headers ,
2463
+ zval * output_headers ,
2464
+ zend_execute_data * execute_data ,
2465
+ zval * return_value
2466
+ ) {
2514
2467
/* Add default headers */
2515
2468
this_ptr = ZEND_THIS ;
2516
- tmp = Z_CLIENT_DEFAULT_HEADERS_P (this_ptr );
2469
+ zval * tmp = Z_CLIENT_DEFAULT_HEADERS_P (this_ptr );
2517
2470
if (Z_TYPE_P (tmp ) == IS_ARRAY ) {
2518
2471
HashTable * default_headers = Z_ARRVAL_P (tmp );
2519
2472
if (soap_headers ) {
@@ -2533,27 +2486,23 @@ void soap_client_call_impl(INTERNAL_FUNCTION_PARAMETERS, bool is_soap_call)
2533
2486
}
2534
2487
}
2535
2488
2536
- arg_count = zend_hash_num_elements (Z_ARRVAL_P ( args ) );
2537
-
2489
+ uint32_t arg_count = zend_hash_num_elements (args );
2490
+ zval * real_args = NULL ;
2538
2491
if (arg_count > 0 ) {
2492
+ zval * param ;
2493
+ int i = 0 ;
2494
+
2539
2495
real_args = safe_emalloc (sizeof (zval ), arg_count , 0 );
2540
- ZEND_HASH_FOREACH_VAL (Z_ARRVAL_P ( args ) , param ) {
2496
+ ZEND_HASH_FOREACH_VAL (args , param ) {
2541
2497
/*zval_add_ref(param);*/
2542
2498
ZVAL_DEREF (param );
2543
2499
ZVAL_COPY_VALUE (& real_args [i ], param );
2544
2500
i ++ ;
2545
2501
} ZEND_HASH_FOREACH_END ();
2546
2502
}
2547
- if (output_headers ) {
2548
- output_headers = zend_try_array_init (output_headers );
2549
- if (!output_headers ) {
2550
- goto cleanup ;
2551
- }
2552
- }
2553
2503
2554
- do_soap_call (execute_data , this_ptr , function , function_len , arg_count , real_args , return_value , location , soap_action , uri , soap_headers , output_headers );
2504
+ do_soap_call (execute_data , this_ptr , function , arg_count , real_args , return_value , location , soap_action , uri , soap_headers , output_headers );
2555
2505
2556
- cleanup :
2557
2506
if (arg_count > 0 ) {
2558
2507
efree (real_args );
2559
2508
}
@@ -2566,12 +2515,95 @@ void soap_client_call_impl(INTERNAL_FUNCTION_PARAMETERS, bool is_soap_call)
2566
2515
2567
2516
PHP_METHOD (SoapClient , __call )
2568
2517
{
2569
- soap_client_call_impl (INTERNAL_FUNCTION_PARAM_PASSTHRU , 0 );
2518
+ zend_string * function = NULL ;
2519
+ HashTable * args = NULL ;
2520
+
2521
+ if (zend_parse_parameters (ZEND_NUM_ARGS (), "Sh" , & function , & args ) == FAILURE ) {
2522
+ RETURN_THROWS ();
2523
+ }
2524
+ soap_client_call_common (
2525
+ ZEND_THIS ,
2526
+ function ,
2527
+ args ,
2528
+ /* location */ NULL ,
2529
+ /* soap_action */ NULL ,
2530
+ /* uri */ NULL ,
2531
+ /* soap_headers */ NULL ,
2532
+ /* free_soap_headers */ false,
2533
+ /* output_headers */ NULL ,
2534
+ execute_data ,
2535
+ return_value
2536
+ );
2570
2537
}
2571
2538
2572
2539
PHP_METHOD (SoapClient , __soapCall )
2573
2540
{
2574
- soap_client_call_impl (INTERNAL_FUNCTION_PARAM_PASSTHRU , 1 );
2541
+ zend_string * function = NULL ;
2542
+ HashTable * args = NULL ;
2543
+ HashTable * options = NULL ;
2544
+ zval * headers = NULL ;
2545
+ zval * output_headers = NULL ;
2546
+
2547
+ if (zend_parse_parameters (ZEND_NUM_ARGS (), "Sh|h!zz" , & function , & args , & options , & headers , & output_headers ) == FAILURE ) {
2548
+ RETURN_THROWS ();
2549
+ }
2550
+
2551
+
2552
+ zend_string * location = NULL ;
2553
+ zend_string * soap_action = NULL ;
2554
+ zend_string * uri = NULL ;
2555
+ if (options ) {
2556
+ zval * tmp ;
2557
+ if ((tmp = zend_hash_str_find (options , "location" , sizeof ("location" )- 1 )) != NULL && Z_TYPE_P (tmp ) == IS_STRING ) {
2558
+ location = Z_STR_P (tmp );
2559
+ }
2560
+
2561
+ if ((tmp = zend_hash_str_find (options , "soapaction" , sizeof ("soapaction" )- 1 )) != NULL && Z_TYPE_P (tmp ) == IS_STRING ) {
2562
+ soap_action = Z_STR_P (tmp );
2563
+ }
2564
+
2565
+ if ((tmp = zend_hash_str_find (options , "uri" , sizeof ("uri" )- 1 )) != NULL && Z_TYPE_P (tmp ) == IS_STRING ) {
2566
+ uri = Z_STR_P (tmp );
2567
+ }
2568
+ }
2569
+
2570
+ if (output_headers ) {
2571
+ output_headers = zend_try_array_init (output_headers );
2572
+ if (output_headers == NULL ) {
2573
+ RETURN_THROWS ();
2574
+ }
2575
+ }
2576
+
2577
+ HashTable * soap_headers = NULL ;
2578
+ bool free_soap_headers = false;
2579
+ if (headers == NULL || Z_TYPE_P (headers ) == IS_NULL ) {
2580
+ } else if (Z_TYPE_P (headers ) == IS_ARRAY ) {
2581
+ soap_headers = Z_ARRVAL_P (headers );
2582
+ verify_soap_headers_array (soap_headers );
2583
+ free_soap_headers = false;
2584
+ } else if (Z_TYPE_P (headers ) == IS_OBJECT && instanceof_function (Z_OBJCE_P (headers ), soap_header_class_entry )) {
2585
+ soap_headers = zend_new_array (0 );
2586
+ zend_hash_next_index_insert (soap_headers , headers );
2587
+ Z_ADDREF_P (headers );
2588
+ free_soap_headers = true;
2589
+ } else {
2590
+ zend_argument_type_error (4 , "must be of type SoapHeader|array|null, %s given" , zend_zval_value_name (headers ));
2591
+ RETURN_THROWS ();
2592
+ }
2593
+
2594
+ soap_client_call_common (
2595
+ ZEND_THIS ,
2596
+ function ,
2597
+ args ,
2598
+ location ,
2599
+ soap_action ,
2600
+ uri ,
2601
+ soap_headers ,
2602
+ free_soap_headers ,
2603
+ output_headers ,
2604
+ execute_data ,
2605
+ return_value
2606
+ );
2575
2607
}
2576
2608
2577
2609
/* {{{ Returns list of SOAP functions */
0 commit comments