From 771ff151331f81f77b05966e102e7ae82f4792d7 Mon Sep 17 00:00:00 2001 From: Klimov Paul Date: Fri, 24 Apr 2015 17:04:57 +0300 Subject: [PATCH] Fixed `yii\log\Logger` unable to export session id close #8174 fixes #8036 --- framework/CHANGELOG.md | 1 + framework/log/Logger.php | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/framework/CHANGELOG.md b/framework/CHANGELOG.md index 027829a317..ef052f4f56 100644 --- a/framework/CHANGELOG.md +++ b/framework/CHANGELOG.md @@ -27,6 +27,7 @@ Yii Framework 2 Change Log - Bug #8012: Fixed fetching multiple relations between two tables for pgsql (nineinchnick) - Bug #8014: Fixed setting incorrect form "action" property after submitting a form using a link with "data-method" and containing "action" among "data-params" (samdark) - Bug #8032: `yii\rbac\PhpManager::updateItem()` was unable to rename item updated (ChristopheBrun, samdark) +- Bug #8036: Fixed `yii\log\Logger` unable to export session id (klimov-paul) - Bug #8068: Fixed `yii\db\Query::count()` fails for query containing 'having' without 'group by' (klimov-paul) - Bug #8073: Fixed `yii\data\ArrayDataProvider::getKeys()` return wrong when `yii\data\ArrayDataProvider::$allModels` contain integer key (mdmunir, klimov-paul) - Bug #8082: Fixed `yii\db\BaseActiveRecord::getAttributeLabel()` return wrong label for related attribute, if several relations in chain share same name (klimov-paul) diff --git a/framework/log/Logger.php b/framework/log/Logger.php index a6ef2ae671..107d90d110 100644 --- a/framework/log/Logger.php +++ b/framework/log/Logger.php @@ -116,7 +116,10 @@ class Logger extends Component { parent::init(); register_shutdown_function(function () { - // make sure "flush()" is called last when there are multiple shutdown functions + // make regular flush before other shutdown functions, which allows session data collection and so on + $this->flush(); + // make sure log entries written by shutdown functions are also flushed + // ensure "flush()" is called last when there are multiple shutdown functions register_shutdown_function([$this, 'flush'], true); }); }