This seems to be a difficult area in SS.
I'm trying to delete a page by code using: $page->doArchive();
This however, leaves a ghost of the page in the SiteTree menu with an option to "restore draft". This however breaks the functionality of my module and is not desired at all.
How do you completely remove a page so that user cannot see / recover it?
EDIT: Also tried:
DB::query("DELETE FROM SomePage WHERE ForeignID = {$this->ID}");
DB::query("DELETE FROM SomePage_Live WHERE ForeignID = {$this->ID}");
DB::query("DELETE FROM SomePage_versions WHERE ForeignID = {$this->ID}");
And even cleared the MySQL Table manually (phpmyadmin) and STILL there it shows the page (crossed out in menu) with a restore draft option.
EDIT2: This piece of messy code will delete all records and remove the ability to restore a draft. However, the deleted page icon is still shown in the sitetree and will dissappear after a refresh.
DB::query("DELETE FROM SomePage WHERE ForeignID = {$this->ID}");
DB::query("DELETE FROM SomePage_Live WHERE ForeignID = {$this->ID}");
DB::query("DELETE FROM SomePage_versions WHERE ForeignID = {$this->ID}");
DB::query("DELETE FROM SomePage_versions WHERE ForeignID = 0");
DB::query("DELETE FROM SiteTree WHERE ID = {$pageID}");
DB::query("DELETE FROM SiteTree_Live WHERE ID = {$pageID}");
DB::query("DELETE FROM SiteTree_versions WHERE RecordID = {$pageID}");
Question: How do prevent the "flash" of deleted page icon?