mirror of
https://github.com/yiisoft/yii2.git
synced 2025-08-26 14:26:54 +08:00
Fix #18328: Raise warning when trying to register a file after View::endBody()
has been called
This commit is contained in:

committed by
GitHub

parent
6fdba043d7
commit
b757d25c4b
@ -4,6 +4,7 @@ Yii Framework 2 Change Log
|
||||
2.0.44 under development
|
||||
------------------------
|
||||
|
||||
- Enh #18328: Raise warning when trying to register a file after `View::endBody()` has been called (perlexed)
|
||||
- Enh #18812: Added error messages and optimized "error" methods in `yii\helpers\BaseJson` (WinterSilence, samdark)
|
||||
- Chg #18823: Rollback changes #18806 in `yii\validators\ExistValidator::checkTargetRelationExistence()` (WinterSilence)
|
||||
- Enh #18826: Add ability to turn the sorting off for a clicked column in GridView with multisort (ditibal)
|
||||
|
@ -133,6 +133,12 @@ class View extends \yii\base\View
|
||||
|
||||
private $_assetManager;
|
||||
|
||||
/**
|
||||
* Whether [[endBody()]] has been called
|
||||
* @var bool
|
||||
*/
|
||||
private $_isBodyEnded = false;
|
||||
|
||||
|
||||
/**
|
||||
* Marks the position of an HTML head section.
|
||||
@ -159,6 +165,8 @@ class View extends \yii\base\View
|
||||
$this->trigger(self::EVENT_END_BODY);
|
||||
echo self::PH_BODY_END;
|
||||
|
||||
$this->_isBodyEnded = true;
|
||||
|
||||
foreach (array_keys($this->assetBundles) as $bundle) {
|
||||
$this->registerAssetFiles($bundle);
|
||||
}
|
||||
@ -490,6 +498,10 @@ class View extends \yii\base\View
|
||||
}
|
||||
$appendTimestamp = ArrayHelper::remove($options, 'appendTimestamp', $assetManagerAppendTimestamp);
|
||||
|
||||
if ($this->_isBodyEnded) {
|
||||
Yii::warning('You\'re trying to register a file after View::endBody() has been called');
|
||||
}
|
||||
|
||||
if (empty($depends)) {
|
||||
// register directly without AssetManager
|
||||
if ($appendTimestamp && Url::isRelative($url)) {
|
||||
|
Reference in New Issue
Block a user