Index: branches/5.2.x/core/kernel/application.php =================================================================== diff -u -N -r15445 -r15456 --- branches/5.2.x/core/kernel/application.php (.../application.php) (revision 15445) +++ branches/5.2.x/core/kernel/application.php (.../application.php) (revision 15456) @@ -1,6 +1,6 @@ isDebugMode(); - if ( $debug_mode && kUtil::constOn('DBG_PROFILE_MEMORY') ) { - $this->Debugger->appendMemoryUsage('Application before Done:'); - } - if ( $debug_mode ) { - $this->EventManager->runScheduledTasks(); - $this->Session->SaveData(); + if ( kUtil::constOn('DBG_PROFILE_MEMORY') ) { + $this->Debugger->appendMemoryUsage('Application before Done:'); + } + $this->Session->SaveData(); // adds session data to debugger report $this->HTML = ob_get_clean() . $this->HTML . $this->Debugger->printReport(true); } else { // send "Set-Cookie" header before any output is made $this->Session->SetSession(); - $this->HTML = ob_get_clean() . $this->HTML; } + $this->_outputPage(); + $this->cacheManager->UpdateApplicationCache(); + + if ( !$debug_mode ) { + $this->Session->SaveData(); + } + + $this->EventManager->runScheduledTasks(); + + if ( defined('DBG_CAPTURE_STATISTICS') && DBG_CAPTURE_STATISTICS && !$this->isAdmin ) { + $this->_storeStatistics(); + } + } + + /** + * Outputs generated page content to end-user + * + * @return void + * @access protected + */ + protected function _outputPage() + { $this->setContentType(); if ( $this->UseOutputCompression() ) { @@ -1197,17 +1216,7 @@ echo $this->HTML; } - $this->cacheManager->UpdateApplicationCache(); flush(); - - if ( !$debug_mode ) { - $this->EventManager->runScheduledTasks(); - $this->Session->SaveData(); - } - - if ( defined('DBG_CAPTURE_STATISTICS') && DBG_CAPTURE_STATISTICS && !$this->isAdmin ) { - $this->_storeStatistics(); - } } /**