Register Shutdown Function not Working in Magento + Solution

I am currently putting together an automated system that converts user input within Magento.

As this runs using cron, I will be unable to see if anything goes wrong, unless the errors are logged.

Now it is possible to set custom error and exception handlers that will log most things, but I needed to cover all bases and try to log in the event of a fatal error.

It is possible to do this by calling register_shutdown_function and checking for an error there - see here for a full explanation on how to do this.

The problem I had was that this would not work within Magento. After a lot of going through the code it appears that if you have developer mode set to true, then your function will not be called. Once it is disabled the function works as expected.


Tags: developmentphpproblemsolutiondebuggingtip