@@ -1457,14 +1457,23 @@ PHPAPI int php_register_url_stream_wrapper(char *protocol, php_stream_wrapper *w
1457
1457
return FAILURE ;
1458
1458
}
1459
1459
1460
- return zend_hash_add (& url_stream_wrappers_hash , protocol , protocol_len , wrapper , sizeof (* wrapper ), NULL );
1460
+ return zend_hash_add (& url_stream_wrappers_hash , protocol , protocol_len , & wrapper , sizeof (wrapper ), NULL );
1461
1461
}
1462
1462
1463
1463
PHPAPI int php_unregister_url_stream_wrapper (char * protocol TSRMLS_DC )
1464
1464
{
1465
1465
return zend_hash_del (& url_stream_wrappers_hash , protocol , strlen (protocol ));
1466
1466
}
1467
1467
1468
+ static void clone_wrapper_hash (TSRMLS_D )
1469
+ {
1470
+ php_stream_wrapper * tmp ;
1471
+
1472
+ ALLOC_HASHTABLE (FG (stream_wrappers ));
1473
+ zend_hash_init (FG (stream_wrappers ), 0 , NULL , NULL , 1 );
1474
+ zend_hash_copy (FG (stream_wrappers ), & url_stream_wrappers_hash , NULL , & tmp , sizeof (tmp ));
1475
+ }
1476
+
1468
1477
/* API for registering VOLATILE wrappers */
1469
1478
PHPAPI int php_register_url_stream_wrapper_volatile (char * protocol , php_stream_wrapper * wrapper TSRMLS_DC )
1470
1479
{
@@ -1475,24 +1484,16 @@ PHPAPI int php_register_url_stream_wrapper_volatile(char *protocol, php_stream_w
1475
1484
}
1476
1485
1477
1486
if (!FG (stream_wrappers )) {
1478
- php_stream_wrapper tmpwrapper ;
1479
-
1480
- ALLOC_HASHTABLE (FG (stream_wrappers ));
1481
- zend_hash_init (FG (stream_wrappers ), 0 , NULL , NULL , 1 );
1482
- zend_hash_copy (FG (stream_wrappers ), & url_stream_wrappers_hash , NULL , & tmpwrapper , sizeof (php_stream_wrapper ));
1487
+ clone_wrapper_hash (TSRMLS_C );
1483
1488
}
1484
1489
1485
- return zend_hash_add (FG (stream_wrappers ), protocol , protocol_len , wrapper , sizeof (* wrapper ), NULL );
1490
+ return zend_hash_add (FG (stream_wrappers ), protocol , protocol_len , & wrapper , sizeof (wrapper ), NULL );
1486
1491
}
1487
1492
1488
1493
PHPAPI int php_unregister_url_stream_wrapper_volatile (char * protocol TSRMLS_DC )
1489
1494
{
1490
1495
if (!FG (stream_wrappers )) {
1491
- php_stream_wrapper tmpwrapper ;
1492
-
1493
- ALLOC_HASHTABLE (FG (stream_wrappers ));
1494
- zend_hash_init (FG (stream_wrappers ), 0 , NULL , NULL , 1 );
1495
- zend_hash_copy (FG (stream_wrappers ), & url_stream_wrappers_hash , NULL , & tmpwrapper , sizeof (php_stream_wrapper ));
1496
+ clone_wrapper_hash (TSRMLS_C );
1496
1497
}
1497
1498
1498
1499
return zend_hash_del (FG (stream_wrappers ), protocol , strlen (protocol ));
@@ -1503,7 +1504,7 @@ PHPAPI int php_unregister_url_stream_wrapper_volatile(char *protocol TSRMLS_DC)
1503
1504
PHPAPI php_stream_wrapper * php_stream_locate_url_wrapper (const char * path , char * * path_for_open , int options TSRMLS_DC )
1504
1505
{
1505
1506
HashTable * wrapper_hash = (FG (stream_wrappers ) ? FG (stream_wrappers ) : & url_stream_wrappers_hash );
1506
- php_stream_wrapper * wrapper = NULL ;
1507
+ php_stream_wrapper * * wrapperpp = NULL ;
1507
1508
const char * p , * protocol = NULL ;
1508
1509
int n = 0 ;
1509
1510
@@ -1529,7 +1530,7 @@ PHPAPI php_stream_wrapper *php_stream_locate_url_wrapper(const char *path, char
1529
1530
}
1530
1531
1531
1532
if (protocol ) {
1532
- if (FAILURE == zend_hash_find (wrapper_hash , (char * )protocol , n , (void * * )& wrapper )) {
1533
+ if (FAILURE == zend_hash_find (wrapper_hash , (char * )protocol , n , (void * * )& wrapperpp )) {
1533
1534
char wrapper_name [32 ];
1534
1535
1535
1536
if (n >= sizeof (wrapper_name ))
@@ -1539,7 +1540,7 @@ PHPAPI php_stream_wrapper *php_stream_locate_url_wrapper(const char *path, char
1539
1540
php_error_docref (NULL TSRMLS_CC , E_NOTICE , "Unable to find the wrapper \"%s\" - did you forget to enable it when you configured PHP?" ,
1540
1541
wrapper_name );
1541
1542
1542
- wrapper = NULL ;
1543
+ wrapperpp = NULL ;
1543
1544
protocol = NULL ;
1544
1545
}
1545
1546
}
@@ -1584,14 +1585,14 @@ PHPAPI php_stream_wrapper *php_stream_locate_url_wrapper(const char *path, char
1584
1585
if (FG (stream_wrappers )) {
1585
1586
/* The file:// wrapper may have been disabled/overridden */
1586
1587
1587
- if (wrapper ) {
1588
+ if (wrapperpp ) {
1588
1589
/* It was found so go ahead and provide it */
1589
- return wrapper ;
1590
+ return * wrapperpp ;
1590
1591
}
1591
1592
1592
1593
/* Check again, the original check might have not known the protocol name */
1593
- if (zend_hash_find (wrapper_hash , "file" , sizeof ("file" )- 1 , (void * * )& wrapper ) == SUCCESS ) {
1594
- return wrapper ;
1594
+ if (zend_hash_find (wrapper_hash , "file" , sizeof ("file" )- 1 , (void * * )& wrapperpp ) == SUCCESS ) {
1595
+ return * wrapperpp ;
1595
1596
}
1596
1597
1597
1598
if (options & REPORT_ERRORS ) {
@@ -1604,14 +1605,14 @@ PHPAPI php_stream_wrapper *php_stream_locate_url_wrapper(const char *path, char
1604
1605
return & php_plain_files_wrapper ;
1605
1606
}
1606
1607
1607
- if (wrapper && wrapper -> is_url && !PG (allow_url_fopen )) {
1608
+ if (wrapperpp && ( * wrapperpp ) -> is_url && !PG (allow_url_fopen )) {
1608
1609
if (options & REPORT_ERRORS ) {
1609
1610
php_error_docref (NULL TSRMLS_CC , E_WARNING , "URL file-access is disabled in the server configuration" );
1610
1611
}
1611
1612
return NULL ;
1612
1613
}
1613
1614
1614
- return wrapper ;
1615
+ return * wrapperpp ;
1615
1616
}
1616
1617
/* }}} */
1617
1618
0 commit comments