Can't get ride of templates from backoffice even though they don't exist anywhere

I have a couple of templates that show up under the “templates” folder in my backoffice but they don’t exist. I looked at the files in the views folder on disk and they are not there, the document types they where assoicated with are deleted, and the content nodes that where made based off those document types have been deleted as well. If I click the “reload” button in either the templates folder of the broken template nothing happens. If I click the broken template it will load a template editor screen but it has no code in the text box and I can’t choose any button options ( they are all grayed out). what do I need to do to get rid of these broken templates?

Hi @Eaglef90

The views are most likely compiled into an RCL, so you won’t see them on disk anyway. When running in production runtime mode they are in the RCL and you cannot edit the templates in the backoffice.

Do you have uSync installed which may be recreating the templates? Although that would also recreate the documents types too if that were the case and uSync was running import on startup.

Did you use uSync to delete the document types and templates and push this through your environments or did you delete directly on live?

Maybe worth checking what you see in the cmsTemplate table in the database.

Justin

I see all the other templates on disk, the ones that are supposed to be there anyways. I have been using usync compleate and used that to move them up but running it again after deleting them localy, checking in my changes to git which pushes a new build to the server, does not remove the bad templates. I do see them listed in the cmsTemplate. Ideas on how to remove? I am still in testing/dev, should I swap to backoffice-development mode? Would that let me delete them via the back office interface?

Hi @Eaglef90

Are you able to see if uSync recorded the delete in it’s file for the template? If so, what happens when you let uSync run the import, does it attempt to delete the template entry and fail? Or is it not picked up at all? Do you have any errors in the Umbraco log when you try this?

You could try changing the runtime mode temporarily to see if you can delete via the backoffice, but that will just use the same underlying APIs as uSync ultimately…

Justin

I am not very familare with usync so I don’t know itlf it recorded it or not and don’t know how to check. I will try a sync down to local dev and see what happens. If they appears will try to delete lcoal and push up. If that fails I will try to set ad backoffice-dev or just wioe the db and start over, I would only loose a fee doc types that I can sync back up

Hi @Eaglef90

If you deleted it locally it will get recorded as a delete in the uSync file, just push that through your environments and import on ach environment and it should replay the delete there as well.

Justin

It appears as though usync did puckup the changes. The big thing is that these oprphan templates exist no where in dev and only exist in the templates folder on the prod server inside the backoffice, there is no corisponding cshtml file in the views folder for them. I don’t know how the two systems got out of sync like this,

Hi @Eaglef90

What happens when you uSync on production? Does it see the templates and try to delete them?

Justin

If I pull from production to local it will pull down the templates but no files are created. I have gone so far as to do a clean export on local, nuke all files from production (but leave DB intact), redepoy to production and do a clean import. The bad templates are all still there. I am not at the point where I think I have to pay my host to wipe the db, my github repo, and build a new instance just so I can be sure that there is nothing else orphaned.

To be clear on one point though, setting backofficedevlepment for the runtime mode on prod lets me delete the templates but now I am worreid that other orphanded stuff I can’t see exists in the db and is going to screw me over at a point where I can’t afford it.

Hi @Eaglef90

Is the uSync file for the template on production with a delete action (look inside the file), if it is, uSync should just delete the template.

It’s difficult to tell what other orphaned stuff you may have (if any), and I don’t know why it got orphaned in the first place without being deleted fully.

If the orphaned templates are not causing an issue then leave them, as long as you’ve got no issues elsewhere and no errors that fingers crossed you are ok.

Justin

No there is no file on prod to mark the template for deletion. Since I know I can delete it now from the backoffice since the runtime is backofficedevelopemtn I am not so worried about the template. I am more worried that other things are broken/out of synce from local dev and that once the site goes public I might start running into problems down the road.

Hi @Eaglef90

Do a uSync export from both and compare the results. Don’t do a clean export, as these removes the files with the rename/delete actions, which you will most likely need.

If you’re confident dev is ok, then just do a uSync export there, push to prod and run report to see what it would change.

Justin

At one point I had already done a clean export on prod. I did do another round of exports on both dev and prod and the only file prod made that was not in dev was the templates. Which I just deleted from prod.

Hi @Eaglef90

If you deleted the uSync file on prod that had the delete instruction in it before you had chance to run the uSync import that would be your issue. Did you manage to delete the template manually after changing the runtime mode on prod?

If that’s the issue, then it sounds like everything else should be ok?

Justin

Yes, changing the runtime mode allowed me to delete the template. I just hope that was the only discrepancy.

Hi @Eaglef90

It sounds like just the affected templates then if you deleted the uSync files before running uSync import.

Justin