Apologies if I am being stupid here but I can't see how to fix this. It seems file fields in new Panopoly widgets are set by default to be pre-populated with a file, and if they are not (e.g. if the file in question is no longer available) a rogue entry is made in the database. This can only be done once, so all subsequent attempts to add a new widget of that type run up against database errors.

Steps to replicate bug:
0. Start with a fresh install of a Panopoly distro including the Panopoly demo module.
1. Manage fields for a Panopoly widget at /admin/structure/fieldable-panels-panes
2. Add an existing field - choose "File: field_basic_file_file (File)".
3. Save settings for that field, and save the widget settings.
4. Editing a page, add a new widget, choosing to add the type of widget you just edited.
5. Observe that the File field comes pre-populated with an existing file that comes as part of the Panopoly demo.
6. At /admin/content/file delete the file that was being used to pre-populate the File field.
7. Now repeat step 4.
8. Observe that the File field is now empty and just has Browse/Upload buttons (or 'Add' if you set the field to allow multiple values).
9. Observe that there is now an entry in the {file_managed} table which has a zero filesize and empty values for filename and uri. (BUG!)
10. Cancel the adding of that widget (or save it, it doesn't matter).
11. Now try to add a new widget to a page, and again select the same type of widget.
12. Observe that the following error message appears in the overlay (BUG!):

An AJAX HTTP error occurred.
HTTP Result Code: 500
Debugging information follows.
Path: /panels/ajax/ipe/add-pane/panel_context%3Apage-panopoly_demo_panel%3Apage_panopoly_demo_panel_panel_context/contentmain/fieldable_panels_pane/image
StatusText: Service unavailable (with message)
ResponseText: PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '' for key 'uri': INSERT INTO {file_managed} (filemime, filesize, status, timestamp, type, uuid) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5); Array
[:db_insert_placeholder_0] => application/octet-stream
[:db_insert_placeholder_1] => 0
[:db_insert_placeholder_2] => 1
[:db_insert_placeholder_3] => 1365673743
[:db_insert_placeholder_4] => undefined
[:db_insert_placeholder_5] => 7bf938ad-c95d-49ba-b52f-064fb1097438
in drupal_write_record() (line 7136 of /home/mq/KM/www/wf1/includes/common.inc).

As I say, I have a sneaking suspicion that I am missing something obvious, but after a couple of days pondering this I've got no further. Before I dive into trying to debug code I've never looked at before, I thought I'd post this to see if someone else has an idea what is wrong.

Please feel free to move this issue if it's not Panopoly's fault. Thanks in advance for any help/pointers to help.


populist’s picture

Status:Active» Fixed

Thanks so much for this very detailed bug report! I went through with the latest -dev release and followed your steps but luckily did not get an errror!

My feeling is that the latest changes in the dev including (a) removing default content and (b) updating the FPP and Panels modules probably fixed this error for you. I am closing as fixed since it should work in the latest -dev and will in the upcoming RC4!

martin_q’s picture

Status:Fixed» Closed (fixed)

Thank you - yes I can confirm it is fixed!