diff --git a/framework/CHANGELOG.md b/framework/CHANGELOG.md index f407b2c345..4a9a561115 100644 --- a/framework/CHANGELOG.md +++ b/framework/CHANGELOG.md @@ -25,6 +25,7 @@ Yii Framework 2 Change Log - Bug #11026: Fixed `StringHelper::truncateWords()` to count words properly for non-English text (samdark, tol17) - Bug #11040: Check parameter 'recursive' and disable recursive copying with option 'recursive' => false in method BaseFileHelper::copyDirectory (Ni-san) - Bug #11125: Fixed `JSON_ERROR_SYNTAX` for `json_decode(null)` in PHP 7 (fps01) +- Bug #11132: Fixed `yii\widgets\FragmentCache` not handling empty content correctly in all cases (kidol) - Bug #11188: Fixed wrong index usage in `CaptchaAction` when calling `imagefilledrectangle` (alsopub) - Bug #11220: NumberValidator now handles objects properly (samdark) - Bug #11221: Boolean validator generates incorrect error message (azaikin, githubjeka) diff --git a/framework/widgets/FragmentCache.php b/framework/widgets/FragmentCache.php index e81f5b8c29..d9e4fe6af2 100644 --- a/framework/widgets/FragmentCache.php +++ b/framework/widgets/FragmentCache.php @@ -104,11 +104,12 @@ class FragmentCache extends Widget if (($content = $this->getCachedContent()) !== false) { echo $content; } elseif ($this->cache instanceof Cache) { + array_pop($this->getView()->cacheStack); + $content = ob_get_clean(); if ($content === false || $content === '') { return; } - array_pop($this->getView()->cacheStack); if (is_array($this->dependency)) { $this->dependency = Yii::createObject($this->dependency); }