- if (psi_context_compile(C) && SUCCESS != zend_register_functions(NULL, C->closures, NULL, MODULE_PERSISTENT)) {
- C->error(PSI_DATA(C), NULL, PSI_WARNING, "Failed to register functions!");
+ if (psi_context_compile(C)) {
+ /* zend_register_functions depends on EG(current_module) pointing into module */
+ EG(current_module) = zend_hash_str_find_ptr(&module_registry, "psi", sizeof("psi") - 1);
+ if (SUCCESS != zend_register_functions(NULL, C->closures, NULL, MODULE_PERSISTENT)) {
+ C->error(PSI_DATA(C), NULL, PSI_WARNING, "Failed to register functions!");
+ }
+ EG(current_module) = NULL;