If you add a File or Image widget, and then delete the underlying file (via file_delete(file_load($fid))), then there will be PHP notices when rendering the widget.
Since those widgets really don't make any sense without the file, they should just not get rendered at all!
In fact, any widget with a required file field should have the same behavior: the widget would never have succeeded in being created without a file, so, not that the file is missing, it shouldn't try to render it.
Patch coming soon!
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | panopoly_widgets-missing-required-file-fields-2952671-2.patch | 2.61 KB | dsnopek |
Comments
Comment #2
dsnopekThis patch works in my testing! Looking forward to trying the automated tests..
EDIT: Here's a build on Travis: https://travis-ci.org/panopoly/panopoly/builds/353022180
Comment #3
cboyden commentedThe patch is working as expected for Add Image widgets. The pane is not rendered on the public view of the page. In the IPE, you see the widget with the empty/placeholder message.
But, on Add File widgets, the file field is not required. So the new hook doesn't fire, and you see PHP notices. Should the file field be required on Add File widgets?
Comment #4
dsnopekAh, yes, it should be required!
I just found an existing issue about this:
#2505357: Widgets can be saved without any content
... but it's postponed on fixing some multilingual bug. :-/ This are all pretty old bugs, so possibly that's not even a thing anymore - need to check
Comment #6
dsnopekMerged #2505357: Widgets can be saved without any content and @cboyden ran a test build there which included this patch, so... merged this one too!