From 3ba197fadd63111f791f3acbd80db1ff75345dc4 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim=20D=C3=BCsterhus?= Date: Wed, 17 Jun 2015 01:33:54 +0200 Subject: [PATCH] Fix output flushing in WCF::destruct() --- .../install/files/lib/system/WCF.class.php | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/wcfsetup/install/files/lib/system/WCF.class.php b/wcfsetup/install/files/lib/system/WCF.class.php index 73d29faab9..63390bf742 100644 --- a/wcfsetup/install/files/lib/system/WCF.class.php +++ b/wcfsetup/install/files/lib/system/WCF.class.php @@ -150,22 +150,24 @@ class WCF { } /** - * Replacement of the "__destruct()" method. - * Seems that under specific conditions (windows) the destructor is not called automatically. - * So we use the php register_shutdown_function to register an own destructor method. - * Flushs the output, closes caches and updates the session. + * Flushes the output, closes the session, performs background tasks and more. + * + * You *must* not create output in here under normal circumstances, as it might get eaten + * when gzip is enabled. */ public static function destruct() { try { // database has to be initialized if (!is_object(self::$dbObj)) return; - // flush output - if (ob_get_level() && ini_get('output_handler')) { - ob_flush(); - } - else { + $debug = self::debugModeIsEnabled(true); + if (!$debug) { + // flush output + if (ob_get_level()) ob_end_flush(); flush(); + + // close connection if using FPM + if (function_exists('fastcgi_finish_request')) fastcgi_finish_request(); } // update session -- 2.20.1