revolution icon indicating copy to clipboard operation
revolution copied to clipboard

PHP widget with syntax error brings down site

Open BobRay opened this issue 7 months ago • 2 comments

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.

BobRay avatar May 02 '25 22:05 BobRay

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.

BobRay avatar May 02 '25 22:05 BobRay

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.

jaygilmore avatar May 30 '25 13:05 jaygilmore

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.

smg6511 avatar Nov 21 '25 06:11 smg6511

Sounds good enough. Closing.

BobRay avatar Nov 21 '25 16:11 BobRay