Forums / Developer / Getting deleting orphans from ezcontentobject and ezcontentobject_tree

Getting deleting orphans from ezcontentobject and ezcontentobject_tree

Author Message

Erik Weinmaster

Monday 29 March 2010 9:34:38 am

Hello,

I created a different delete function, which purges an object if the main node is selected to be deleted (the subtree is deleted too), otherwise just the tree node is removed. However, before I was able to fully implement this, I notice that there have been orphaned records in ezcontentobject and ezcontentobject_tree.

I guess I have one simple question. Can an Object exist without a corresponding record in ezcontentobject_tree? From what I find, I'd say no, because how would you get to this object? But I'd like some confirmation too. Please.

Also, here are the two queries I am using to find orphaned records.

Type 1: No corresponding tree node

SELECT DISTINCT co.id

FROM ezcontentobject co

LEFT JOIN ezcontentobject_tree cot ON co.id = cot.contentobject_id

WHERE node_id IS NULL

Type 2: No parent node

SELECT DISTINCT contentobject_id AS id

FROM ezcontentobject_tree

WHERE parent_node_id NOT IN (SELECT DISTINCT node_id FROM ezcontentobject_tree)

Do these queries look right?

Thanks

Robin Muilwijk

Monday 29 March 2010 11:05:40 am

Hi,

I saw a post about orphans some time ago, so sharing here in case it's worth something for you to compare your own sql scripts: http://share.ez.no/forums/developer/zombie-check-script/%28language%29/eng-GB

Regards Robin

Board member, eZ Publish Community Project Board - Member of the share.ez.no team - Key values: Openness and Innovation.

LinkedIn: http://nl.linkedin.com/in/robinmuilwijk // Twitter: http://twitter.com/i_robin // Skype: robin.muilwijk