Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Node delete fails #78

Closed
marcoacierno opened this issue Sep 26, 2017 · 1 comment
Closed

Node delete fails #78

marcoacierno opened this issue Sep 26, 2017 · 1 comment
Labels

Comments

@marcoacierno
Copy link

marcoacierno commented Sep 26, 2017

I am using django cms (3.2.5 and Django 1.9.5) with treebeard (4.1.2). Even time I try to delete a CMS plugin it fails with an error 500 and MultipleObjectsReturned: get() returned more than one CMSPlugin -- it returned 36 as error.

The issue happens at MP_NodeQuerySet#delete after finding all the nodes to remove (in my case just one)

# ok, got the minimal list of nodes to remove...
# we must also remove their children
# and update every parent node's numchild attribute
# LOTS OF FUN HERE!
for path, node in removed.items():
    parentpath = node._get_basepath(node.path, node.depth - 1)
    if parentpath:
        if parentpath not in parents:
            parents[parentpath] = node.get_parent(True)
        parent = parents[parentpath]
        if parent and parent.numchild > 0:
            parent.numchild -= 1
            parent.save()
    if node.is_leaf():
        toremove.append(Q(path=node.path))
    else:
        toremove.append(Q(path__startswith=node.path))

at the parents[parentpath] = node.get_parent(True) line. The database seems to returns multiple parents. Might it be caused by the fact that in the database I have multiple cms plugins with the same path? (https://marcoacierno.space/xQzR3Qogo4.png)

(EDIT: I just found that when you delete a root node it also deletes content from other pages because the path starts the same way, (the node.is_leaf() == false if))

If it helps, I also have an issue where, sometimes (at random), when changing/adding/deleting (even if it never works) most content of my website gets mixed up (images/text etc gets moved to the current blogpost)

Any suggestion to how to fix this issue? Or it's a known issue?

Thank you!

@tabo tabo added the invalid label Jan 17, 2021
@tabo
Copy link
Member

tabo commented Jan 17, 2021

Hi, I know it's been years and your png isn't there any more, but it surely was a problem with the queryset. There are a lot of warnings on how to properly subclass querysets. Cheers!

@tabo tabo closed this as completed Jan 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants