public static function Shutdown() { /* * Break out of this function if we do not need to run it. * This is important when we are not in AJAX mode and the * user is not looking at OnePanel * */ if (!OnePanelLib::InConsole()) { return true; } /* * TODO * Ive got a feeling that printing <script> tags outside the html tags is a bad idea * perhaps this function should only be used as a last ditch attempt to scrape data in * the case of a fatal php error and another shutdown function should be run after the * plugin has completed whatever hook is being called. * */ // Discern whether a fatal error occured TODO handle non fatals $last_error = error_get_last(); if ($last_error['type'] === E_ERROR || $last_error['type'] === E_USER_ERROR || $last_error['type'] === E_COMPILE_ERROR || $last_error['type'] === E_CORE_ERROR || $last_error['type'] === E_RECOVERABLE_ERROR) { // Fail the last entry self::FailIncompleteTrackers(); // Store the log if necessary // Stop the clock self::$finish_time = microtime(true); // Record memory usage self::$finish_mu = memory_get_usage(); // Output the apppropriate data depending on running environment (AJAX or normal) echo self::GetRawOutput(); } else { // Stop the clock self::$finish_time = microtime(true); // Record memory usage self::$finish_mu = memory_get_usage(); // Script completed. Send the jacascript to populate the error console if (!OnePanelLib::InAjaxMode()) { echo self::GetOutput(); // TODO, devise a strategy to append the return ajax data with the error console data. } } return true; }