Copied to clipboard

Flag this post as spam?

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


  • Alex 21 posts 41 karma points
    Aug 25, 2010 @ 14:07
    Alex
    0

    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?

  • Morten Bock 1867 posts 2140 karma points MVP 2x admin c-trib
    Aug 25, 2010 @ 14:19
    Morten Bock
    0

    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.

  • Alex 21 posts 41 karma points
    Aug 25, 2010 @ 14:26
    Alex
    0

    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?

  • Morten Bock 1867 posts 2140 karma points MVP 2x admin c-trib
    Aug 25, 2010 @ 14:29
    Morten Bock
    0

    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.

  • Alex 21 posts 41 karma points
    Aug 25, 2010 @ 14:52
    Alex
    0

    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.

  • Morten Bock 1867 posts 2140 karma points MVP 2x admin c-trib
    Aug 25, 2010 @ 14:57
    Morten Bock
    0

    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.

  • Alex 21 posts 41 karma points
    Aug 25, 2010 @ 15:42
    Alex
    0

    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.

     

     

  • Morten Bock 1867 posts 2140 karma points MVP 2x admin c-trib
    Aug 25, 2010 @ 16:47
    Morten Bock
    0

    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.

Please Sign in or register to post replies

Write your reply to:

Draft