yii2-debug
yii2-debug copied to clipboard
Don't render application error pages
What steps will reproduce the problem?
- Have an dependency with a broken asset bundle that is fixed via config
- Create an error in the debug toolbar (for example, delete debug data)
What's expected?
The toolbar should work, indicating that it cannot find the data.
What do you get instead?
The debug module tries to render the application error page, which fails because the asset bundles are not configured correctly.
Thanks for posting in our issue tracker. In order to properly assist you, we need additional information:
- When does the issue occur?
- What do you see?
- What was the expected result?
- Can you supply us with a stacktrace? (optional)
- Do you have exact code to reproduce it? Maybe a PHPUnit tests that fails? (optional)
Thanks!
This is an automated comment, triggered by adding the label status:need more info
.
@samdark what's unclear about my description?
Consider this asset bundle:
class BadBundle extends AssetBundle {
public $sourcePath = '/';
public $css = [
'abc'
];
public publish(AssetManager $am) {
if (!empty($this->css)) {
throw new \Exception('noo');
}
}
}
The above bundle will kill the application when included (it is used to simulate a third party bundle that I have no control over, that contains a bad path for example).
I can override it in config
'components' => [
'assetManager' => [
'bundles' => [
BadBundle::class => [
'css' => []
]
]
]
]
Now when I go to an invalid tag: https://local.test/debug/default/view?tag=x&panel=log
The debug module then throws an exception which causes the application to attempt to render an error page without the bundle configuration (the debug module resets all bundle overrides).
An Error occurred while handling another error:
yii\base\InvalidArgumentException: The file or directory to be published does not exist: /project/src/../vendor/bower-asset/font-awesome/web-fonts-with-css in /project/vendor/yiisoft/yii2/web/AssetManager.php:455
Stack trace:
#0 /project/vendor/yiisoft/yii2/web/AssetBundle.php(185): yii\web\AssetManager->publish('/project/src/.....', Array)
#1 /project/vendor/yiisoft/yii2/web/AssetManager.php(266): yii\web\AssetBundle->publish(Object(SamIT\Yii2\StaticAssets\ReadOnlyAssetManager))
#2 /project/vendor/yiisoft/yii2/web/AssetManager.php(237): yii\web\AssetManager->loadBundle('rmrevin\\yii\\fon...', Array, true)
#3 /project/vendor/yiisoft/yii2/web/View.php(286): yii\web\AssetManager->getBundle('rmrevin\\yii\\fon...')
#4 /project/vendor/yiisoft/yii2/web/View.php(291): yii\web\View->registerAssetBundle('rmrevin\\yii\\fon...', NULL)
#5 /project/vendor/yiisoft/yii2/web/View.php(291): yii\web\View->registerAssetBundle('yiister\\gentele...', NULL)
#6 /project/vendor/yiisoft/yii2/web/View.php(291): yii\web\View->registerAssetBundle('yiister\\gentele...', NULL)
#7 /project/src/views/layouts/main.php(9): yii\web\View->registerAssetBundle('collecthor\\bund...')
#8 /project/vendor/yiisoft/yii2/base/View.php(348): require('/project/src/vi...')
#9 /project/vendor/yiisoft/yii2/base/View.php(257): yii\base\View->renderPhpFile('/project/src/vi...', Array)
#10 /project/vendor/yiisoft/yii2/base/Controller.php(399): yii\base\View->renderFile('/project/src/vi...', Array, Object(collecthor\controllers\SiteController))
#11 /project/vendor/yiisoft/yii2/base/Controller.php(385): yii\base\Controller->renderContent('\n<div class="co...')
#12 /project/vendor/yiisoft/yii2/web/ErrorAction.php(139): yii\base\Controller->render('/global/error', Array)
#13 /project/vendor/yiisoft/yii2/web/ErrorAction.php(118): yii\web\ErrorAction->renderHtmlResponse()
#14 /project/src/actions/ErrorAction.php(36): yii\web\ErrorAction->run()
#15 [internal function]: collecthor\actions\ErrorAction->run()
#16 /project/vendor/yiisoft/yii2/base/Action.php(94): call_user_func_array(Array, Array)
#17 /project/vendor/yiisoft/yii2/base/Controller.php(157): yii\base\Action->runWithParams(Array)
#18 /project/src/controllers/Controller.php(19): yii\base\Controller->runAction('error', Array)
#19 /project/vendor/yiisoft/yii2/base/Module.php(528): collecthor\controllers\Controller->runAction('error', Array)
#20 /project/vendor/yiisoft/yii2/web/ErrorHandler.php(108): yii\base\Module->runAction('/site/error')
#21 /project/vendor/yiisoft/yii2/base/ErrorHandler.php(111): yii\web\ErrorHandler->renderException(Object(yii\web\NotFoundHttpException))
#22 [internal function]: yii\base\ErrorHandler->handleException(Object(yii\web\NotFoundHttpException))
#23 {main}
Previous exception:
yii\web\NotFoundHttpException: Unable to find debug data tagged with 'x'. in /project/vendor/yiisoft/yii2-debug/src/controllers/DefaultController.php:224
Stack trace:
#0 /project/vendor/yiisoft/yii2-debug/src/controllers/DefaultController.php(105): yii\debug\controllers\DefaultController->loadData('x')
#1 [internal function]: yii\debug\controllers\DefaultController->actionView('x', 'log')
#2 /project/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#3 /project/vendor/yiisoft/yii2/base/Controller.php(157): yii\base\InlineAction->runWithParams(Array)
#4 /project/vendor/yiisoft/yii2/base/Module.php(528): yii\base\Controller->runAction('view', Array)
#5 /project/vendor/yiisoft/yii2/web/Application.php(103): yii\base\Module->runAction('debug/default/v...', Array)
#6 /project/vendor/yiisoft/yii2/base/Application.php(386): yii\web\Application->handleRequest(Object(yii\web\Request))
#7 /project/src/entry.php(27): yii\base\Application->run()
#8 {main}