@@ -48,6 +48,10 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_opcache_get_status, 0, 0, 0)
48
48
ZEND_ARG_INFO (0 , fetch_scripts )
49
49
ZEND_END_ARG_INFO ()
50
50
51
+ ZEND_BEGIN_ARG_INFO_EX (arginfo_opcache_compile_file , 0 , 0 , 1 )
52
+ ZEND_ARG_INFO (0 , file )
53
+ ZEND_END_ARG_INFO ()
54
+
51
55
ZEND_BEGIN_ARG_INFO_EX (arginfo_opcache_invalidate , 0 , 0 , 1 )
52
56
ZEND_ARG_INFO (0 , script )
53
57
ZEND_ARG_INFO (0 , force )
@@ -59,12 +63,14 @@ static ZEND_FUNCTION(opcache_invalidate);
59
63
60
64
/* Private functions */
61
65
static ZEND_FUNCTION (opcache_get_status );
66
+ static ZEND_FUNCTION (opcache_compile_file );
62
67
static ZEND_FUNCTION (opcache_get_configuration );
63
68
64
69
static zend_function_entry accel_functions [] = {
65
70
/* User functions */
66
71
ZEND_FE (opcache_reset , arginfo_opcache_none )
67
72
ZEND_FE (opcache_invalidate , arginfo_opcache_invalidate )
73
+ ZEND_FE (opcache_compile_file , arginfo_opcache_compile_file )
68
74
/* Private functions */
69
75
ZEND_FE (opcache_get_configuration , arginfo_opcache_none )
70
76
ZEND_FE (opcache_get_status , arginfo_opcache_get_status )
@@ -709,3 +715,44 @@ static ZEND_FUNCTION(opcache_invalidate)
709
715
RETURN_FALSE ;
710
716
}
711
717
}
718
+
719
+ static ZEND_FUNCTION (opcache_compile_file )
720
+ {
721
+ char * script_name ;
722
+ int script_name_len ;
723
+ zend_file_handle handle ;
724
+ zend_op_array * op_array = NULL ;
725
+ zend_execute_data * orig_execute_data = NULL ;
726
+
727
+ if (zend_parse_parameters (ZEND_NUM_ARGS () TSRMLS_CC , "s" , & script_name , & script_name_len ) == FAILURE ) {
728
+ return ;
729
+ }
730
+
731
+ if (!ZCG (enabled ) || !accel_startup_ok || !ZCSG (accelerator_enabled )) {
732
+ zend_error (E_NOTICE , ACCELERATOR_PRODUCT_NAME " seems to be disabled, can't compile file" );
733
+ RETURN_FALSE ;
734
+ }
735
+
736
+ handle .filename = script_name ;
737
+ handle .free_filename = 0 ;
738
+ handle .opened_path = NULL ;
739
+ handle .type = ZEND_HANDLE_FILENAME ;
740
+
741
+ orig_execute_data = EG (current_execute_data );
742
+
743
+ zend_try {
744
+ op_array = persistent_compile_file (& handle , ZEND_INCLUDE TSRMLS_CC );
745
+ } zend_catch {
746
+ EG (current_execute_data ) = orig_execute_data ;
747
+ zend_error (E_WARNING , ACCELERATOR_PRODUCT_NAME " could not compile file %s" TSRMLS_CC , handle .filename );
748
+ } zend_end_try ();
749
+
750
+ if (op_array != NULL ) {
751
+ destroy_op_array (op_array TSRMLS_CC );
752
+ efree (op_array );
753
+ RETVAL_TRUE ;
754
+ } else {
755
+ RETVAL_FALSE ;
756
+ }
757
+ zend_destroy_file_handle (& handle TSRMLS_CC );
758
+ }
0 commit comments