Skip to content

Commit 06ef71f

Browse files
author
Andrei Zmievski
committed
Speed up SoapClient/SoapServer constructors by caching WSDL structures
in memory. All WSDL files will be cached, unless turned off via an option to the constructor.
1 parent 1e33c4c commit 06ef71f

File tree

9 files changed

+1153
-10
lines changed

9 files changed

+1153
-10
lines changed

NEWS

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
PHP NEWS
22
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
33
06 Apr 2006, PHP 5.1.3RC3
4+
- Sped up SoapClient/SoapServer construction by making SOAP extension cache
5+
WSDL structure in memory. (Andrei)
46
- Fixed a bug that would not fill in the fifth argument to preg_replace()
57
properly, if the variable was not declared previously. (Andrei)
68
- Fixed safe_mode check for source argument of the copy() function. (Ilia)

ext/soap/php_encoding.c

+14
Original file line numberDiff line numberDiff line change
@@ -3300,3 +3300,17 @@ void delete_encoder(void *encode)
33003300
}
33013301
efree(t);
33023302
}
3303+
3304+
void delete_encoder_persistent(void *encode)
3305+
{
3306+
encodePtr t = *((encodePtr*)encode);
3307+
if (t->details.ns) {
3308+
free(t->details.ns);
3309+
}
3310+
if (t->details.type_str) {
3311+
free(t->details.type_str);
3312+
}
3313+
/* we should never have mapping in persistent encoder */
3314+
assert(t->details.map == NULL);
3315+
free(t);
3316+
}

ext/soap/php_encoding.h

+1
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,7 @@ xmlNsPtr encode_add_ns(xmlNodePtr node, const char* ns);
219219
encodePtr get_conversion(int encode);
220220

221221
void delete_encoder(void *handle);
222+
void delete_encoder_persistent(void *handle);
222223

223224
extern encode defaultEncoding[];
224225

ext/soap/php_schema.c

+127
Original file line numberDiff line numberDiff line change
@@ -2358,6 +2358,28 @@ void delete_model(void *handle)
23582358
efree(tmp);
23592359
}
23602360

2361+
void delete_model_persistent(void *handle)
2362+
{
2363+
sdlContentModelPtr tmp = *((sdlContentModelPtr*)handle);
2364+
switch (tmp->kind) {
2365+
case XSD_CONTENT_ELEMENT:
2366+
case XSD_CONTENT_GROUP:
2367+
break;
2368+
case XSD_CONTENT_SEQUENCE:
2369+
case XSD_CONTENT_ALL:
2370+
case XSD_CONTENT_CHOICE:
2371+
zend_hash_destroy(tmp->u.content);
2372+
free(tmp->u.content);
2373+
break;
2374+
case XSD_CONTENT_GROUP_REF:
2375+
free(tmp->u.group_ref);
2376+
break;
2377+
default:
2378+
break;
2379+
}
2380+
free(tmp);
2381+
}
2382+
23612383
void delete_type(void *data)
23622384
{
23632385
sdlTypePtr type = *((sdlTypePtr*)data);
@@ -2405,6 +2427,53 @@ void delete_type(void *data)
24052427
efree(type);
24062428
}
24072429

2430+
void delete_type_persistent(void *data)
2431+
{
2432+
sdlTypePtr type = *((sdlTypePtr*)data);
2433+
if (type->name) {
2434+
free(type->name);
2435+
}
2436+
if (type->namens) {
2437+
free(type->namens);
2438+
}
2439+
if (type->def) {
2440+
free(type->def);
2441+
}
2442+
if (type->fixed) {
2443+
free(type->fixed);
2444+
}
2445+
if (type->elements) {
2446+
zend_hash_destroy(type->elements);
2447+
free(type->elements);
2448+
}
2449+
if (type->attributes) {
2450+
zend_hash_destroy(type->attributes);
2451+
free(type->attributes);
2452+
}
2453+
if (type->model) {
2454+
delete_model_persistent((void**)&type->model);
2455+
}
2456+
if (type->restrictions) {
2457+
delete_restriction_var_int_persistent(&type->restrictions->minExclusive);
2458+
delete_restriction_var_int_persistent(&type->restrictions->minInclusive);
2459+
delete_restriction_var_int_persistent(&type->restrictions->maxExclusive);
2460+
delete_restriction_var_int_persistent(&type->restrictions->maxInclusive);
2461+
delete_restriction_var_int_persistent(&type->restrictions->totalDigits);
2462+
delete_restriction_var_int_persistent(&type->restrictions->fractionDigits);
2463+
delete_restriction_var_int_persistent(&type->restrictions->length);
2464+
delete_restriction_var_int_persistent(&type->restrictions->minLength);
2465+
delete_restriction_var_int_persistent(&type->restrictions->maxLength);
2466+
delete_restriction_var_char_persistent(&type->restrictions->whiteSpace);
2467+
delete_restriction_var_char_persistent(&type->restrictions->pattern);
2468+
if (type->restrictions->enumeration) {
2469+
zend_hash_destroy(type->restrictions->enumeration);
2470+
free(type->restrictions->enumeration);
2471+
}
2472+
free(type->restrictions);
2473+
}
2474+
free(type);
2475+
}
2476+
24082477
void delete_extra_attribute(void *attribute)
24092478
{
24102479
sdlExtraAttributePtr attr = *((sdlExtraAttributePtr*)attribute);
@@ -2418,6 +2487,19 @@ void delete_extra_attribute(void *attribute)
24182487
efree(attr);
24192488
}
24202489

2490+
void delete_extra_attribute_persistent(void *attribute)
2491+
{
2492+
sdlExtraAttributePtr attr = *((sdlExtraAttributePtr*)attribute);
2493+
2494+
if (attr->ns) {
2495+
free(attr->ns);
2496+
}
2497+
if (attr->val) {
2498+
free(attr->val);
2499+
}
2500+
free(attr);
2501+
}
2502+
24212503
void delete_attribute(void *attribute)
24222504
{
24232505
sdlAttributePtr attr = *((sdlAttributePtr*)attribute);
@@ -2444,6 +2526,32 @@ void delete_attribute(void *attribute)
24442526
efree(attr);
24452527
}
24462528

2529+
void delete_attribute_persistent(void *attribute)
2530+
{
2531+
sdlAttributePtr attr = *((sdlAttributePtr*)attribute);
2532+
2533+
if (attr->def) {
2534+
free(attr->def);
2535+
}
2536+
if (attr->fixed) {
2537+
free(attr->fixed);
2538+
}
2539+
if (attr->name) {
2540+
free(attr->name);
2541+
}
2542+
if (attr->namens) {
2543+
free(attr->namens);
2544+
}
2545+
if (attr->ref) {
2546+
free(attr->ref);
2547+
}
2548+
if (attr->extraAttributes) {
2549+
zend_hash_destroy(attr->extraAttributes);
2550+
free(attr->extraAttributes);
2551+
}
2552+
free(attr);
2553+
}
2554+
24472555
void delete_restriction_var_int(void *rvi)
24482556
{
24492557
sdlRestrictionIntPtr ptr = *((sdlRestrictionIntPtr*)rvi);
@@ -2452,6 +2560,14 @@ void delete_restriction_var_int(void *rvi)
24522560
}
24532561
}
24542562

2563+
void delete_restriction_var_int_persistent(void *rvi)
2564+
{
2565+
sdlRestrictionIntPtr ptr = *((sdlRestrictionIntPtr*)rvi);
2566+
if (ptr) {
2567+
free(ptr);
2568+
}
2569+
}
2570+
24552571
void delete_restriction_var_char(void *srvc)
24562572
{
24572573
sdlRestrictionCharPtr ptr = *((sdlRestrictionCharPtr*)srvc);
@@ -2462,3 +2578,14 @@ void delete_restriction_var_char(void *srvc)
24622578
efree(ptr);
24632579
}
24642580
}
2581+
2582+
void delete_restriction_var_char_persistent(void *srvc)
2583+
{
2584+
sdlRestrictionCharPtr ptr = *((sdlRestrictionCharPtr*)srvc);
2585+
if (ptr) {
2586+
if (ptr->value) {
2587+
free(ptr->value);
2588+
}
2589+
free(ptr);
2590+
}
2591+
}

ext/soap/php_schema.h

+6
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,15 @@ int load_schema(sdlCtx *ctx, xmlNodePtr schema TSRMLS_DC);
2626
void schema_pass2(sdlCtx *ctx);
2727

2828
void delete_model(void *handle);
29+
void delete_model_persistent(void *handle);
2930
void delete_type(void *data);
31+
void delete_type_persistent(void *data);
3032
void delete_extra_attribute(void *attribute);
33+
void delete_extra_attribute_persistent(void *attribute);
3134
void delete_attribute(void *attribute);
35+
void delete_attribute_persistent(void *attribute);
3236
void delete_restriction_var_int(void *rvi);
37+
void delete_restriction_var_int_persistent(void *rvi);
3338
void delete_restriction_var_char(void *srvc);
39+
void delete_restriction_var_char_persistent(void *srvc);
3440
#endif

0 commit comments

Comments
 (0)