plone / Products.CMFPlone

The core of the Plone content management system
https://plone.org
GNU General Public License v2.0
254 stars 191 forks source link

@@personal-information breaks after portrait was uploaded in Plone 5.1.5 #2709

Closed pgrunewald closed 5 years ago

pgrunewald commented 5 years ago

BUG/PROBLEM REPORT (OR OTHER COMMON ISSUE)

What I did:

  1. Go to: http://localhost:8080/Plone/@@personal-information
  2. Choose an image for the portrait field and save
  3. Go To @@personal-information again and click save.

What I expect to happen:

Forms should submit successfully.

What actually happened:

Form breaks with this stacktrace:

Traceback (innermost last):

Module ZPublisher.Publish, line 138, in publish
Module ZPublisher.mapply, line 77, in mapply
Module Products.PDBDebugMode.runcall, line 70, in pdb_runcall
Module ZPublisher.Publish, line 48, in call_object
Module plone.app.users.browser.userdatapanel, line 94, in __call__
Module z3c.form.form, line 233, in __call__
Module plone.z3cform.fieldsets.extensible, line 65, in update
Module plone.z3cform.patch, line 30, in GroupForm_update
Module z3c.form.group, line 132, in update
Module z3c.form.form, line 136, in updateWidgets
Module z3c.form.field, line 277, in update
Module z3c.form.browser.text, line 36, in update
Module z3c.form.browser.widget, line 171, in update
Module Products.CMFPlone.patches.z3c_form, line 47, in _wrapped
Module z3c.form.widget, line 88, in update
Module plone.formwidget.namedfile.widget, line 276, in extract
Module plone.namedfile.utils, line 42, in safe_basename
AttributeError: 'NoneType' object has no attribute 'rfind'

When choosing the different or same image to upload, the form works just fine. But if portrait is left changed, the error comes again.

What version of Plone/ Addons I am using:

Vanilla Plone 5.1.5

Note: It works however in Plone 5.1.2!

pbauer commented 5 years ago

The problem was introduced in https://github.com/plone/plone.formwidget.namedfile/pull/32 where the case that the filename is None is not handled.

pbauer commented 5 years ago

Also currently it seems that the upload_map (IFileUploadTemporaryStorage) always keeps a reference to the previously stored value. Even after restarting the instance and even after del upload_map[file_upload_id] has run. So the code always attempts to create the file anew. Confirmed in Plone 5.2 master with Python 2.7 @thet: can you please comment on that, since you added the mentioned changes.

pbauer commented 5 years ago

@thet ping

mauritsvanrees commented 5 years ago

Fixed in https://github.com/plone/plone.formwidget.namedfile/pull/38