Don't miss out Virtual Happy Hour this Friday (April 26).

Try our conversational search powered by Generative AI!

Automatic emptying of recycle bin does not work in CMS 5

Vote:
 

Currently we have 12000 pages (most of them very old) in our recycle bin and we have since long back activated the "Automatic emptying of recycle bin" but it does not remove any pages (it has long time back removed a few pages). I also tried to run it manually with same negative result. When starting it, it finishes immediately with no error. We had the same problem in EPiServer 4.62 and used the following script as a workaround:

exec sp_debugtree
GO

declare @DeletePageID int

while(1=1)
begin
  select top 1 @DeletePageID=pkID
  from tblPage
  where (fkparentID = 2)   -- modify this where-statement...
  and   Saved< dateadd(day,-7,getdate())

  if (@@ROWCOUNT = 0)
    break

  exec editDeletePage @DeletePageID, 1
end

We would like to use a similar script for CSM 5 and I thougth I had got it right but it seems like the pages are not fully deleted when using my modified script. Pages sometimes remain in recycle bin but they can not be viewed and they cannot be searched so the database seems to have come into an inconsistent state. This is the script I have been trying in CMS 5:

declare @DeletePageID int

while(1=1)
begin
  select top 1 @DeletePageID=P.pkID
  from tblPage P, tblWorkPage W
  where (P.fkparentID = 2)   -- modify this where-statement...
  and P.pkID = W.fkPageID
  and   W.Saved< dateadd(day,-7,getdate())

  if (@@ROWCOUNT = 0)
    break

  exec editDeletePage @DeletePageID, 1
end

Does enyone have a solution to the empty recycle bin problem in CMS 5?

#47121
Jan 14, 2011 14:32
Vote:
 

This will delete around 1000 pages in the wastbasket before it throws an error. But it will delete them...

string DeleteStuff(bool doIt)
{
    TimeSpan dbQueryDefault = EPiServer.Configuration.Settings.Instance.DatabaseQueryTimeout;
    EPiServer.Configuration.Settings.Instance.DatabaseQueryTimeout = new TimeSpan(0, 10, 0);

    string result = "";
    string result2 = "";
    int num = 0;
    var wastChilds=DataFactory.Instance.GetChildren(PageReference.WasteBasket,LanguageSelector.AutoDetect(true));
    foreach (PageData data in wastChilds)
    {
        if (data.IsDeleted && (data.Saved <= DateTime.Now.AddDays(-30.0)))
        {
            result += "<li>";
            try
            {
                num++;
                result += data.PageName + "[" + data.PageLink.ID + " " + data.LanguageID + "]";
                if (doIt)
                {
                    DataFactory.Instance.Delete(data.PageLink, true, AccessLevel.NoAccess);

                    result += " deleted!";
                }

            }
            catch (Exception exception)
            {
                result += exception.Message;

            }
            result += "</li>";
        }
        else
        {
            result2 += "<li>" + data.PageName + " [" + data.PageLink.ID + " " + data.LanguageID + "]" + data.Saved + "</li>";
        }
    }
    EPiServer.Configuration.Settings.Instance.DatabaseQueryTimeout = dbQueryDefault;
    return "<li>count=" + num + "</li><li>Tot=" + wastChilds.Count+"</li>"+ result + "<li>not done</li>" + result2;

}

#47138
Jan 14, 2011 21:45
Vote:
 

Thanks Anders for your input. However, I want a permanent solution that I can run as an SQL scheduled task regularly that removes everything older than a number of days. And it should preferably use EPiServers own stored procs for deletion so that I am sure all EPiServer tables are cleaned up in the correct way. It seems my second script works partly but I think something is missing in it but as I do not know the EPiServer database structure in detail, it is hard to know exactly what to do.

#47143
Jan 17, 2011 8:30
Vote:
 

We had to make the code above a schedule task since we got an timeout from the normal sched task, and that rollacked alle the deleted items. The above code do delete pages correctly, but only one at the time.

#47144
Jan 17, 2011 9:02
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.