Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into davisagli-suppress-…
Browse files Browse the repository at this point in the history
…login-migration
  • Loading branch information
davisagli committed Dec 13, 2017
2 parents 50f8a31 + 9098cff commit ef22eb1
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 6 deletions.
15 changes: 14 additions & 1 deletion CHANGES.rst
@@ -1,7 +1,7 @@
Changelog
=========

2.0.10 (unreleased)
2.0.11 (unreleased)
-------------------

Breaking changes:
Expand All @@ -14,6 +14,19 @@ New features:

Bug fixes:

- Log progress and ignore bad catalog entries while updating catalog metadata.
[davisagli]

- Disable CSRF protection when replacing keyring.
This fixes running specific upgrade steps via the portal_setup UI.
[davisagli]


2.0.10 (2017-12-13)
-------------------

Bug fixes:

- Unregister import_steps that were moved to post_handlers.
Fixes https://github.com/plone/Products.CMFPlone/issues/2238
[pbauer]
Expand Down
10 changes: 10 additions & 0 deletions plone/app/upgrade/v50/alphas.py
Expand Up @@ -18,10 +18,13 @@
from plone.keyring.interfaces import IKeyManager
from plone.keyring.keymanager import KeyManager
from plone.keyring.keyring import Keyring
from plone.protect.interfaces import IDisableCSRFProtection
from plone.registry.interfaces import IRegistry
from zope.component import getSiteManager
from zope.component import getUtility
from zope.component.hooks import getSite
from zope.globalrequest import getRequest
from zope.interface import alsoProvides
from zope.schema.interfaces import ConstraintNotSatisfied

try:
Expand Down Expand Up @@ -206,6 +209,13 @@ def upgrade_keyring(context):
obj = KeyManager()
sm.registerUtility(aq_base(obj), IKeyManager, '')

# disable CSRF protection which will fail due to
# using different secrets than when the authenticator
# was generated
request = getRequest()
if request is not None:
alsoProvides(request, IDisableCSRFProtection)


def to50alhpa3(context):
"""5.0alpha2 - > 5.0alpha3"""
Expand Down
15 changes: 13 additions & 2 deletions plone/app/upgrade/v50/final.py
Expand Up @@ -4,6 +4,8 @@
from plone.registry.interfaces import IRegistry
from Products.CMFCore.utils import getToolByName
from Products.CMFPlone.utils import safe_unicode
from Products.ZCatalog.ProgressHandler import ZLogHandler
from zExceptions import NotFound
from zope.component import getUtility
from zope.component.hooks import getSite

Expand Down Expand Up @@ -68,9 +70,17 @@ def refresh_getIcon_catalog_metadata(context):

cnt = 0
# search whole catalog
for brain in zcatalog.unrestrictedSearchResults():
results = zcatalog.unrestrictedSearchResults()
num_objects = len(results)
pghandler = ZLogHandler(1000)
pghandler.init('Updating getIcon metadata', num_objects)
for brain in results:
pghandler.report(cnt)
# First get the new value
obj = brain._unrestrictedGetObject()
try:
obj = brain._unrestrictedGetObject()
except (AttributeError, KeyError, TypeError, NotFound):
continue
new_value = bool(getattr(aq_base(obj), 'image', False))

# We can now update the record with the new getIcon value
Expand All @@ -80,6 +90,7 @@ def refresh_getIcon_catalog_metadata(context):

cnt += 1 # we are curious
# done
pghandler.finish()
logger.info('Reindexed `getIcon` for %s items' % str(cnt))

refresh_getIcon_catalog_metadata(context)
Expand Down
15 changes: 13 additions & 2 deletions plone/app/upgrade/v51/betas.py
Expand Up @@ -5,6 +5,8 @@
from Products.CMFCore.utils import getToolByName
from Products.CMFPlone.interfaces import IFilterSchema
from Products.CMFPlone.interfaces import ISearchSchema
from Products.ZCatalog.ProgressHandler import ZLogHandler
from zExceptions import NotFound
from zope.component import getUtility
import logging

Expand Down Expand Up @@ -152,8 +154,16 @@ def reindex_mime_type(context):
'Products.ATContentTypes.interfaces.file.IFileContent',
'Products.ATContentTypes.interfaces.image.IImageContent']
cnt = 0
for brain in zcatalog.unrestrictedSearchResults(object_provides=ifaces):
obj = brain._unrestrictedGetObject()
results = zcatalog.unrestrictedSearchResults(object_provides=ifaces)
num_objects = len(results)
pghandler = ZLogHandler(1000)
pghandler.init('Updating mime_type metadata', num_objects)
for brain in results:
pghandler.report(cnt)
try:
obj = brain._unrestrictedGetObject()
except (AttributeError, KeyError, TypeError, NotFound):
continue
if not obj:
continue
# First get the new value:
Expand All @@ -169,6 +179,7 @@ def reindex_mime_type(context):
record[metadata_index] = new_value
catalog.data[brain.getRID()] = tuple(record)
cnt += 1
pghandler.finish()
logger.info('Reindexed `mime_type` for %s items' % str(cnt))


Expand Down
2 changes: 1 addition & 1 deletion setup.py
@@ -1,6 +1,6 @@
from setuptools import setup, find_packages

version = '2.0.10.dev0'
version = '2.0.11.dev0'

setup(
name='plone.app.upgrade',
Expand Down

0 comments on commit ef22eb1

Please sign in to comment.