@@ -311,12 +311,17 @@ static inline void _call_php_function_with_2_params(const char *function_name, z
311
311
static void _call_php_function_with_3_params (const char * function_name , zval * retval_ptr , zval * arg1 , zval * arg2 , zval * arg3 );
312
312
static inline void _call_php_function_with_params (const char * function_name , zval * retval_ptr , uint32_t param_count , zval params []);
313
313
314
+ static const zend_module_dep timecop_module_deps [] = {
315
+ ZEND_MOD_REQUIRED ("Date" )
316
+ ZEND_MOD_END
317
+ };
318
+
314
319
/* {{{ timecop_module_entry
315
320
*/
316
321
zend_module_entry timecop_module_entry = {
317
- #if ZEND_MODULE_API_NO >= 20010901
318
- STANDARD_MODULE_HEADER ,
319
- #endif
322
+ STANDARD_MODULE_HEADER_EX ,
323
+ NULL ,
324
+ timecop_module_deps ,
320
325
"timecop" ,
321
326
timecop_functions ,
322
327
PHP_MINIT (timecop ),
@@ -355,6 +360,14 @@ PHP_MINIT_FUNCTION(timecop)
355
360
ZEND_INIT_MODULE_GLOBALS (timecop , timecop_globals_ctor , NULL );
356
361
REGISTER_INI_ENTRIES ();
357
362
register_timecop_classes ();
363
+
364
+ if (TIMECOP_G (func_override )) {
365
+ if (SUCCESS != timecop_func_override () ||
366
+ SUCCESS != timecop_class_override ()) {
367
+ return FAILURE ;
368
+ }
369
+ }
370
+
358
371
return SUCCESS ;
359
372
}
360
373
/* }}} */
@@ -364,6 +377,12 @@ PHP_MINIT_FUNCTION(timecop)
364
377
PHP_MSHUTDOWN_FUNCTION (timecop )
365
378
{
366
379
UNREGISTER_INI_ENTRIES ();
380
+
381
+ if (TIMECOP_G (func_override )) {
382
+ timecop_func_override_clear ();
383
+ timecop_class_override_clear ();
384
+ }
385
+
367
386
return SUCCESS ;
368
387
}
369
388
/* }}} */
@@ -375,25 +394,13 @@ PHP_RINIT_FUNCTION(timecop)
375
394
ZEND_TSRMLS_CACHE_UPDATE ();
376
395
#endif
377
396
378
- if (TIMECOP_G (func_override )) {
379
- if (SUCCESS != timecop_func_override () ||
380
- SUCCESS != timecop_class_override ()) {
381
- return FAILURE ;
382
- }
383
- }
384
-
385
397
return SUCCESS ;
386
398
}
387
399
/* }}} */
388
400
389
401
/* {{{ PHP_RSHUTDOWN_FUNCTION(timecop) */
390
402
PHP_RSHUTDOWN_FUNCTION (timecop )
391
403
{
392
- if (TIMECOP_G (func_override )) {
393
- timecop_func_override_clear ();
394
- timecop_class_override_clear ();
395
- }
396
-
397
404
if (Z_TYPE (TIMECOP_G (orig_request_time )) == IS_NULL ) {
398
405
restore_request_time ();
399
406
}
@@ -496,22 +503,22 @@ static int timecop_func_override()
496
503
497
504
p = & (timecop_override_func_table [0 ]);
498
505
while (p -> orig_func != NULL ) {
499
- zf_orig = zend_hash_str_find_ptr (EG (function_table ), p -> orig_func , strlen (p -> orig_func ));
506
+ zf_orig = zend_hash_str_find_ptr (CG (function_table ), p -> orig_func , strlen (p -> orig_func ));
500
507
if (zf_orig == NULL ) {
501
508
/* Do nothing. Because some functions are introduced by optional extensions. */
502
509
p ++ ;
503
510
continue ;
504
511
}
505
512
506
- zf_ovrd = zend_hash_str_find_ptr (EG (function_table ), p -> ovrd_func , strlen (p -> ovrd_func ));
513
+ zf_ovrd = zend_hash_str_find_ptr (CG (function_table ), p -> ovrd_func , strlen (p -> ovrd_func ));
507
514
if (zf_ovrd == NULL ) {
508
515
php_error_docref ("https://github.com/hnw/php-timecop" , E_WARNING ,
509
516
"timecop couldn't find function %s." , p -> ovrd_func );
510
517
p ++ ;
511
518
continue ;
512
519
}
513
520
514
- zf_save = zend_hash_str_find_ptr (EG (function_table ), p -> save_func , strlen (p -> save_func ));
521
+ zf_save = zend_hash_str_find_ptr (CG (function_table ), p -> save_func , strlen (p -> save_func ));
515
522
if (zf_save != NULL ) {
516
523
php_error_docref ("https://github.com/hnw/php-timecop" , E_WARNING ,
517
524
"timecop couldn't create function %s because already exists." ,
@@ -523,12 +530,12 @@ static int timecop_func_override()
523
530
TIMECOP_ASSERT (zf_orig -> type == ZEND_INTERNAL_FUNCTION );
524
531
TIMECOP_ASSERT (zf_ovrd -> type == ZEND_INTERNAL_FUNCTION );
525
532
526
- zend_hash_str_add_mem (EG (function_table ), p -> save_func , strlen (p -> save_func ),
533
+ zend_hash_str_add_mem (CG (function_table ), p -> save_func , strlen (p -> save_func ),
527
534
zf_orig , sizeof (zend_internal_function ));
528
535
function_add_ref (zf_orig );
529
536
530
537
GUARD_FUNCTION_ARG_INFO_BEGIN (zf_orig );
531
- zend_hash_str_update_mem (EG (function_table ), p -> orig_func , strlen (p -> orig_func ),
538
+ zend_hash_str_update_mem (CG (function_table ), p -> orig_func , strlen (p -> orig_func ),
532
539
zf_ovrd , sizeof (zend_internal_function ));
533
540
GUARD_FUNCTION_ARG_INFO_END ();
534
541
function_add_ref (zf_ovrd );
@@ -546,15 +553,15 @@ static int timecop_class_override()
546
553
547
554
p = & (timecop_override_class_table [0 ]);
548
555
while (p -> orig_class != NULL ) {
549
- ce_orig = zend_hash_str_find_ptr (EG (class_table ), p -> orig_class , strlen (p -> orig_class ));
556
+ ce_orig = zend_hash_str_find_ptr (CG (class_table ), p -> orig_class , strlen (p -> orig_class ));
550
557
if (ce_orig == NULL ) {
551
558
php_error_docref ("https://github.com/hnw/php-timecop" , E_WARNING ,
552
559
"timecop couldn't find class %s." , p -> orig_class );
553
560
p ++ ;
554
561
continue ;
555
562
}
556
563
557
- ce_ovrd = zend_hash_str_find_ptr (EG (class_table ), p -> ovrd_class , strlen (p -> ovrd_class ));
564
+ ce_ovrd = zend_hash_str_find_ptr (CG (class_table ), p -> ovrd_class , strlen (p -> ovrd_class ));
558
565
if (ce_ovrd == NULL ) {
559
566
php_error_docref ("https://github.com/hnw/php-timecop" , E_WARNING ,
560
567
"timecop couldn't find class %s." , p -> ovrd_class );
@@ -626,23 +633,23 @@ static int timecop_func_override_clear()
626
633
627
634
p = & (timecop_override_func_table [0 ]);
628
635
while (p -> orig_func != NULL ) {
629
- zf_orig = zend_hash_str_find_ptr (EG (function_table ),
636
+ zf_orig = zend_hash_str_find_ptr (CG (function_table ),
630
637
p -> save_func , strlen (p -> save_func ));
631
- zf_ovld = zend_hash_str_find_ptr (EG (function_table ),
638
+ zf_ovld = zend_hash_str_find_ptr (CG (function_table ),
632
639
p -> orig_func , strlen (p -> orig_func ));
633
640
if (zf_orig == NULL || zf_ovld == NULL ) {
634
641
p ++ ;
635
642
continue ;
636
643
}
637
644
638
645
GUARD_FUNCTION_ARG_INFO_BEGIN (zf_ovld );
639
- zend_hash_str_update_mem (EG (function_table ), p -> orig_func , strlen (p -> orig_func ),
646
+ zend_hash_str_update_mem (CG (function_table ), p -> orig_func , strlen (p -> orig_func ),
640
647
zf_orig , sizeof (zend_internal_function ));
641
648
GUARD_FUNCTION_ARG_INFO_END ();
642
649
function_add_ref (zf_orig );
643
650
644
651
GUARD_FUNCTION_ARG_INFO_BEGIN (zf_orig );
645
- zend_hash_str_del (EG (function_table ), p -> save_func , strlen (p -> save_func ));
652
+ zend_hash_str_del (CG (function_table ), p -> save_func , strlen (p -> save_func ));
646
653
GUARD_FUNCTION_ARG_INFO_END ();
647
654
648
655
p ++ ;
@@ -658,7 +665,7 @@ static int timecop_class_override_clear()
658
665
659
666
p = & (timecop_override_class_table [0 ]);
660
667
while (p -> orig_class != NULL ) {
661
- ce_orig = zend_hash_str_find_ptr (EG (class_table ),
668
+ ce_orig = zend_hash_str_find_ptr (CG (class_table ),
662
669
p -> orig_class , strlen (p -> orig_class ));
663
670
if (ce_orig == NULL ) {
664
671
php_error_docref ("https://github.com/hnw/php-timecop" , E_WARNING ,
0 commit comments