Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

General Questions

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

"Orphan" pages in SiteTree


4 Posts   1162 Views


5 May 2009 at 1:46pm (Last edited: 5 May 2009 2:30pm), Community Member, 604 Posts

Hi all,

I had an issue where a page I was creating for a site was appending "-12" to the URL even if I removed it manually. I knew this meant there was a conflicting URL in the system.

I checked it out in the SiteTree table and found the conflicting page. I got it's Parent number in an attempt to find out where it was and found that the Parent ID did not exist in either SiteTree or SiteTree_Live.

So I wrote a little script to check this out by getting all the pages from SiteTree and check that their ParentID exists in turn (except for ParentID of 0). I found litteraly dozens of "Orphan" pages in the system.

So a few questions:
1. Anyone know how something like this happens?
2. Is there a /dev/build function or the likes for cleaning this up?
3. If no to 2., is there any reason why I shouldn't use this script to remove this orphans. e.g. Could their parents be in another table perhaps?



5 May 2009 at 2:31pm Community Member, 70 Posts

Hmm, I'm going to have to do an orphan pages report for a client soon, so I'm interested in the topic.

It isn't anything to do with page histories/revisions is it?


5 May 2009 at 2:57pm (Last edited: 5 May 2009 2:57pm), Community Member, 604 Posts

Don't think so.

I find these pages in SiteTree, and they don't appear to have 'real' parents in SiteTree, SiteTree_Live or SiteTree_versions.

I've attached the code I used to clean a test copy of the site in question. All seems well so far. Just basic Run of the mill PHP in there. Couldn't be knackered working Sapphire into this.



5 May 2009 at 3:15pm Community Member, 70 Posts


I will update this thread with my code if the client goes ahead with getting the report.....