@@ -4246,6 +4246,10 @@ static int preload_autoload(zend_string *filename)
4246
4246
{
4247
4247
zend_persistent_script * persistent_script ;
4248
4248
zend_op_array * op_array ;
4249
+ zend_execute_data * old_execute_data ;
4250
+ zend_class_entry * old_fake_scope ;
4251
+ zend_bool do_bailout = 0 ;
4252
+ int ret = SUCCESS ;
4249
4253
4250
4254
if (zend_hash_exists (& EG (included_files ), filename )) {
4251
4255
return FAILURE ;
@@ -4256,18 +4260,55 @@ static int preload_autoload(zend_string *filename)
4256
4260
return FAILURE ;
4257
4261
}
4258
4262
4263
+ zend_hash_add_empty_element (& EG (included_files ), filename );
4264
+
4265
+ if (persistent_script -> ping_auto_globals_mask ) {
4266
+ zend_accel_set_auto_globals (persistent_script -> ping_auto_globals_mask );
4267
+ }
4268
+
4259
4269
op_array = zend_accel_load_script (persistent_script , 1 );
4260
4270
if (!op_array ) {
4261
4271
return FAILURE ;
4262
4272
}
4263
4273
4264
- // TODO: we may need to execute this in some special context ???
4265
- zend_execute (op_array , NULL );
4274
+ /* Execute in global context */
4275
+ old_execute_data = EG (current_execute_data );
4276
+ EG (current_execute_data ) = NULL ;
4277
+ old_fake_scope = EG (fake_scope );
4278
+ EG (fake_scope ) = NULL ;
4279
+ zend_exception_save ();
4280
+
4281
+ zend_try {
4282
+ zend_execute (op_array , NULL );
4283
+ } zend_catch {
4284
+ do_bailout = 1 ;
4285
+ } zend_end_try ();
4286
+
4287
+ if (EG (exception )) {
4288
+ ret = FAILURE ;
4289
+ }
4290
+
4291
+ zend_exception_restore ();
4292
+ EG (fake_scope ) = old_fake_scope ;
4293
+ EG (current_execute_data ) = old_execute_data ;
4294
+ while (old_execute_data ) {
4295
+ if (old_execute_data -> func && (ZEND_CALL_INFO (old_execute_data ) & ZEND_CALL_HAS_SYMBOL_TABLE )) {
4296
+ if (old_execute_data -> symbol_table == & EG (symbol_table )) {
4297
+ zend_attach_symbol_table (old_execute_data );
4298
+ }
4299
+ break ;
4300
+ }
4301
+ old_execute_data = old_execute_data -> prev_execute_data ;
4302
+ }
4266
4303
4267
4304
destroy_op_array (op_array );
4268
4305
efree_size (op_array , sizeof (zend_op_array ));
4269
4306
4270
- return SUCCESS ;
4307
+ if (do_bailout ) {
4308
+ zend_bailout ();
4309
+ }
4310
+
4311
+ return ret ;
4271
4312
}
4272
4313
4273
4314
static int accel_preload (const char * config )
0 commit comments