Run shutdown handlers before running request-exit cleanup

Shutdown handlers can run user code (e.g. the session stuff serializes
the session and can pass the serialized blob to user code to do
something with), so it's generally not safe to run them after
requestExit(). In particular, requestExit destroys global variables, and
the session serializer reads $_SESSION.

My recent diff to get rid of the hardcoded globals exposed this, though
I argue this situation was incorrect all along.
Esse commit está contido em:
Owen Yamauchi
2013-06-19 10:14:02 -07:00
commit de Sara Golemon
commit 35fafe5545
+4 -1
Ver Arquivo
@@ -1406,11 +1406,14 @@ void hphp_context_exit(ExecutionContext *context, bool psp,
Eval::Debugger::InterruptPSPEnded(program);
} catch (const Eval::DebuggerException &e) {}
}
context->requestExit();
// Run shutdown handlers. This may cause user code to run.
if (shutdown) {
context->onRequestShutdown();
}
// Clean up a bunch of request state. No user code after this point.
context->requestExit();
context->obProtect(false);
context->obEndAll();
}