plone / Products.CMFPlone

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

Syndication fails after migrating to Plone 6.0 #3805

Closed mauritsvanrees closed 1 year ago

mauritsvanrees commented 1 year ago

I have seen this on two sites now that I migrated from earlier Plone (4.3 and 5.2) to Plone 6.0. I am not sure if these sites actually want RSS/atom feeds to work, but I see tracebacks, so either people or bots do visit the urls. Sample traceback:

TypeError: http://localhost:8080/Plone/rss.xml
Traceback (innermost last):
  Module ZPublisher.WSGIPublisher, line 181, in transaction_pubevents
  Module ZPublisher.WSGIPublisher, line 390, in publish_module
  Module ZPublisher.WSGIPublisher, line 285, in publish
  Module ZPublisher.mapply, line 85, in mapply
  Module ZPublisher.WSGIPublisher, line 68, in call_object
  Module Products.CMFPlone.browser.syndication.views, line 38, in __call__
  Module Products.Five.browser.pagetemplatefile, line 126, in __call__
  Module Products.Five.browser.pagetemplatefile, line 58, in __call__
  Module zope.pagetemplate.pagetemplate, line 134, in pt_render
  Module Products.PageTemplates.engine, line 365, in __call__
  Module z3c.pt.pagetemplate, line 176, in render
  Module chameleon.zpt.template, line 298, in render
  Module chameleon.template, line 214, in render
  Module chameleon.utils, line 20, in raise_with_traceback
  Module chameleon.template, line 190, in render
  Module dcbf46baa3cc42454143e413ab7bfc09, line 346, in render
  Module Products.PageTemplates.engine, line 74, in __call__
  Module Products.CMFPlone.browser.syndication.adapters, line 139, in items
  Module Products.CMFPlone.browser.syndication.adapters, line 135, in _items
  Module Products.CMFPlone.browser.syndication.adapters, line 168, in _brains
TypeError: unsupported operand type(s) for +: 'int' and 'NoneType'

 - Expression: "feed/items"
 - Filename:   ... oducts.CMFPlone.browser.syndication.templates.rss.xml.pt
 - Location:   (line 18: col 27)
 - Source:     <item tal:repeat="item feed/items">
                                      ^^^^^^^^^^

Or when you visit the syndication control panel:

KeyError: http://localhost:8080/Plone/@@syndication-controlpanel
Traceback (innermost last):
  Module ZPublisher.WSGIPublisher, line 181, in transaction_pubevents
  Module ZPublisher.WSGIPublisher, line 390, in publish_module
  Module ZPublisher.WSGIPublisher, line 285, in publish
  Module ZPublisher.mapply, line 85, in mapply
  Module ZPublisher.WSGIPublisher, line 68, in call_object
  Module plone.z3cform.layout, line 61, in __call__
  Module plone.z3cform.layout, line 45, in update
  Module Products.CMFPlone.controlpanel.browser.syndication, line 53, in update
  Module plone.z3cform.fieldsets.extensible, line 62, in update
  Module plone.z3cform.patch, line 31, in GroupForm_update
  Module z3c.form.group, line 132, in update
  Module z3c.form.form, line 129, in updateWidgets
  Module plone.app.registry.browser.controlpanel, line 45, in getContent
  Module plone.registry.registry, line 71, in forInterface
KeyError: 'Interface `plone.base.interfaces.syndication.ISiteSyndicationSettings`
 defines a field `allowed`, for which there is no record.'

Problem is the the syndication control panel interface was moved from Products.CMFPlone.interfaces.syndication.ISiteSyndicationSettings to plone.base.interfaces.syndication.ISiteSyndicationSettings.

So this may be part of issue #3787.

A way to fix it in a site is to create an xml file like this and upload it in the configuration registry on the Import tab:

<?xml version="1.0"?>
<registry>
  <records interface="plone.base.interfaces.syndication.ISiteSyndicationSettings" />
</registry>

Then the errors are gone, but the old settings have not been taken over. When you go to the configuration registry control panel and the Export tab, you see both interfaces available for export. They have these differences:

$ diff Products.CMFPlone.interfaces.syndication.ISiteSyndicationSettings.xml plone.base.interfaces.syndication.ISiteSyndicationSettings.xml 
3c3
<   <records interface="Products.CMFPlone.interfaces.syndication.ISiteSyndicationSettings" prefix="Products.CMFPlone.interfaces.syndication.ISiteSyndicationSettings">
---
>   <records interface="plone.base.interfaces.syndication.ISiteSyndicationSettings" prefix="plone.base.interfaces.syndication.ISiteSyndicationSettings">
12,13c12,13
<     <value key="max_items">25</value>
<     <value key="render_body">True</value>
---
>     <value key="max_items">15</value>
>     <value key="render_body">False</value>
16,17c16,20
<     <value key="show_syndication_button">True</value>
<     <value key="show_syndication_link">True</value>
---
>     <value key="show_syndication_button">False</value>
>     <value key="show_syndication_link">False</value>
>     <value key="site_rss_items">
>       <element>/news/aggregator</element>
>     </value>

So I guess in this particular site, some settings were changed, probably years ago. I took them over and uploaded this xml:

<?xml version='1.0' encoding='UTF-8'?>
<registry>
  <records interface="plone.base.interfaces.syndication.ISiteSyndicationSettings" prefix="plone.base.interfaces.syndication.ISiteSyndicationSettings">
    <value key="allowed">True</value>
    <value key="allowed_feed_types">
      <element>RSS|RSS 1.0</element>
      <element>rss.xml|RSS 2.0</element>
      <element>atom.xml|Atom</element>
      <element>itunes.xml|iTunes</element>
    </value>
    <value key="default_enabled">False</value>
    <value key="max_items">25</value>
    <value key="render_body">True</value>
    <value key="search_rss_enabled">True</value>
    <value key="show_author_info">True</value>
    <value key="show_syndication_button">True</value>
    <value key="show_syndication_link">True</value>
  </records>
</registry>

BTW, I removed the <value key="site_rss_items"> because this gave an error on import, even though it was exported like that. This seems a separate problem that we can ignore for this issue.

1letter commented 1 year ago

@mauritsvanrees i can write an upgrade step for this, i have the code in a custom project and can copy and paste it to plone.app.upgrades

1letter commented 1 year ago

@mauritsvanrees import of site_rss_items raise an error if the tuple contains none existing objects ('/news/aggregator',) zope.schema._bootstrapinterfaces.WrongContainedType: ([ConstraintNotSatisfied('/news/aggregator', '')], 'value')

site_rss_items use the vocabulary SyndicatableFeedItems, the value is an UID of object

mauritsvanrees commented 1 year ago

@1letter Thanks for fixing!