Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Bogdan 250 posts 427 karma points
    Feb 24, 2011 @ 11:04
    Bogdan
    0

    Cannot empty recycle bin in media section

    On a 4.5.2. website if I try to empty the recycle bin in the media section it hangs on the "The items in the recycle bin is now being deleted. Please do not close this window while this operation takes place" screen. If I try to individually delete an item I see in firebug the error

    {"Message":"No Document exists with Version \u0027271b4c09-c3e9-442f-995d-c7fbd2bb5a33\u0027","StackTrace":" at umbraco.cms.businesslogic.web.Document.setupNode()\r\n at umbraco.cms.businesslogic.CMSNode..ctor(Int32 Id)\r\n at umbraco.cms.businesslogic.Content..ctor(Int32 id)\r\n at umbraco.cms.businesslogic.web.Document..ctor(Int32 id)\r\n at umbraco.presentation.webservices.legacyAjaxCalls.DeleteContentPermanently(String nodeId, String nodeType)","ExceptionType":"System.ArgumentException"}

    I know there's an sql query I can run to delete the items with with parent id -20, this is the one I successfully used before

    delete from cmsPreviewXml where versionID in (select versionid from cmsContentVersion where ContentId in (select nodeId from cmsContent where nodeId in (select id from umbracoNode where path like '%-20%' and id!=-20)))
    delete from cmsContentVersion where ContentId in (select nodeid from cmsContent where nodeId in (select id from umbracoNode where path like '%-20%' and id!=-20))
    delete from cmsPropertyData where contentNodeId in (select id from umbracoNode where path like '%-20%' and id!=-20)
    delete from cmsContentXML where nodeId in (select nodeid from cmsContent where nodeId in (select id from umbracoNode where path like '%-20%' and id!=-20))
    delete from cmsDocument where nodeId in (select id from umbracoNode where path like '%-20%' and id!=-20)
    delete from cmsContent where nodeId in (select id from umbracoNode where path like '%-20%' and id!=-20)
    delete from umbracoNode where path like '%-20%' and id!=-20

    but I only want to clear the recycle bin from media, not the content one as well.

  • Jeroen Breuer 4908 posts 12265 karma points MVP 4x admin c-trib
    Feb 24, 2011 @ 11:06
    Jeroen Breuer
    0

    This should have been fixed in Umbraco 4.6

    Jeroen

  • Daniel Bardi 927 posts 2562 karma points
    Feb 24, 2011 @ 11:08
    Daniel Bardi
    0

    Media recycle bin id is -21 ... you might have deleted a record reference to the media recycle bin using your script.

  • Bogdan 250 posts 427 karma points
    Feb 24, 2011 @ 11:18
    Bogdan
    0

    I used that script on older versions of umbraco, to empty the content recycle bin, haven't tried it on 4.5.2 or newer. So if I replace -20 with -21 it should only remove the items from the media recycle bin?

  • Daniel Bardi 927 posts 2562 karma points
    Feb 24, 2011 @ 13:26
    Daniel Bardi
    0

    That is correct.  you need to look in why you can't delete.

  • GiuServ 4 posts 75 karma points
    Jan 04, 2018 @ 11:15
    GiuServ
    0

    For umbraco 7+ (currently last release 7.7.7) i made this script to empty both media and document trash folder:

    DELETE FROM cmsPreviewXml WHERE  nodeId IN (SELECT id FROM umbracoNode WHERE (path LIKE '%-21%' AND id!=-21) OR (path LIKE '%-20%' AND id!=-20));
    DELETE FROM cmsContentVersion WHERE  ContentId IN (SELECT id FROM umbracoNode WHERE (path LIKE '%-21%' AND id!=-21) OR (path LIKE '%-20%' AND id!=-20));
    DELETE FROM cmsDocument WHERE nodeId IN (SELECT id FROM umbracoNode WHERE (path LIKE '%-21%' AND id!=-21) OR (path LIKE '%-20%' AND id!=-20));
    DELETE FROM cmsTagRelationship WHERE nodeId IN (SELECT id FROM umbracoNode WHERE (path LIKE '%-21%' AND id!=-21) OR (path LIKE '%-20%' AND id!=-20));
    DELETE FROM cmsContentXML WHERE nodeId IN (SELECT id FROM umbracoNode WHERE (path LIKE '%-21%' AND id!=-21) OR (path LIKE '%-20%' AND id!=-20));
    DELETE FROM cmsContent WHERE nodeId IN (SELECT id FROM umbracoNode WHERE (path LIKE '%-21%' AND id!=-21) OR (path LIKE '%-20%' AND id!=-20));
    DELETE FROM cmsPropertyData WHERE contentNodeId IN (SELECT id FROM umbracoNode WHERE (path LIKE '%-21%' AND id!=-21) OR (path LIKE '%-20%' AND id!=-20));
    DELETE FROM umbracoDomains WHERE domainRootStructureID IN (SELECT id FROM umbracoNode WHERE (path LIKE '%-21%' AND id!=-21) OR (path LIKE '%-20%' AND id!=-20));
    DELETE FROM umbracoUser2NodePermission WHERE nodeId IN (SELECT id FROM umbracoNode WHERE (path LIKE '%-21%' AND id!=-21) OR (path LIKE '%-20%' AND id!=-20));
    DELETE FROM umbracorelation WHERE parentId IN (SELECT id FROM umbracoNode WHERE (path LIKE '%-21%' AND id!=-21) OR (path LIKE '%-20%' AND id!=-20));
    DELETE FROM umbracorelation WHERE childId IN (SELECT id FROM umbracoNode WHERE (path LIKE '%-21%' AND id!=-21) OR (path LIKE '%-20%' AND id!=-20));
    DELETE FROM umbracoredirecturl WHERE contentKey IN (SELECT uniqueID FROM umbracoNode WHERE (path LIKE '%-21%' AND id!=-21) OR (path LIKE '%-20%' AND id!=-20));
    ALTER TABLE `umbraconode` DROP FOREIGN KEY `umbraconode_ibfk_1`; 
    DELETE FROM umbracoNode WHERE (path LIKE '%-21%' AND id!=-21) OR (path LIKE '%-20%' AND id!=-20);
    ALTER TABLE `umbraconode` ADD CONSTRAINT `umbraconode_ibfk_1` FOREIGN KEY (`parentID`) REFERENCES `umbraconode`(`id`);
    

    Backup your DB before trying it.

  • Alex Skrypnyk 6132 posts 23951 karma points MVP 7x admin c-trib
    Jul 23, 2019 @ 22:56
    Alex Skrypnyk
    0

    Hi,

    Is this script works for the latest version?

    Thanks, Alex

  • David Challener 80 posts 444 karma points c-trib
    Jul 26, 2019 @ 11:13
    David Challener
    100

    Hi Alex,

    More or less, for content and not media I try to keep an eye on the content repository class to keep track of changes v7 contentrepository.cs

    The user permissions and redirect table have been added since.

    NB. Backup db and at your own risk caveat!

    DECLARE @nodeId int
    
    DECLARE node_cursor CURSOR FOR 
    SELECT Id
    FROM umbracoNode
    WHERE ParentId = -20
    
    OPEN node_cursor;
    
    FETCH NEXT FROM node_cursor 
    INTO @nodeId;
    
    WHILE @@FETCH_STATUS = 0
    BEGIN
        print @nodeId
    
    DELETE FROM umbracoRedirectUrl WHERE contentKey IN (SELECT uniqueID FROM umbracoNode WHERE id = @nodeId)
    DELETE FROM cmsTask WHERE nodeId = @nodeId
    DELETE FROM umbracoUser2NodeNotify WHERE nodeId = @nodeId
    DELETE FROM umbracoUserGroup2NodePermission WHERE nodeId = @nodeId
    DELETE FROM umbracoUserStartNode WHERE startNode = @nodeId
    UPDATE umbracoUserGroup SET startContentId = NULL WHERE startContentId = @nodeId
    DELETE FROM umbracoRelation WHERE parentId = @nodeId
    DELETE FROM umbracoRelation WHERE childId = @nodeId
    DELETE FROM cmsTagRelationship WHERE nodeId = @nodeId
    DELETE FROM umbracoDomains WHERE domainRootStructureID = @nodeId
    DELETE FROM cmsDocument WHERE nodeId = @nodeId
    DELETE FROM cmsPropertyData WHERE contentNodeId = @nodeId
    DELETE FROM cmsPreviewXml WHERE nodeId = @nodeId
    DELETE FROM cmsContentVersion WHERE ContentId = @nodeId
    DELETE FROM cmsContentXml WHERE nodeId = @nodeId
    DELETE FROM cmsContent WHERE nodeId = @nodeId
    DELETE FROM umbracoAccess WHERE nodeId = @nodeId
    DELETE FROM umbracoNode WHERE id = @nodeId    
    
        FETCH NEXT FROM node_cursor 
        INTO @nodeId
    END
    CLOSE node_cursor;
    DEALLOCATE node_cursor;
    

    EDIT: there is a media repository equivalent as well though.

Please Sign in or register to post replies

Write your reply to:

Draft