Skip to content

Commit 615b980

Browse files
authored
Get rid of redundant SOAP globals (#18702)
The copy doesn't make sense, remove it.
1 parent f0fa9c7 commit 615b980

File tree

4 files changed

+24
-26
lines changed

4 files changed

+24
-26
lines changed

ext/soap/php_encoding.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3456,7 +3456,7 @@ xmlNsPtr encode_add_ns(xmlNodePtr node, const char* ns)
34563456
if (xmlns == NULL) {
34573457
xmlChar* prefix;
34583458

3459-
if ((prefix = zend_hash_str_find_ptr(&SOAP_GLOBAL(defEncNs), (char*)ns, strlen(ns))) != NULL) {
3459+
if ((prefix = zend_hash_str_find_ptr(&php_soap_defEncNs, (char*)ns, strlen(ns))) != NULL) {
34603460
xmlns = xmlNewNs(node->doc->children, BAD_CAST(ns), prefix);
34613461
} else {
34623462
smart_str prefix = {0};
@@ -3531,7 +3531,7 @@ encodePtr get_conversion(int encode)
35313531
{
35323532
encodePtr enc;
35333533

3534-
if ((enc = zend_hash_index_find_ptr(&SOAP_GLOBAL(defEncIndex), encode)) == NULL) {
3534+
if ((enc = zend_hash_index_find_ptr(&php_soap_defEncIndex, encode)) == NULL) {
35353535
soap_error0(E_ERROR, "Encoding: Cannot find encoding");
35363536
return NULL;
35373537
} else {

ext/soap/php_sdl.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ encodePtr get_encoder_ex(sdlPtr sdl, const char *nscat, size_t len)
177177
{
178178
encodePtr enc;
179179

180-
if ((enc = zend_hash_str_find_ptr(&SOAP_GLOBAL(defEnc), nscat, len)) != NULL) {
180+
if ((enc = zend_hash_str_find_ptr(&php_soap_defEnc, nscat, len)) != NULL) {
181181
return enc;
182182
} else if (sdl && sdl->encoders && (enc = zend_hash_str_find_ptr(sdl->encoders, nscat, len)) != NULL) {
183183
return enc;

ext/soap/php_soap.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,9 +151,6 @@ struct _soapService {
151151

152152

153153
ZEND_BEGIN_MODULE_GLOBALS(soap)
154-
HashTable defEncNs; /* mapping of default namespaces to prefixes */
155-
HashTable defEnc;
156-
HashTable defEncIndex;
157154
HashTable *typemap;
158155
int cur_uniq_ns;
159156
int soap_version;
@@ -195,6 +192,8 @@ extern zend_class_entry* soap_var_class_entry;
195192
extern zend_class_entry* soap_url_class_entry;
196193
extern zend_class_entry* soap_sdl_class_entry;
197194

195+
extern HashTable php_soap_defEncNs, php_soap_defEnc, php_soap_defEncIndex;
196+
198197
void add_soap_fault(zval *obj, char *fault_code, char *fault_string, char *fault_actor, zval *fault_detail);
199198

200199
#define soap_error0(severity, format) \

ext/soap/soap.c

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -390,16 +390,18 @@ STD_PHP_INI_ENTRY("soap.wsdl_cache_limit", "5", PHP_INI_ALL, OnUpdateLong,
390390
cache_limit, zend_soap_globals, soap_globals)
391391
PHP_INI_END()
392392

393-
static HashTable defEnc, defEncIndex, defEncNs;
393+
/* Real globals shared for the entire processes across threads, only written during init. */
394+
HashTable php_soap_defEncNs; /* mapping of default namespaces to prefixes */
395+
HashTable php_soap_defEnc, php_soap_defEncIndex;
394396

395397
static void php_soap_prepare_globals(void)
396398
{
397399
int i;
398400
encode* enc;
399401

400-
zend_hash_init(&defEnc, 0, NULL, NULL, 1);
401-
zend_hash_init(&defEncIndex, 0, NULL, NULL, 1);
402-
zend_hash_init(&defEncNs, 0, NULL, NULL, 1);
402+
zend_hash_init(&php_soap_defEnc, 0, NULL, NULL, 1);
403+
zend_hash_init(&php_soap_defEncIndex, 0, NULL, NULL, 1);
404+
zend_hash_init(&php_soap_defEncNs, 0, NULL, NULL, 1);
403405

404406
i = 0;
405407
do {
@@ -412,35 +414,32 @@ static void php_soap_prepare_globals(void)
412414
size_t clark_notation_len = spprintf(&clark_notation, 0, "{%s}%s", enc->details.ns, enc->details.type_str);
413415
enc->details.clark_notation = zend_string_init(clark_notation, clark_notation_len, true);
414416
size_t ns_type_len = spprintf(&ns_type, 0, "%s:%s", enc->details.ns, enc->details.type_str);
415-
zend_hash_str_add_ptr(&defEnc, ns_type, ns_type_len, (void*)enc);
417+
zend_hash_str_add_ptr(&php_soap_defEnc, ns_type, ns_type_len, (void*)enc);
416418
efree(clark_notation);
417419
efree(ns_type);
418420
} else {
419-
zend_hash_str_add_ptr(&defEnc, defaultEncoding[i].details.type_str, strlen(defaultEncoding[i].details.type_str), (void*)enc);
421+
zend_hash_str_add_ptr(&php_soap_defEnc, defaultEncoding[i].details.type_str, strlen(defaultEncoding[i].details.type_str), (void*)enc);
420422
}
421423
}
422424
/* Index everything by number */
423-
zend_hash_index_add_ptr(&defEncIndex, defaultEncoding[i].details.type, (void*)enc);
425+
zend_hash_index_add_ptr(&php_soap_defEncIndex, defaultEncoding[i].details.type, (void*)enc);
424426
i++;
425427
} while (defaultEncoding[i].details.type != END_KNOWN_TYPES);
426428

427429
/* hash by namespace */
428-
zend_hash_str_add_ptr(&defEncNs, XSD_1999_NAMESPACE, sizeof(XSD_1999_NAMESPACE)-1, XSD_NS_PREFIX);
429-
zend_hash_str_add_ptr(&defEncNs, XSD_NAMESPACE, sizeof(XSD_NAMESPACE)-1, XSD_NS_PREFIX);
430-
zend_hash_str_add_ptr(&defEncNs, XSI_NAMESPACE, sizeof(XSI_NAMESPACE)-1, XSI_NS_PREFIX);
431-
zend_hash_str_add_ptr(&defEncNs, XML_NAMESPACE, sizeof(XML_NAMESPACE)-1, XML_NS_PREFIX);
432-
zend_hash_str_add_ptr(&defEncNs, SOAP_1_1_ENC_NAMESPACE, sizeof(SOAP_1_1_ENC_NAMESPACE)-1, SOAP_1_1_ENC_NS_PREFIX);
433-
zend_hash_str_add_ptr(&defEncNs, SOAP_1_2_ENC_NAMESPACE, sizeof(SOAP_1_2_ENC_NAMESPACE)-1, SOAP_1_2_ENC_NS_PREFIX);
430+
zend_hash_str_add_ptr(&php_soap_defEncNs, XSD_1999_NAMESPACE, sizeof(XSD_1999_NAMESPACE)-1, XSD_NS_PREFIX);
431+
zend_hash_str_add_ptr(&php_soap_defEncNs, XSD_NAMESPACE, sizeof(XSD_NAMESPACE)-1, XSD_NS_PREFIX);
432+
zend_hash_str_add_ptr(&php_soap_defEncNs, XSI_NAMESPACE, sizeof(XSI_NAMESPACE)-1, XSI_NS_PREFIX);
433+
zend_hash_str_add_ptr(&php_soap_defEncNs, XML_NAMESPACE, sizeof(XML_NAMESPACE)-1, XML_NS_PREFIX);
434+
zend_hash_str_add_ptr(&php_soap_defEncNs, SOAP_1_1_ENC_NAMESPACE, sizeof(SOAP_1_1_ENC_NAMESPACE)-1, SOAP_1_1_ENC_NS_PREFIX);
435+
zend_hash_str_add_ptr(&php_soap_defEncNs, SOAP_1_2_ENC_NAMESPACE, sizeof(SOAP_1_2_ENC_NAMESPACE)-1, SOAP_1_2_ENC_NS_PREFIX);
434436
}
435437

436438
static void php_soap_init_globals(zend_soap_globals *soap_globals)
437439
{
438440
#if defined(COMPILE_DL_SOAP) && defined(ZTS)
439441
ZEND_TSRMLS_CACHE_UPDATE();
440442
#endif
441-
soap_globals->defEnc = defEnc;
442-
soap_globals->defEncIndex = defEncIndex;
443-
soap_globals->defEncNs = defEncNs;
444443
soap_globals->typemap = NULL;
445444
soap_globals->use_soap_error_handler = 0;
446445
soap_globals->error_code = NULL;
@@ -461,9 +460,9 @@ PHP_MSHUTDOWN_FUNCTION(soap)
461460
i++;
462461
} while (defaultEncoding[i].details.type != END_KNOWN_TYPES);
463462
zend_error_cb = old_error_handler;
464-
zend_hash_destroy(&SOAP_GLOBAL(defEnc));
465-
zend_hash_destroy(&SOAP_GLOBAL(defEncIndex));
466-
zend_hash_destroy(&SOAP_GLOBAL(defEncNs));
463+
zend_hash_destroy(&php_soap_defEnc);
464+
zend_hash_destroy(&php_soap_defEncIndex);
465+
zend_hash_destroy(&php_soap_defEncNs);
467466
if (SOAP_GLOBAL(mem_cache)) {
468467
zend_hash_destroy(SOAP_GLOBAL(mem_cache));
469468
free(SOAP_GLOBAL(mem_cache));
@@ -765,7 +764,7 @@ PHP_METHOD(SoapVar, __construct)
765764
if (type_is_null) {
766765
ZVAL_LONG(Z_VAR_ENC_TYPE_P(this_ptr), UNKNOWN_TYPE);
767766
} else {
768-
if (zend_hash_index_exists(&SOAP_GLOBAL(defEncIndex), type)) {
767+
if (zend_hash_index_exists(&php_soap_defEncIndex, type)) {
769768
ZVAL_LONG(Z_VAR_ENC_TYPE_P(this_ptr), type);
770769
} else {
771770
zend_argument_value_error(2, "is not a valid encoding");

0 commit comments

Comments
 (0)