# [RFC][PATCH]: hook for compile_string

- Thread: https://externals.io/message/24077
- Original archive: https://news-web.php.net/php.internals/24077
- Started by Stefan Esser on 2006-06-10T12:55:24+00:00
- Messages: 4
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #24077 — Stefan Esser — 2006-06-10T12:55:24+00:00

URL: https://externals.io/message/24077#24077

Hello,

I just wanted to hear your opinion about providing a hook for
compile_string. We already have a hook called zend_compile_file and it
would be very nice if we could also hook compile_string calls.

Greetings,
Stefan

---

## #24078 — Marcus Boerger — 2006-06-10T13:53:37+00:00

URL: https://externals.io/message/24077#24078 · In reply to: #24077

Hello Stefan,

 i for one appreciate this.

best regards
marcus

Saturday, June 10, 2006, 2:55:24 PM, you wrote:

> diff -Nura php-5.2/Zend/zend.c php-5.2-cshook/Zend/zend.c
> --- php-5.2/Zend/zend.c	2006-06-05 16:30:49.000000000 +0200
> +++ php-5.2-cshook/Zend/zend.c  2006-06-10 14:51:08.000000000 +0200
> @@ -595,6 +595,7 @@
>         zend_vspprintf = utility_functions->vspprintf_function;
>         zend_getenv = utility_functions->getenv_function;
>  
> +       zend_compile_string = compile_string;
>         zend_compile_file = compile_file;
>         zend_execute = execute;
>         zend_execute_internal = NULL;
> diff -Nura php-5.2/Zend/zend_compile.c php-5.2-cshook/Zend/zend_compile.c
> --- php-5.2/Zend/zend_compile.c	2006-06-07 12:30:53.000000000 +0200
> +++ php-5.2-cshook/Zend/zend_compile.c  2006-06-10 14:50:12.000000000 +0200
> @@ -31,6 +31,7 @@
>  #include "zend_multibyte.h"
>  #endif /* ZEND_MULTIBYTE */
>  
> +ZEND_API zend_op_array *(*zend_compile_string)(zval *source_string, char *filename TSRMLS_DC);
>  ZEND_API zend_op_array *(*zend_compile_file)(zend_file_handle *file_handle, int type TSRMLS_DC);
>  
>  
> diff -Nura php-5.2/Zend/zend_compile.h php-5.2-cshook/Zend/zend_compile.h
> --- php-5.2/Zend/zend_compile.h	2006-05-27 22:30:48.000000000 +0200
> +++ php-5.2-cshook/Zend/zend_compile.h  2006-06-10 14:50:04.000000000 +0200
> @@ -320,6 +320,7 @@
>  void shutdown_compiler(TSRMLS_D);
>  void zend_init_compiler_data_structures(TSRMLS_D);
>  
> +extern ZEND_API zend_op_array *(*zend_compile_string)(zval
> *source_string, char *filename TSRMLS_DC);
>  extern ZEND_API zend_op_array *(*zend_compile_file)(zend_file_handle *file_handle, int type TSRMLS_DC);
>  
>  ZEND_API int lex_scan(zval *zendlval TSRMLS_DC);
> diff -Nura php-5.2/Zend/zend_execute_API.c
> php-5.2-cshook/Zend/zend_execute_API.c
> --- php-5.2/Zend/zend_execute_API.c     2006-06-05 16:30:49.000000000 +0200
> +++ php-5.2-cshook/Zend/zend_execute_API.c      2006-06-10 14:52:17.000000000 +0200
> @@ -1101,7 +1101,7 @@
>  
>         original_handle_op_arrays = CG(handle_op_arrays);
>         CG(handle_op_arrays) = 0;
> -       new_op_array = compile_string(&pv, string_name TSRMLS_CC);
> +       new_op_array = zend_compile_string(&pv, string_name TSRMLS_CC);
>         CG(handle_op_arrays) = original_handle_op_arrays;
>  
>         if (new_op_array) {
> diff -Nura php-5.2/Zend/zend_vm_def.h php-5.2-cshook/Zend/zend_vm_def.h
> --- php-5.2/Zend/zend_vm_def.h  2006-06-08 12:30:48.000000000 +0200
> +++ php-5.2-cshook/Zend/zend_vm_def.h   2006-06-10 14:52:25.000000000 +0200
> @@ -2766,7 +2766,7 @@
>                 case ZEND_EVAL: {
>                                 char *eval_desc =
> zend_make_compiled_string_description("eval()'d code" TSRMLS_CC);
>  
> -                               new_op_array =
> compile_string(inc_filename, eval_desc TSRMLS_CC);
> +                               new_op_array =
> zend_compile_string(inc_filename, eval_desc TSRMLS_CC);
>                                 efree(eval_desc);
>                         }
>                         break;
> diff -Nura php-5.2/Zend/zend_vm_execute.h
> php-5.2-cshook/Zend/zend_vm_execute.h
> --- php-5.2/Zend/zend_vm_execute.h      2006-06-08 12:30:49.000000000 +0200
> +++ php-5.2-cshook/Zend/zend_vm_execute.h       2006-06-10 14:52:12.000000000 +0200
> @@ -1960,7 +1960,7 @@
>                 case ZEND_EVAL: {
>                                 char *eval_desc =
> zend_make_compiled_string_description("eval()'d code" TSRMLS_CC);
>  
> -                               new_op_array =
> compile_string(inc_filename, eval_desc TSRMLS_CC);
> +                               new_op_array =
> zend_compile_string(inc_filename, eval_desc TSRMLS_CC);
>                                 efree(eval_desc);
>                         }
>                         break;
> @@ -4460,7 +4460,7 @@
>                 case ZEND_EVAL: {
>                                 char *eval_desc =
> zend_make_compiled_string_description("eval()'d code" TSRMLS_CC);
>  
> -                               new_op_array =
> compile_string(inc_filename, eval_desc TSRMLS_CC);
> +                               new_op_array =
> zend_compile_string(inc_filename, eval_desc TSRMLS_CC);
>                                 efree(eval_desc);
>                         }
>                         break;
> @@ -7542,7 +7542,7 @@
>                 case ZEND_EVAL: {
>                                 char *eval_desc =
> zend_make_compiled_string_description("eval()'d code" TSRMLS_CC);
>  
> -                               new_op_array =
> compile_string(inc_filename, eval_desc TSRMLS_CC);
> +                               new_op_array =
> zend_compile_string(inc_filename, eval_desc TSRMLS_CC);
>                                 efree(eval_desc);
>                         }
>                         break;
> @@ -19764,7 +19764,7 @@
>                 case ZEND_EVAL: {
>                                 char *eval_desc =
> zend_make_compiled_string_description("eval()'d code" TSRMLS_CC);
>  
> -                               new_op_array =
> compile_string(inc_filename, eval_desc TSRMLS_CC);
> +                               new_op_array =
> zend_compile_string(inc_filename, eval_desc TSRMLS_CC);
>                                 efree(eval_desc);
>                         }
>                         break;




Best regards,
 Marcus

---

## #24079 — Derick Rethans — 2006-06-10T14:20:53+00:00

URL: https://externals.io/message/24077#24079 · In reply to: #24078

>  i for one appreciate this.

Yeah, would be nice...

Derick

---

## #24098 — Andi Gutmans — 2006-06-13T01:11:25+00:00

URL: https://externals.io/message/24077#24098 · In reply to: #24079

Fine with me.

At 07:20 AM 6/10/2006, Derick Rethans wrote:
>
>
> > […]
>
>Yeah, would be nice...
>
>Derick
