Closed mauritsvanrees closed 3 years ago
Long comment. Summary is at the end.
The site for which I originally reported this problem, now has a related problem that is caused by my PR. After the upgrade, the site logo disappears.
After some tests, I see that this is specific for this site, because I copied the code of my PR to a custom package and ran it, and now it goes wrong when I update to Plone 5.2.3. But I see ways where others may get the same problem. Also: editing the logo via the portal_registry no longer works.
Let's see if I can reproduce this in core Plone.
plone.formwidget.namedfile
while rendering the logo. You also then get the same ValueError when you go to the site-controlpanel, so you can no longer fix it. So in my test I undo this.So 5.1 to 5.2 on Python 2 mostly works. The site logo is okay, as long as you only edit it in the site-controlpanel, not in portal_registry.
Now we try Python 3:
./bin/zodbupdate --convert-py3 --file=var/filestorage/Data.fs --encoding utf8
and start Plone.For more fun, I notice an extra problem, where my PR is innocent:
zope.schema._bootstrapinterfaces.WrongType: (<NOT_CHANGED>, <class 'bytes'>, 'value')
.filenameb64:...
.Module plone.formwidget.namedfile.converter, line 77, in b64decode_file
: ValueError: not enough values to unpack (expected 2, got 1)
.ValueError: too many values to unpack
. This is either a difference in Python 2 and 3, or because I first tried a .svg
and later a .png
, which gives a value starting with PNG IHDR
.Summary:
plone.site_logo
in portal_registry
is broken.ISiteSchema
interface again when a field is added.plone.app.upgrade
does not seem necessary.I close this one as my PR is merged. For the configuration registry editor problem I opened a new issue: https://github.com/plone/Products.CMFPlone/issues/3215
The site logo is missing a migration from ASCII to Bytes. In Plone 5.1, the site logo is of type ASCII, in 5.2 this was changed to Bytes, see commit 11482a2d37b9ded04d517bd1e9f50e234e3b3b46.
zope.schema.ASCII
inherits fromNativeString
, which on Python 2 is the same asBytes
. On Python 3,ASCII
is the same asString
. Problem with a site started at 5.1 and migrated to 5.2 Py 3, is that theportal_registry
reports thatplone.site_logo
is an ASCII type and its value is text (native Py3 string), but theISiteSchema
expects aBytes
field. Validation fails with:What I did:
buildout.coredev
branches.portal_registry?q=plone.site_logo
: field type is ASCII.@@site-controlpanel
: this works.var
dir to a checkout of 5.2), including@@plone-upgrade
.portal_registry?q=plone.site_logo
: field type is still ASCII.@@site-controlpanel
: this still works.portal_registry?q=plone.site_logo
: field type is still ASCII.@@site-controlpanel
and save without making any change: this fails.Alternatively:
@@site-controlpanel
and save without making any change: this should work.@@site-controlpanel
and save: this failsWhat I expect to happen:
The logo is saved, and used as logo.
What actually happened:
Traceback:
What version of Plone/ Addons I am using:
Solution:
I have not tried solutions yet, but I can imagine:
plone.app.upgrade
to change the ASCII record to a Bytes record. In Python 2.7 this should be easy. It may be tricker when this is already Python 3.bin/zodbupdate
could maybe handle this when migrating to Py 3, but I guess not. Also, this should still be fixed even when the database has already been migrated to Py 3.I do not expect that all ASCII records should be turned into Bytes. It seems this should be determined on a field-by-field basis. But I do wonder if a fix could be made more general: go through all registry records and check if the record type matches the interface.