7373* https://www.amazon.fr/Advanced-PHP-Programming-George-Schlossnagle/dp/0672325616
7474*/
7575
76+ /* upgrading to php7
77+ * https://wiki.php.net/phpng-upgrading
78+ * https://www.programmersought.com/article/42361486581/
79+ */
80+
7681#include "php_embeded.h"
7782#include "ext/standard/php_standard.h"
7883
8186 #error "Need PHP version >= 5.5 to compile this file"
8287#endif
8388
84-
8589/******************************************************************************
8690 * *
8791 * Function: php_embed_eval_string *
8892 * *
8993 * Purpose: eval php script string transmit in code. *
9094 * *
9195 ******************************************************************************/
92- zval * php_embed_eval_string (char * code , zval * retval_ptr , char * string_name TSRMLS_DC )
96+ int php_embed_eval_string (char * code , zval * retval , char * string_name TSRMLS_DC )
9397{
94- zval * retval ;
95- ALLOC_INIT_ZVAL (retval );
96-
9798 zend_try {
98- if (SUCCESS == zend_eval_string (code , retval , string_name TSRMLS_CC ))
99- return retval ;
99+ if (SUCCESS == zend_eval_string (code , retval , string_name TSRMLS_CC )) return SUCCESS ;
100100 } zend_catch {
101101
102102 } zend_end_try ();
103103
104- return retval ;
104+ return FAILURE ;
105105}
106106
107107
@@ -112,10 +112,9 @@ zval *php_embed_eval_string(char *code, zval *retval_ptr, char *string_name TSRM
112112 * Purpose: execute filename script. *
113113 * *
114114 ******************************************************************************/
115- zval * php_embed_execute (char * filename TSRMLS_DC )
115+ int php_embed_execute (char * filename , zval * retval TSRMLS_DC )
116116{
117117 int ret = 0 ;
118- zval * retval = NULL ;
119118 zend_file_handle zfd ;
120119
121120 zfd .type = ZEND_HANDLE_FILENAME ;
@@ -125,9 +124,9 @@ zval * php_embed_execute(char *filename TSRMLS_DC)
125124 zfd .opened_path = NULL ;
126125 zend_try {
127126 if (SUCCESS == zend_execute_scripts (ZEND_REQUIRE TSRMLS_CC , & retval , 1 , & zfd ))
128- if ( retval ) return retval ;
127+ return SUCCESS ;
129128 } zend_end_try ();
130- return retval ;
129+ return FAILURE ;
131130}
132131
133132
@@ -151,7 +150,7 @@ static const zend_function_entry my_additional_functions[] = {
151150 */
152151int php_embed_minit (const char * hardcoded_ini PTSRMLS_DC )
153152{
154- #ifdef ZTS
153+ #if defined( ZTS ) && PHP_VERSION_ID < 70400
155154 void * * * tsrm_ls = NULL ;
156155#endif
157156 int ini_entries_len = 0 ;
@@ -168,11 +167,22 @@ int php_embed_minit(const char* hardcoded_ini PTSRMLS_DC)
168167#endif
169168
170169#ifdef ZTS
170+ #if PHP_VERSION_ID >= 70400
171+ php_tsrm_startup ();
172+ #else
171173 tsrm_startup (1 , 1 , 0 , NULL );
172174 tsrm_ls = ts_resource (0 );
173175 * ptsrm_ls = tsrm_ls ;
174176#endif
177+ #endif
175178
179+ #if PHP_VERSION_ID >= 70000 && defined(ZEND_SIGNALS )
180+ #if HAVE_ZEND_SIGNAL_STARTUP
181+ zend_signal_startup ();
182+ #elif defined(ZTS )
183+ #error PHP is built with thread safety and broken signals.
184+ #endif
185+ #endif
176186 if (hardcoded_ini != NULL )
177187 {
178188 ini_entries_len = strlen (hardcoded_ini );
0 commit comments