yii2-debug
yii2-debug copied to clipboard
Improve error reporting for asset bundles
The information available is not enough. For the case i´m going to talk about, it took me a lot of time to debug and required manually update of yii2-debug libraries. Toolbar error tag reported only Serialization of closure is not allowed
, but no clue about which file was generating that. My first attempt was including the file and line to the title tag, but this reports the LogTarget::class
instead the real origin. I finally found the AssetPanel::save()
method, in which i could try assets individually and detect the origin of failure by including a call to serialize within a try/catch block.
Also, the panel did not show any record for an error.
I think that serializations should be checked individually for each assetBundle and prevent stoppping the whole process.
What steps will reproduce the problem?
Create an assetBundle and within registerAssetFiles($view)
method, store the view as a property of that assetBundle public $param
was previously declared. (In my case was view, but you can store any object which includes a closure wichin one of its properties)
What's expected?
Debug panel should work show all assetBundles
What do you get instead?
Serialization of closure is not allowed
as title
of the toolbar tag and the AssetsPanel shows only the previous parsed bundles, without tips to error registered.
Additional info
Q | A |
---|---|
Yii version | 2.0.45 |
PHP version | 8.0.0 |
Yii2-debug | Tested on 2.1.0 and 2.1.19 |
Operating system |