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.
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?
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`);
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;
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
but I only want to clear the recycle bin from media, not the content one as well.
This should have been fixed in Umbraco 4.6
Jeroen
Media recycle bin id is -21 ... you might have deleted a record reference to the media recycle bin using your script.
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?
That is correct. you need to look in why you can't delete.
For umbraco 7+ (currently last release 7.7.7) i made this script to empty both media and document trash folder:
Backup your DB before trying it.
Hi,
Is this script works for the latest version?
Thanks, Alex
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!
EDIT: there is a media repository equivalent as well though.
is working on a reply...