@@ -48,6 +48,7 @@ php_stream_wrapper shadow_wrapper = {
4848static ssize_t shadow_dirstream_read (php_stream * stream , char * buf , size_t count );
4949static int shadow_dirstream_close (php_stream * stream , int close_handle );
5050static int shadow_dirstream_rewind (php_stream * stream , off_t offset , int whence , off_t * newoffs );
51+ static void shadow_init_wrapper ();
5152
5253static php_stream_ops shadow_dirstream_ops = {
5354 NULL ,
@@ -423,22 +424,26 @@ PHP_MSHUTDOWN_FUNCTION(shadow)
423424 */
424425PHP_RINIT_FUNCTION (shadow )
425426{
426- if (SHADOW_G (enabled )) {
427- zend_string * protocol ;
428- protocol = zend_string_init ("file" , strlen ("file" ), 0 );
429- php_unregister_url_stream_wrapper_volatile (protocol );
430- php_register_url_stream_wrapper_volatile (protocol , & shadow_wrapper );
431- zend_string_release_ex (protocol , 0 );
432- }
433- SHADOW_G (template ) = NULL ;
434- SHADOW_G (instance ) = NULL ;
435- SHADOW_G (curdir ) = NULL ;
436- SHADOW_G (segment_id ) = 0 ;
437- SHADOW_G (shadow_override_copy ) = NULL ;
427+ shadow_init_wrapper ();
438428 return SUCCESS ;
439429}
440430/* }}} */
441431
432+ static void shadow_init_wrapper () {
433+ if (SHADOW_G (enabled )) {
434+ zend_string * protocol ;
435+ protocol = zend_string_init ("file" , strlen ("file" ), 0 );
436+ php_unregister_url_stream_wrapper_volatile (protocol );
437+ php_register_url_stream_wrapper_volatile (protocol , & shadow_wrapper );
438+ zend_string_release_ex (protocol , 0 );
439+ }
440+ SHADOW_G (template ) = NULL ;
441+ SHADOW_G (instance ) = NULL ;
442+ SHADOW_G (curdir ) = NULL ;
443+ SHADOW_G (segment_id ) = 0 ;
444+ SHADOW_G (shadow_override_copy ) = NULL ;
445+ }
446+
442447static void shadow_free_data ()
443448{
444449 if (SHADOW_G (template )) {
@@ -493,16 +498,21 @@ PHP_FUNCTION(shadow)
493498 char * temp = NULL ;
494499 char * inst = NULL ;
495500 size_t temp_len , inst_len ;
501+ zend_bool force = 0 ; // New parameter
496502 HashTable * instance_only = NULL ; /* paths relative to template root */
497503
498- if (zend_parse_parameters (ZEND_NUM_ARGS (), "ss|h " , & temp , & temp_len , & inst , & inst_len , & instance_only ) == FAILURE ) {
504+ if (zend_parse_parameters (ZEND_NUM_ARGS (), "ss|hb " , & temp , & temp_len , & inst , & inst_len , & instance_only , & force ) == FAILURE ) {
499505 return ;
500506 }
501507
502508 if (!SHADOW_G (enabled )) {
503509 RETURN_FALSE ;
504510 }
505511
512+ if (force ) {
513+ shadow_init_wrapper ();
514+ }
515+
506516 shadow_free_data ();
507517 php_clear_stat_cache (0 , NULL , 0 );
508518 if (temp_len == 0 || inst_len == 0 ) {
0 commit comments