From: Tim Düsterhus Date: Tue, 16 Jun 2015 23:33:54 +0000 (+0200) Subject: Fix output flushing in WCF::destruct() X-Git-Tag: 3.0.0_Beta_1~2249^2~11 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=3ba197fadd63111f791f3acbd80db1ff75345dc4;p=GitHub%2FWoltLab%2FWCF.git Fix output flushing in WCF::destruct() --- 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