I've deleted a couple of media items via the Umbraco CMS and looks like they have deleted successfully because they get removed from the media folder in question.
Unfortunately when I query for media types using Media.getContentOfContentType() the apparently deleted media items are returned, therefore they must still be in the database. Is this correct behaviour, for Umbraco to keep them in the database?
Thanks for the quick reply Morten. I'm using Umbraco 4.0.3. I didn't know there was a recycle bin. Don't suppose you know how to query for media that isn't in the recycle bin?
Can't remember if the recycle bin is there in 4.0.3, But I guess you can see if it is in the media section or not.
I think there is a "path" property on the items you get returned from the method call. If that path starts with "-20", then the item is in the recycle bin.
Ah thanks for that. There doesn't seem to be a recycle bin icon in the Umbraco CMS. Could there be something wrong with the installation if it's not deleting the media from the database? The media type I created doesn't have a physical file associated with it, so it shouldn't be failing trying to delete anything on the filesystem.
In that case, it sounds like you are right in assuming there is some kind of bug going on here. If they are deleted, they should be gone from the database, and if they are in the database, they should appear in the UI.
You could check the umbracoLog table and see if there are any errors around the time you deleted the media items.
Ah I've got it. It seems that Media.getContentOfContentType() method was returning content that had a document type with the same name. Naughty method, should really only be returning media content! So after all that the media items must have been getting deleted properly.
Media not deleting from database
I've deleted a couple of media items via the Umbraco CMS and looks like they have deleted successfully because they get removed from the media folder in question.
Unfortunately when I query for media types using Media.getContentOfContentType() the apparently deleted media items are returned, therefore they must still be in the database. Is this correct behaviour, for Umbraco to keep them in the database?
Are the media items still in the recycle bin? (Which version of umbraco are you using?)
Could be that the method does not take into consideration if the item is in the bin.
Thanks for the quick reply Morten. I'm using Umbraco 4.0.3. I didn't know there was a recycle bin. Don't suppose you know how to query for media that isn't in the recycle bin?
Can't remember if the recycle bin is there in 4.0.3, But I guess you can see if it is in the media section or not.
I think there is a "path" property on the items you get returned from the method call. If that path starts with "-20", then the item is in the recycle bin.
Ah thanks for that. There doesn't seem to be a recycle bin icon in the Umbraco CMS. Could there be something wrong with the installation if it's not deleting the media from the database? The media type I created doesn't have a physical file associated with it, so it shouldn't be failing trying to delete anything on the filesystem.
In that case, it sounds like you are right in assuming there is some kind of bug going on here. If they are deleted, they should be gone from the database, and if they are in the database, they should appear in the UI.
You could check the umbracoLog table and see if there are any errors around the time you deleted the media items.
Ah I've got it. It seems that Media.getContentOfContentType() method was returning content that had a document type with the same name. Naughty method, should really only be returning media content! So after all that the media items must have been getting deleted properly.
Ahhh. Probably because the method is inherited from the Content class, which is the base of all types of content in umbraco. Good to know.
is working on a reply...