@@ -271,7 +271,6 @@ void sdl_set_uri_credentials(sdlCtx *ctx, char *uri)
271271{
272272 char * s ;
273273 size_t l1 , l2 ;
274- zval context ;
275274 zval * header = NULL ;
276275
277276 /* check if we load xsd from the same server */
@@ -320,18 +319,13 @@ void sdl_set_uri_credentials(sdlCtx *ctx, char *uri)
320319 if (l1 == l2 && memcmp (ctx -> sdl -> source , uri , l1 ) == 0 ) {
321320 return ;
322321 }
323- /* another server. clear authentication credentals */
324- php_libxml_switch_context (NULL , & context );
325- php_libxml_switch_context (& context , NULL );
326- if (Z_TYPE (context ) == IS_UNDEF ) {
327- return ;
328- }
329- zval * context_ptr = & context ;
330- ctx -> context = php_stream_context_from_zval (context_ptr , 1 );
331-
332- if (!ctx -> context ) {
322+ /* another server. clear authentication credentials */
323+ php_stream_context * context = php_libxml_switch_context (NULL );
324+ php_libxml_switch_context (context );
325+ if (context == NULL ) {
333326 return ;
334327 }
328+ ctx -> context = context ;
335329
336330 header = php_stream_context_get_option (ctx -> context , "http" , "header" );
337331 if (header == NULL ) {
@@ -3316,15 +3310,13 @@ sdlPtr get_sdl(zval *this_ptr, char *uri, zend_long cache_wsdl)
33163310 char * old_error_code = SOAP_GLOBAL (error_code );
33173311 size_t uri_len = 0 ;
33183312 php_stream_context * context = NULL ;
3319- zval * tmp , orig_context , new_context ;
3313+ zval * tmp ;
33203314 smart_str headers = {0 };
33213315 char * key = NULL ;
33223316 time_t t = time (0 );
33233317 bool has_proxy_authorization = false;
33243318 bool has_authorization = false;
33253319
3326- ZVAL_UNDEF (& orig_context );
3327- ZVAL_UNDEF (& new_context );
33283320 if (strchr (uri ,':' ) != NULL || IS_ABSOLUTE_PATH (uri , uri_len )) {
33293321 uri_len = strlen (uri );
33303322 } else if (VCWD_REALPATH (uri , fn ) == NULL ) {
@@ -3397,9 +3389,6 @@ sdlPtr get_sdl(zval *this_ptr, char *uri, zend_long cache_wsdl)
33973389 tmp = Z_CLIENT_STREAM_CONTEXT_P (this_ptr );
33983390 if (Z_TYPE_P (tmp ) == IS_RESOURCE ) {
33993391 context = php_stream_context_from_zval (tmp , 0 );
3400- /* Share a reference with new_context down below.
3401- * For new contexts, the reference is only in new_context so that doesn't need extra refcounting. */
3402- GC_ADDREF (context -> res );
34033392 }
34043393
34053394 tmp = Z_CLIENT_USER_AGENT_P (this_ptr );
@@ -3465,9 +3454,9 @@ sdlPtr get_sdl(zval *this_ptr, char *uri, zend_long cache_wsdl)
34653454 zval_ptr_dtor (& str_headers );
34663455 }
34673456
3457+ php_stream_context * orig_context = NULL ;
34683458 if (context ) {
3469- ZVAL_RES (& new_context , context -> res );
3470- php_libxml_switch_context (& new_context , & orig_context );
3459+ orig_context = php_libxml_switch_context (context );
34713460 }
34723461
34733462 SOAP_GLOBAL (error_code ) = "WSDL" ;
@@ -3480,8 +3469,7 @@ sdlPtr get_sdl(zval *this_ptr, char *uri, zend_long cache_wsdl)
34803469 SOAP_GLOBAL (error_code ) = old_error_code ;
34813470
34823471 if (context ) {
3483- php_libxml_switch_context (& orig_context , NULL );
3484- zval_ptr_dtor (& new_context );
3472+ php_libxml_switch_context (orig_context );
34853473 }
34863474
34873475 if ((cache_wsdl & WSDL_CACHE_DISK ) && key ) {
0 commit comments