craftcms / cms

Build bespoke content experiences with Craft.
https://craftcms.com
Other
3.28k stars 635 forks source link

[4.x]: Debug bar errors #12010

Closed hassanmah closed 2 years ago

hassanmah commented 2 years ago

What happened?

Description

On some pages, I get errors when using the debug bar on all tabs

On Events and DB

yii\base\ErrorException: Trying to access array offset on value of type null in /deploy/vendor/yiisoft/yii2-debug/src/views/default/panels/request/summary.php:8
Stack trace:
#0 /deploy/vendor/craftcms/cms/src/web/ErrorHandler.php(79): yii\base\ErrorHandler->handleError(2, 'Trying to acces...', '/Users/hassanma...', 8)
#1 /deploy/vendor/yiisoft/yii2-debug/src/views/default/panels/request/summary.php(8): craft\web\ErrorHandler->handleError(2, 'Trying to acces...', '/Users/hassanma...', 8)
#2 /deploy/vendor/yiisoft/yii2/base/View.php(347): require('/Users/hassanma...')
#3 /deploy/vendor/yiisoft/yii2/base/View.php(257): yii\base\View->renderPhpFile('/Users/hassanma...', Array)
#4 /deploy/vendor/yiisoft/yii2/base/View.php(156): yii\base\View->renderFile('/Users/hassanma...', Array, NULL)
#5 /deploy/vendor/yiisoft/yii2-debug/src/panels/RequestPanel.php(43): yii\base\View->render('panels/request/...', Array)
#6 /deploy/vendor/yiisoft/yii2-debug/src/views/default/view.php(26): yii\debug\panels\RequestPanel->getSummary()
#7 /deploy/vendor/yiisoft/yii2/base/View.php(347): require('/Users/hassanma...')
#8 /deploy/vendor/yiisoft/yii2/base/View.php(257): yii\base\View->renderPhpFile('/Users/hassanma...', Array)
#9 /deploy/vendor/yiisoft/yii2/base/View.php(156): yii\base\View->renderFile('/Users/hassanma...', Array, Object(yii\debug\controllers\DefaultController))
#10 /deploy/vendor/yiisoft/yii2/base/Controller.php(407): yii\base\View->render('view', Array, Object(yii\debug\controllers\DefaultController))
#11 /deploy/vendor/yiisoft/yii2-debug/src/controllers/DefaultController.php(126): yii\base\Controller->render('view', Array)
#12 [internal function]: yii\debug\controllers\DefaultController->actionView('63318b520d4ca', 'event')
#13 /deploy/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#14 /deploy/vendor/yiisoft/yii2/base/Controller.php(178): yii\base\InlineAction->runWithParams(Array)
#15 /deploy/vendor/yiisoft/yii2/base/Module.php(552): yii\base\Controller->runAction('view', Array)
#16 /deploy/vendor/craftcms/cms/src/web/Application.php(301): yii\base\Module->runAction('debug/default/v...', Array)
#17 /deploy/vendor/craftcms/cms/src/web/Application.php(625): craft\web\Application->runAction('debug/default/v...', Array)
#18 /deploy/vendor/craftcms/cms/src/web/Application.php(280): craft\web\Application->_processActionRequest(Object(craft\web\Request))
#19 /deploy/vendor/yiisoft/yii2/base/Application.php(384): craft\web\Application->handleRequest(Object(craft\web\Request))
#20 /deploy/public/index.php(12): yii\base\Application->run()
#21 /Users/.composer/vendor/laravel/valet/server.php(234): require('/Users/hassanma...')
#22 {main}

On Request:


TypeError: Cannot assign yii\debug\FlattenException to property craft\events\ExceptionEvent::$exception of type Throwable in /deploy/vendor/yiisoft/yii2/BaseYii.php:558
Stack trace:
#0 /deploy/vendor/yiisoft/yii2/base/BaseObject.php(107): yii\BaseYii::configure(Object(craft\events\ExceptionEvent), Array)
#1 /deploy/vendor/craftcms/cms/src/web/ErrorHandler.php(49): yii\base\BaseObject->__construct(Array)
#2 /deploy/vendor/yiisoft/yii2-debug/src/controllers/DefaultController.php(118): craft\web\ErrorHandler->handleException(Object(yii\debug\FlattenException))
#3 [internal function]: yii\debug\controllers\DefaultController->actionView('63318b520d4ca', 'request')
#4 /deploy/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#5 /deploy/vendor/yiisoft/yii2/base/Controller.php(178): yii\base\InlineAction->runWithParams(Array)
#6 /deploy/vendor/yiisoft/yii2/base/Module.php(552): yii\base\Controller->runAction('view', Array)
#7 /deploy/vendor/craftcms/cms/src/web/Application.php(301): yii\base\Module->runAction('debug/default/v...', Array)
#8 /deploy/vendor/craftcms/cms/src/web/Application.php(625): craft\web\Application->runAction('debug/default/v...', Array)
#9 /deploy/vendor/craftcms/cms/src/web/Application.php(280): craft\web\Application->_processActionRequest(Object(craft\web\Request))
#10 /deploy/vendor/yiisoft/yii2/base/Application.php(384): craft\web\Application->handleRequest(Object(craft\web\Request))
#11 /deploy/public/index.php(12): yii\base\Application->run()
#12 /Users/.composer/vendor/laravel/valet/server.php(234): require('/Users/hassanma...')
#13 {main}

Steps to reproduce

  1. Open debug bar

Expected behavior

Actual behavior

Craft CMS version

4.2.5.1

PHP version

No response

Operating system and version

No response

Database type and version

No response

Image driver and version

No response

Installed plugins and versions

-

brianjhanson commented 2 years ago

What are you rending on the pages when you get this error? Any chance there's a twig error on those pages?

angrybrad commented 2 years ago

Probably a Yii2 issue? https://github.com/yiisoft/yii2-debug/issues/491

hassanmah commented 2 years ago

@brianjhanson just a Neo field

daafbleumink commented 2 years ago

I've got the exact same issue, but then with SuperTable. I also tried debugging it, but it's very difficult to pinpoint. Commented out all renderings and simply looping over the matrix field gave me the error.

brianjhanson commented 2 years ago

Thanks for the info! I happened to run into this while working on a totally separate ticket, but also wasn't able to completely track it down. I was using a Vizy field and it seemed to be somewhat related to referencing a handle that wasn't present on a block type. I'd see a totally blank page (no errors in the logs) and the debug bar would show the same errors.

It seems like all of us are using more "complex" fields (Neo, Super Table, Vizy) so I wonder if it has something to do with that. I'll dig around a bit more, but I have a feeling @angrybrad is right and this is better fixed in Yii2.

daafbleumink commented 2 years ago

I kind of figured it out for me. I'm using the Typed Link Field plugin. If I remove all of the instances of that field from my Matrix Field the error disappears. After re-adding the Typed Link fields one by one the error didn't return. Bit of a weird bug, but I think I had some misconfiguration in one of the Typed Link fields...

I found the error by trying to clone the Matrix Field that gave me the error using the Field Manager plugin. I wanted to clone it to see if "just a new instance" of the Matrix Field would solve the issue. But I ran into an error that pointed me to the Typed Link field instead.

brianjhanson commented 2 years ago

I'm still having trouble replicating this consistently. If anyone has some consistent steps to reproduce that would be great.

Based on the stack trace it looks like in some situations an instance of ExceptionEvent is getting created with an instance of yii\debug\FlattenException which isn't compatible with the $exception property there. I'm guessing this has something to do with a plugin, but I've had trouble replicating it consistently.

daafbleumink commented 2 years ago

The fix was way easier for me than I initially thought ... I had a custom module that wasn't up to date with Craft's coding guidelines. After fixing the module everything worked fine again 😅 Do you have any custom modules/plugins? @hassanmah

brianjhanson commented 2 years ago

Glad you got it sorted out! I'm going to close this for now, but @hassanmah feel free to reopen if you're still running into issues.

hassanmah commented 1 year ago

@daafbleumink sorry for the reply, I do have a custom module, which I deletes the folder for, but seems like it's still in composer.json

Do I need to run anything to remove it from composer.json?

Thanks

brianjhanson commented 1 year ago

@hassanmah If you're deleting the module, you'll want to manually remove the autoload config for your module from composer.json and then run composer dump-autoload -a.

daafbleumink commented 1 year ago

@hassanmah I think manually removing the entry from your composer.json, then running composer install + composer dump-autoload should work 🤔

hassanmah commented 1 year ago

@daafbleumink that's not fixed it, but looking at the comments, I do have Typed Link Field plugin installed too.

davidwebca commented 1 year ago

I had this issue lately and I couldn't figure it out. I had used Typed Link Field before but since had migrated to Hyper from verbb and removed it. I also have a module, but it was existing prior to the issue.

The thing that fixed it is restoring an old (but unused since 2 weeks ago) route in config/route.php. It was pointing to a controller in the module, but the route and controller were removed since a while ago. Restoring the route, refreshing the page, it worked... then I could remove the route again and it continued to work. Why the hell? I have no idea. 😂 It's as if an old cache pointing the route and controller together were failing when I was trying to access routes from debugbar...