From 3ddeeebc93d5a3c7b9683e5d167e6a926d2132b8 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Wed, 29 Jul 2015 12:37:06 +0000 Subject: [PATCH] * Nginx/FastCGI: run shutdown callbacks (eg. link notification processing) after sending response to user was broken since some time, because a not closed session kept it from working --> we are now run all callbacks containing "session" it there name, closing session, calling fastcgi_finish_request() and then run rest of the callbacks --- phpgwapi/inc/class.egw.inc.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/phpgwapi/inc/class.egw.inc.php b/phpgwapi/inc/class.egw.inc.php index 22f20f3b20..77c2f220d1 100644 --- a/phpgwapi/inc/class.egw.inc.php +++ b/phpgwapi/inc/class.egw.inc.php @@ -575,6 +575,24 @@ class egw extends egw_minimal egw_json_response::sendResult(); } + // run all on_shutdown callbacks with session in their name (eg. egw_link::save_session_cache), do NOT stop on exceptions + foreach(self::$shutdown_callbacks as $n => $data) + { + try { + //error_log(__METHOD__."() running ".array2string($data)); + $callback = array_shift($data); + if (!is_array($callback) || strpos($callback[1], 'session') === false) continue; + call_user_func_array($callback, $data); + } + catch (Exception $ex) { + _egw_log_exception($ex); + } + unset(self::$shutdown_callbacks[$n]); + } + // now we can close the session + // without closing the session fastcgi_finish_request() will NOT send output to user + $GLOBALS['egw']->session->commit_session(); + // flush all output to user /* does NOT work on Apache :-( for($i = 0; ob_get_level() && $i < 10; ++$i)