From 30f1270c26edb6ced469eb302de2fa27befbdbec Mon Sep 17 00:00:00 2001 From: jvoisin Date: Mon, 27 Jun 2022 20:12:47 +0200 Subject: Move compile_file and compile_string to sp_execute.c --- src/sp_execute.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'src/sp_execute.c') diff --git a/src/sp_execute.c b/src/sp_execute.c index f1ed8d0..b81f408 100644 --- a/src/sp_execute.c +++ b/src/sp_execute.c @@ -286,6 +286,34 @@ static zend_result sp_stream_open(zend_file_handle *handle) { #endif +ZEND_API zend_op_array* (*orig_zend_compile_file)(zend_file_handle* file_handle, + int type) = NULL; +#if PHP_VERSION_ID >= 80000 +ZEND_API zend_op_array* (*orig_zend_compile_string)( + zend_string* source_string, const char* filename) = NULL; +#else +ZEND_API zend_op_array* (*orig_zend_compile_string)(zval* source_string, + char* filename) = NULL; +#endif + +#if PHP_VERSION_ID >= 80000 +ZEND_API zend_op_array* sp_compile_string(zend_string* source_string, + const char* filename) { +#else +ZEND_API zend_op_array* sp_compile_string(zval* source_string, char* filename) { +#endif + zend_op_array* opline = orig_zend_compile_string(source_string, filename); + sp_sloppy_modify_opcode(opline); + return opline; +} + +ZEND_API zend_op_array* sp_compile_file(zend_file_handle* file_handle, + int type) { + zend_op_array* opline = orig_zend_compile_file(file_handle, type); + sp_sloppy_modify_opcode(opline); + return opline; +} + int hook_execute(void) { TSRMLS_FETCH(); @@ -309,5 +337,16 @@ int hook_execute(void) { } } + if (NULL == orig_zend_compile_file && zend_compile_file != sp_compile_file) { + orig_zend_compile_file = zend_compile_file; + zend_compile_file = sp_compile_file; + } + + if (NULL == orig_zend_compile_string && + zend_compile_string != sp_compile_string) { + orig_zend_compile_string = zend_compile_string; + zend_compile_string = sp_compile_string; + } + return SUCCESS; } -- cgit v1.3