@@ -194,9 +194,6 @@ PHP_MSHUTDOWN_FUNCTION(appserver)
194
194
195
195
PHP_MINIT_FUNCTION (appserver )
196
196
{
197
- zval * const_value , * const_name ;
198
- char * sapiname ;
199
-
200
197
REGISTER_INI_ENTRIES ();
201
198
202
199
/* init globals */
@@ -207,8 +204,27 @@ PHP_MINIT_FUNCTION(appserver)
207
204
208
205
PHP_RINIT_FUNCTION (appserver )
209
206
{
210
- char * ptr ;
211
- char * str ;
207
+ char * ptr , * str , * sapiconst = APPSERVER_CONSTANT_PHP_SAPI ;
208
+ zend_constant * defined ;
209
+ zval * new_phpsapi ;
210
+ char * new_phpsapi_name = APPSERVER_SAPI_NAME ;
211
+
212
+ /* create zval for new sapi string */
213
+ MAKE_STD_ZVAL (new_phpsapi );
214
+ ZVAL_STRING (new_phpsapi , new_phpsapi_name , 1 );
215
+
216
+ /* check if PHP_SAPI const can be found to overwrite cli sapi name to appserver */
217
+ if (zend_hash_find (EG (zend_constants ), sapiconst , strlen (sapiconst )+ 1 , (void * * ) & defined ) == SUCCESS ) {
218
+ /* create new constant with new php sapi name */
219
+ zend_constant c ;
220
+ c .value = * new_phpsapi ;
221
+ c .flags = PHP_USER_CONSTANT ;
222
+ c .name = zend_strndup (& sapiconst , strlen (sapiconst ));
223
+ c .name_len = strlen (sapiconst ) + 1 ;
224
+ c .module_number = 0 ;
225
+ /* update PHP_SAPI constant in hash table */
226
+ zend_hash_update (EG (zend_constants ), sapiconst , strlen (sapiconst )+ 1 , (void * )& c , sizeof (zend_constant ), (void * * )& c );
227
+ }
212
228
213
229
/* remove functions given in ini setting */
214
230
ptr = strtok (INI_STR ("appserver.remove_constants" ), "," );
@@ -219,7 +235,6 @@ PHP_RINIT_FUNCTION(appserver)
219
235
ptr = strtok (NULL , "," );
220
236
}
221
237
222
-
223
238
/* remove functions given in ini setting */
224
239
ptr = strtok (INI_STR ("appserver.remove_functions" ), "," );
225
240
while (ptr != NULL ) {
0 commit comments