Copied to clipboard

Flag this post as spam?

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


  • Neil 63 posts 105 karma points
    Aug 30, 2013 @ 15:54
    Neil
    0

    Template Files Reappearing after Deletion in VS2010

    I know that the integration between umbraco and VS2010 isn't perfect.  For example, things linger in umbraco because it stores things in flat files like umbraco.config.  In general, when I delete things like document types or make certain kinds of changes to document properties in them, in VS I delete the umbraco.config, clean the solution and rebuilt before running the CMS.  After that, I know the db keeps some things around, so I go into the Settings section and delete the approprite document properties, etc.

    That said, I haven't yet figured out where umbraco is storing certain master pages/templates since, when I delete certain ones of those, when I clean and rebuild, the files will reappear (thought not included in the project).  Can anyone tell me where the reference to these deleted templates lives in the umbraco SiteBuilder code so that I can get rid of them permanently?

  • Funka! 398 posts 661 karma points
    Aug 31, 2013 @ 19:27
    Funka!
    0

    A copy of master pages and views are kept in the database, in the cmsTemplate table. It's possible the system keeps rebuilding the missing files based on the record it finds in the database?

    With that said, I suppose it's possible if you deleted the template file as well as deleted the corresponding template row in the database, this would work for you, but be very careful of all of the references which may or may not be protected via referential integrity. For example, documents (current published version as well as any older saved versions) relate to templates, as well as document types or cached information of course. So it's probably best to delete through the admin UI whenever possible.

    Best of luck!

  • Neil 63 posts 105 karma points
    Aug 31, 2013 @ 19:55
    Neil
    0

    Yeah, the persisting reference had to be in the db or in a flat file somewhere.  I hate touching the db directly, so will try deleting through the admin ui first.  Though I've noticed that when things have been partially removed in umbraco, that you can get a yellow screen when trying to delete them through the ui.  This usually means donning your headlamp and going spelunking through the tables and their foreign keys to eradicate the pest entirely. :-)

  • Funka! 398 posts 661 karma points
    Sep 03, 2013 @ 19:26
    Funka!
    0

    Some added notes for posterity on this:

    Yes, there currently is (as of 6.1.x at least) a strong dependency between the file on disk and a matching row for it in the database. It is recommended to thus always first attempt to delete a template from the admin UI only, just as you must for creating a template as well in order to keep the database in synch. In rare cases, bugs or other types of development scenarios means you might have to spelunk through the DB to clean up templates that won't delete, reassign or nullify references, etc., but is certainly not the recommended approach. (Love your spelunking metaphor on this!)

    But now my note for posterity is that this may become simpler in the future; there are plans to one day de-couple the file on disk entirely from the database row, and just use what's on disk, I think. See U4-59 to follow the progress on this.

  • Neil 63 posts 105 karma points
    Sep 24, 2013 @ 15:58
    Neil
    0

    Some further posterior notes:

    I found that most of the time, the trouble can be dealt with by going into Settings through the CMS and opening up Templates.  There, you will usually find the persisting template file and if you delete it there and from the source in VS after it's creation has been forced by its presence in the db, it will not be re-created.  That said, there are times when the CMS won't let you delete the template file.  To address it, I attempted to delete the dead templates from cms.Template.  There is a foreign key dependency between the nodeId column in that table and the templateId column in cms.Document.  However, when deleting all nodes with the templateId matching the dead node's nodeId in cms.Document and then deleting the dead nodes in cms.Template, it broke something because trying to run the site gave me a missing Object reference error.  Thank goodness I backed it up.  When I figure out the issue, I'll post more.

  • Funka! 398 posts 661 karma points
    Sep 24, 2013 @ 22:54
    Funka!
    0

    My approach when dealing with the dreadful foreign key reference error when trying to delete templates through the admin UI, has been to set referencing TemplateID values from cmsDocument to NULL, rather than deleting the row. This is because as you noted, more and more stuff relates to these rows so the easiest approach is to just un-assign the template rather than nuking the document. Although the UI should be pretty good at deleting templates for you, there are still cases where you do run into this error. See U4-2356 for example.

  • Neil 63 posts 105 karma points
    Sep 24, 2013 @ 23:01
    Neil
    0

    Great.  I'll give it a go and report back.

  • Funka! 398 posts 661 karma points
    Sep 24, 2013 @ 23:17
    Funka!
    0

    My approach when dealing with the dreadful foreign key reference error when trying to delete templates through the admin UI, has been to set referencing TemplateID values from cmsDocument to NULL, rather than deleting the row. This is because as you noted, more and more stuff relates to these rows so the easiest approach is to just un-assign the template rather than nuking the document/revision. Although the UI should be pretty good at de-referencing these for you when you delete templates, but there are still cases where you do run into this error. See U4-2356 for example.

Please Sign in or register to post replies

Write your reply to:

Draft