PHP widget with syntax error brings down site
Bug report
Summary
A PHP-type widget with a syntax error causes 500 error and blank screen for entire site.
Step to reproduce
Create a PHP-type widget with this code:
<?php
return "Hello World;"
Reload page.
Observed behavior
xxxxxx.modx.dev is currently unable to handle this request. HTTP ERROR 500
Nothing in error log.
Expected behavior
Clearer error.
This may be unavoidable, but the effect seems unnecessarily catastrophic.
On initial visit to the site, you don't even see the login screen. The 500 hundred error shows up immediately. I didn't expect that the widget code would be "included" before the login screen was rendered. That seems unnecessary.
Environment
MODX Cloud, but I think any install.
In case someone runs into this, the only solutions are to either edit the widget code in the DB, or remove any placement records for that widget.
Hey @BobRay, yeah, this seems to be an unfortunate issue with the Dashboard main view and how things load/work in this view. We've seen this over the years with a variety of Dashboard widgets either with straight up coding errors or PHP version changes removing obsolete functions and causing fatal errors that way. I don't know if it's really worth trying to solve or not. At the very least people building widgets where they rely on third-party code or API endpoints should have appropriate timeouts/error state handling.
I should note, it's not absolutely required to edit the db directly. The widget only kills the main dashboard view. The general workaround is to go to any other valid path in the manager such as: /manager/?a=system/dashboards or /manager/?a=element/template/update&id=1 which will allow the Manager to load and then you have access to the navigation of the Manager. Then you can either go to the file manager to edit the widget code or you can go to the Dashboard and remove the widget.
FYI, 3.2.0-dev handles this more gracefully — you get a stack trace within the body of the bad widget. It's ugly, but doesn't affect the rest of the UI.
Sounds good enough. Closing.