From 191fa7c0c1326b0261010800d423ef85b2d4bfbc Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Tue, 16 Feb 2016 11:12:01 +0900 Subject: [PATCH] Call common.flushDebugInfo automatically on shutdown --- classes/context/Context.class.php | 20 +++++++++++++++++--- classes/display/DisplayHandler.class.php | 2 +- classes/module/ModuleHandler.class.php | 1 - index.php | 2 -- 4 files changed, 18 insertions(+), 7 deletions(-) diff --git a/classes/context/Context.class.php b/classes/context/Context.class.php index c5451e817..c34554ada 100644 --- a/classes/context/Context.class.php +++ b/classes/context/Context.class.php @@ -331,9 +331,9 @@ class Context { ob_start(); $this->setCacheControl(-1, true); - register_shutdown_function(array($this, 'checkSessionStatus')); $_SESSION = array(); } + register_shutdown_function('Context::close'); // set authentication information in Context and session if(self::isInstalled()) @@ -411,7 +411,7 @@ class Context { if(self::getSessionStatus()) { - return; + return true; } if($force_start || (count($_SESSION) && !headers_sent())) { @@ -419,7 +419,9 @@ class Context unset($_SESSION); session_start(); $_SESSION = $tempSession; + return true; } + return false; } /** @@ -429,7 +431,19 @@ class Context */ public static function close() { - session_write_close(); + // Flush the slow query/trigger/widget log. + static $flushed = false; + if (!$flushed && config('debug.enabled')) + { + ModuleHandler::triggerCall('common.flushDebugInfo', 'after', new stdClass); + $flushed = true; + } + + // Check session status and close it if open. + if (self::checkSessionStatus()) + { + session_write_close(); + } } /** diff --git a/classes/display/DisplayHandler.class.php b/classes/display/DisplayHandler.class.php index 80026a860..ba48d6dc7 100644 --- a/classes/display/DisplayHandler.class.php +++ b/classes/display/DisplayHandler.class.php @@ -78,7 +78,7 @@ class DisplayHandler extends Handler } // Start the session if $_SESSION was touched - Context::getInstance()->checkSessionStatus(); + Context::checkSessionStatus(); // header output $httpStatusCode = $oModule->getHttpStatusCode(); diff --git a/classes/module/ModuleHandler.class.php b/classes/module/ModuleHandler.class.php index 80b565d9e..fb7449c83 100644 --- a/classes/module/ModuleHandler.class.php +++ b/classes/module/ModuleHandler.class.php @@ -884,7 +884,6 @@ class ModuleHandler extends Handler if($_SESSION['XE_VALIDATOR_RETURN_URL']) { - Context::getInstance()->checkSessionStatus(); header('location:' . $_SESSION['XE_VALIDATOR_RETURN_URL']); return; } diff --git a/index.php b/index.php index 6fda48144..bb7000fb1 100644 --- a/index.php +++ b/index.php @@ -59,7 +59,5 @@ if($oContext->checkSSO()) } } -$oContext->close(); - /* End of file index.php */ /* Location: ./index.php */