A personal repository of random information in compensation for a fatigued biological computer
Breaded IT » Web Development » SilverStripe CMS pre V3.0 » HouseKeeping » 2.2.x Orphaned pages
While investigating how to clear out old page versions I found I had a record count difference between SiteTree (157 records) & SiteTree_Live (154 records).
Lets see whats in SiteTree thats not in SiteTree_Live:
SELECT * FROM `SiteTree_Live` WHERE CONCAT_WS('_', ID, Version) NOT IN (SELECT CONCAT_WS('_', id, Version) AS combined_id FROM SiteTree) |
Returned 0 rows..
Lets see whats in SiteTree_Live thats not in SiteTree:
SELECT * FROM `SiteTree` WHERE CONCAT_WS('_', ID, Version) NOT IN (SELECT CONCAT_WS('_', id, Version) AS combined_id FROM SiteTree_Live) |
Returned 3 rows..
Visual checking parent ID's of these 3 records and OMG it seems I have 3 orphaned pages! in SiteTree. Lets confirm:
SELECT * from SiteTree where ID in ( SELECT ParentID FROM SiteTree WHERE CONCAT_WS('_', ID, Version) NOT IN ( SELECT CONCAT_WS('_', id, Version) AS combined_id FROM SiteTree_Live ) ) |
0 rows returned! Hmm ALERT ** Database integrity compromised ** ALERT
Scary stuff, I wonder how that can happen.. Well, since 2.3 is out we will delete these 3 pages from SiteTree and will run this query every so often after we upgrade to 2.3 to see if it reoccurs.. (Note that the 3 orphaned pages were last edited under 2.2.2)