Deleting page with blocks copied to other pages
Permalink
On a new site we are building, we've been adding, moving, and deleting pages all over the place.
Today we deleted one of our oldest pages, and shortly after, much to our dismay, discovered a large number of pages that were trashed - throwing fatal errors, apparently due to missing block records.
"Fatal error: Call to a member function getBlockTypeHandle() on a non-object in <web root>\concrete\core\libraries\block_view_template.php on line 41 "
We come to discover, it was related to the fact that much of the content on those pages started as copies of content blocks from the page we deleted. Thinking back on it, it kind of makes sense, but since there is no way to track block copies, it goes out of sight, out of mind rather quickly. I'm surprised there wasn't at least some kind of warning...
Meanwhile, I've been searching the forums for fixes - I have backups of the database that would undoubtedly contain the records that were deleted. We would be extremely grateful if someone can offer any advice to repair the broken pages.
Thanks!
Today we deleted one of our oldest pages, and shortly after, much to our dismay, discovered a large number of pages that were trashed - throwing fatal errors, apparently due to missing block records.
"Fatal error: Call to a member function getBlockTypeHandle() on a non-object in <web root>\concrete\core\libraries\block_view_template.php on line 41 "
We come to discover, it was related to the fact that much of the content on those pages started as copies of content blocks from the page we deleted. Thinking back on it, it kind of makes sense, but since there is no way to track block copies, it goes out of sight, out of mind rather quickly. I'm surprised there wasn't at least some kind of warning...
Meanwhile, I've been searching the forums for fixes - I have backups of the database that would undoubtedly contain the records that were deleted. We would be extremely grateful if someone can offer any advice to repair the broken pages.
Thanks!
1. Go to sitemap. Write down the cID and cvID from the page where the error appears.
2. Run query in database tool:
SELECT * FROM (SELECT * FROM (SELECT * FROM CollectionVersionBlocks WHERE cID=****CID**** AND cvID=****cvID****) AS t1 LEFT JOIN Blocks USING(bID)) as t2 LEFT JOIN BlockTypes USING(btID)
3. Look for btID = 1 (which are stacks). Write down bID.
4. Run query:
SELECT * FROM CollectionVersionBlocks WHERE bID=***bID*** AND cvID=***cvID***
5. If you see blocks that you've deleted in the past and that don't exist anymore in your c5 installation, you could delete the blocks manually and see if the page renders afterwards.
Another approach is to enable database verbose output by running: Database::setDebug(true) at the beginning of the script. Then scroll down to the end to see which query was ran last and probably caused the issue.