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!

Comments

dsnopek created an issue. See original summary.

dsnopek’s picture

Status: Active » Needs review
StatusFileSize
new2.61 KB

This 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

cboyden’s picture

The 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?

dsnopek’s picture

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?

Ah, 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

  • dsnopek committed 51be29a on 7.x-1.x
    Update Panopoly Widgets for Issue #2952671 by dsnopek, cboyden: File and...
dsnopek’s picture

Status: Needs review » Fixed

Merged #2505357: Widgets can be saved without any content and @cboyden ran a test build there which included this patch, so... merged this one too!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.