Quantcast
Channel:
Viewing all articles
Browse latest Browse all 4235

Re: Restore Unpublished and Deleted Pages

$
0
0

Your post was a great help. As I had to undelete hundreds of pages I had to write a stored procedure. As I had added an own ArticlePage they had to be undeleted as well. Here is what I did:

DELIMITER $$
DROP PROCEDURE IF EXISTS UnDelete$$
CREATE PROCEDURE UnDelete()
BEGIN
DECLARE x int(11);
DECLARE rID int(11);
DECLARE nID int(11);
SET x = 23027;
WHILE x >= 1132 DO
SET rID = (SELECT RecordID from SiteTree_versions WHERE ID = x AND ClassName LIKE 'ArticlePage' AND Title NOT LIKE 'NeuArticlePage');
SET nID = (select ID from SiteTree WHERE ID = rID);
IF nID IS NULL AND rID IS NOT NULL THEN
SELECT x, rID, nID;
INSERT INTO SiteTree (ID, Version, ClassName, Created, LastEdited, URLSegment, Title, Content, MenuTitle, MetaTitle, ShowInMenus, ShowInSearch, Sort, Status, Priority, ParentID, ToDo, CanEditType, CanViewType, ReportClass, HasBrokenLink, HasBrokenFile, LegacyURL, ProvideComments, HomepageForDomain, ExtraMeta, MetaKeywords, MetaDescription) select RecordID, Version, ClassName, Created, LastEdited, URLSegment, Title, Content, MenuTitle, MetaTitle, ShowInMenus, ShowInSearch, Sort, Status, Priority, ParentID, ToDo, CanEditType, CanViewType, ReportClass, HasBrokenLink, HasBrokenFile, LegacyURL, ProvideComments, HomepageForDomain, ExtraMeta, MetaKeywords, MetaDescription from SiteTree_versions where ID = x;
END IF;
SET x = x - 1;
END WHILE;
SET x = 23027;
WHILE x >= 1132 DO
SET rID = (SELECT RecordID from ArticlePage_versions WHERE ID = x);
SET nID = (select ID from ArticlePage WHERE ID = rID);
IF nID IS NULL AND rID IS NOT NULL THEN
SELECT x, rID, nID;
INSERT INTO ArticlePage (ID, Date, Author, Teaser, Tag) select RecordID, Date, Author, Teaser, Tag from ArticlePage_versions where ID = x;
END IF;
SET x = x - 1;
END WHILE;
END$$
DELIMITER ;
CALL UnDelete();


Posted to: Restore Unpublished and Deleted Pages | Show Thread | Post Reply


Viewing all articles
Browse latest Browse all 4235

Trending Articles