Fix unindexing of comments when deleting content resulting from
iterating over a BTree while modifying it. Fixes #11402. svn path=/plone.app.discussion/trunk/; revision=48845
This commit is contained in:
		
							parent
							
								
									82b4a7ca70
								
							
						
					
					
						commit
						7354ca4298
					
				@ -4,6 +4,10 @@ Changelog
 | 
				
			|||||||
2.0b2 (Unreleased)
 | 
					2.0b2 (Unreleased)
 | 
				
			||||||
------------------
 | 
					------------------
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					- Fix unindexing of comments when deleting content resulting from
 | 
				
			||||||
 | 
					  iterating over a BTree while modifying it. Fixes #11402.
 | 
				
			||||||
 | 
					  [rossp]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
- Fix Missing.Value for Creator in the catalog. Fixes #11634.
 | 
					- Fix Missing.Value for Creator in the catalog. Fixes #11634.
 | 
				
			||||||
  [rossp]
 | 
					  [rossp]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -195,14 +195,16 @@ def notify_content_object(obj, event):
 | 
				
			|||||||
                                    'last_comment_date',
 | 
					                                    'last_comment_date',
 | 
				
			||||||
                                    'commentators',))
 | 
					                                    'commentators',))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def notify_content_object_deleted(obj, event):
 | 
					def notify_content_object_deleted(obj, event):
 | 
				
			||||||
    """Remove all comments of a content object when the content object has been
 | 
					    """Remove all comments of a content object when the content object has been
 | 
				
			||||||
       deleted.
 | 
					       deleted.
 | 
				
			||||||
    """
 | 
					    """
 | 
				
			||||||
    if IAnnotatable.providedBy(obj):
 | 
					    if IAnnotatable.providedBy(obj):
 | 
				
			||||||
        conversation = IConversation(obj)
 | 
					        conversation = IConversation(obj)
 | 
				
			||||||
        for comment in conversation.getComments():
 | 
					        while conversation:
 | 
				
			||||||
            del conversation[comment.id]
 | 
					            del conversation[conversation.keys()[0]]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def notify_user(obj, event):
 | 
					def notify_user(obj, event):
 | 
				
			||||||
    """Tell users when a comment has been added.
 | 
					    """Tell users when a comment has been added.
 | 
				
			||||||
 | 
				
			|||||||
@ -35,7 +35,8 @@ Make sure we have a test user from the layer and it uses fancy characters:
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    >>> from Products.CMFCore.utils import getToolByName
 | 
					    >>> from Products.CMFCore.utils import getToolByName
 | 
				
			||||||
    >>> mtool = getToolByName(portal, 'portal_membership', None)
 | 
					    >>> mtool = getToolByName(portal, 'portal_membership', None)
 | 
				
			||||||
    >>> mtool.getMemberById('jim').getProperty('fullname')
 | 
					    >>> jim_fullname = mtool.getMemberById('jim').getProperty('fullname')
 | 
				
			||||||
 | 
					    >>> jim_fullname
 | 
				
			||||||
    'Jim Fult\xc3\xb8rn'
 | 
					    'Jim Fult\xc3\xb8rn'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Enable commenting.
 | 
					Enable commenting.
 | 
				
			||||||
@ -198,11 +199,12 @@ Now we can post an anonymous comment.
 | 
				
			|||||||
Make sure special characters work as well.
 | 
					Make sure special characters work as well.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    >>> unprivileged_browser.open(urldoc1)
 | 
					    >>> unprivileged_browser.open(urldoc1)
 | 
				
			||||||
    >>> unprivileged_browser.getControl(name='form.widgets.author_name').value = "Tarek Ziadé"
 | 
					    >>> tarek_fullname = "Tarek Ziadé"
 | 
				
			||||||
 | 
					    >>> unprivileged_browser.getControl(name='form.widgets.author_name').value = tarek_fullname
 | 
				
			||||||
    >>> unprivileged_browser.getControl(name='form.widgets.text').value = "This is an äüö comment"
 | 
					    >>> unprivileged_browser.getControl(name='form.widgets.text').value = "This is an äüö comment"
 | 
				
			||||||
    >>> unprivileged_browser.getControl(name='form.buttons.comment').click()
 | 
					    >>> unprivileged_browser.getControl(name='form.buttons.comment').click()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    >>> 'Tarek Ziadé' in unprivileged_browser.contents
 | 
					    >>> tarek_fullname in unprivileged_browser.contents
 | 
				
			||||||
    True
 | 
					    True
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    >>> 'says' in unprivileged_browser.contents
 | 
					    >>> 'says' in unprivileged_browser.contents
 | 
				
			||||||
@ -313,6 +315,7 @@ Create a collection.
 | 
				
			|||||||
    >>> browser.getControl('Save').click()
 | 
					    >>> browser.getControl('Save').click()
 | 
				
			||||||
    >>> print browser.contents
 | 
					    >>> print browser.contents
 | 
				
			||||||
    <...Changes saved...
 | 
					    <...Changes saved...
 | 
				
			||||||
 | 
					    >>> topic_url = browser.url
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Set the collection criteria.
 | 
					Set the collection criteria.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -339,7 +342,40 @@ View the collection listing.
 | 
				
			|||||||
    <Link text='Anonymous on Doc1' url='http://nohost/plone/doc1/++conversation++default/...'>
 | 
					    <Link text='Anonymous on Doc1' url='http://nohost/plone/doc1/++conversation++default/...'>
 | 
				
			||||||
    >>> browser.getLink('Anonymous on Doc1', index=1)
 | 
					    >>> browser.getLink('Anonymous on Doc1', index=1)
 | 
				
			||||||
    <Link text='Anonymous on Doc1' url='http://nohost/plone/doc1/++conversation++default/...'>
 | 
					    <Link text='Anonymous on Doc1' url='http://nohost/plone/doc1/++conversation++default/...'>
 | 
				
			||||||
    >>> browser.getLink('Tarek Ziadé on Doc1')
 | 
					    >>> browser.getLink(tarek_fullname + ' on Doc1')
 | 
				
			||||||
    <Link text='Tarek Ziad\xc3\xa9 on Doc1' url='http://nohost/plone/doc1/++conversation++default/...'>
 | 
					    <Link text='Tarek Ziad\xc3\xa9 on Doc1' url='http://nohost/plone/doc1/++conversation++default/...'>
 | 
				
			||||||
    >>> browser.getLink('Jim Fultørn on Doc1')
 | 
					    >>> browser.getLink(jim_fullname + ' on Doc1')
 | 
				
			||||||
    <Link text='Jim Fult\xc3\xb8rn on Doc1' url='http://nohost/plone/doc1/++conversation++default/...'>
 | 
					    <Link text='Jim Fult\xc3\xb8rn on Doc1' url='http://nohost/plone/doc1/++conversation++default/...'>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Comments are unindexed when the content is deleted
 | 
				
			||||||
 | 
					--------------------------------------------------
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Delete the commented content.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    >>> browser.open(urldoc1)
 | 
				
			||||||
 | 
					    >>> browser.getLink('Delete').click()
 | 
				
			||||||
 | 
					    >>> browser.getControl('Delete').click()
 | 
				
			||||||
 | 
					    >>> print browser.contents
 | 
				
			||||||
 | 
					    <...Doc1 has been deleted...
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					The comments are no longer in the catalog.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    >>> browser.open(topic_url)
 | 
				
			||||||
 | 
					    >>> browser.getLink('admin on Doc1', index=0)
 | 
				
			||||||
 | 
					    Traceback (most recent call last):
 | 
				
			||||||
 | 
					    LinkNotFoundError
 | 
				
			||||||
 | 
					    >>> browser.getLink('admin on Doc1', index=1)
 | 
				
			||||||
 | 
					    Traceback (most recent call last):
 | 
				
			||||||
 | 
					    LinkNotFoundError
 | 
				
			||||||
 | 
					    >>> browser.getLink('Anonymous on Doc1', index=0)
 | 
				
			||||||
 | 
					    Traceback (most recent call last):
 | 
				
			||||||
 | 
					    LinkNotFoundError
 | 
				
			||||||
 | 
					    >>> browser.getLink('Anonymous on Doc1', index=1)
 | 
				
			||||||
 | 
					    Traceback (most recent call last):
 | 
				
			||||||
 | 
					    LinkNotFoundError
 | 
				
			||||||
 | 
					    >>> browser.getLink(tarek_fullname + ' on Doc1')
 | 
				
			||||||
 | 
					    Traceback (most recent call last):
 | 
				
			||||||
 | 
					    LinkNotFoundError
 | 
				
			||||||
 | 
					    >>> browser.getLink(jim_fullname + ' on Doc1')
 | 
				
			||||||
 | 
					    Traceback (most recent call last):
 | 
				
			||||||
 | 
					    LinkNotFoundError
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user