Details
-
Bug
-
Status: Closed
-
Critical
-
Resolution: Fixed
-
2.6
-
MOODLE_26_STABLE
-
MOODLE_26_STABLE
-
w41_
MDL-42040_m26_shutdown -
-
4
-
BACKEND Sprint 5
Description
This issue arrived because, recently I've started to get some "$DB not available" messages when profiling pages, leading to the profiling runs not sent to DB. And I'm pretty sure that it has been working ok since 2.0, until we introduced the new sessions stuff that changed the internal order of those handlers.
So please, avoid arguing things like "it should not be using $DB" and friends (I'm aware of them). It worked and now it does not. Let's try to improve the situation and the future.
Right now the registration of shutdown handlers (register_shutdown_function) is completely chaotic and disorganized, and that can lead to more and more problems where some objects, not available anymore, or disposed by a previous handler are needed later in the chain of shutdowns.
grep -lr register_shutdown_function *
|
So we need some method to organize and force their registration in an ordered way, declaring their needs (DB, logging, whatever) and observing any dependencies between them and also, surely containing references to all the needed used to avoid its auto-disposal by php.
Not sure how to encapsulate all that information (needs, dependencies, disposal) nor how to behave (multiple handlers vs a big one in charge of everything).
But it should be computable, I hope. Ciao