Tuesday 20 December 2011

Lost templates and document types in Umbraco Settings tree

Today we came across an issue where the Umbraco Templates tree in Settings was not being populated and when we tried to edit a Document Type we got the following error:

Object reference not set to an instance of an object.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

Source Error:


Line 49:         public string MasterPageFile
Line 50:         {
Line 51:             get { return IOHelper.MapPath( SystemDirectories.Masterpages  
+ "/" + Alias.Replace(" ", "") + ".master") ; }
Line 52:         }
Line 53: 

Source File: C:\Projects\288Group\WestminsterCollection\Shared\Umbraco\cms\businesslogic\template\Template.cs    Line: 51

Stack Trace:


[NullReferenceException: Object reference not set to an instance of an object.]
   umbraco.cms.businesslogic.template.Template.get_MasterPageFile() in C:\Projects
\288Group\WestminsterCollection\Shared\Umbraco\cms\businesslogic\template\Template.cs:51
   umbraco.cms.businesslogic.template.Template.getMasterPageContent() in C:\Projects\
288Group\WestminsterCollection\Shared\Umbraco\cms\businesslogic\template\Template.cs:153
   umbraco.cms.businesslogic.template.Template.setupNode() in C:\Projects\288Group\
WestminsterCollection\Shared\Umbraco\cms\businesslogic\template\Template.cs:141
   umbraco.cms.businesslogic.CMSNode..ctor(Guid uniqueID) in C:\Projects\288Group\
WestminsterCollection\Shared\Umbraco\cms\businesslogic\CMSNode.cs:341
   umbraco.cms.businesslogic.template.Template..ctor(Guid id) in C:\Projects\288Group
\WestminsterCollection\Shared\Umbraco\cms\businesslogic\template\Template.cs:63
   umbraco.cms.businesslogic.template.Template.GetAllAsList() in C:\Projects\288Group
\WestminsterCollection\Shared\Umbraco\cms\businesslogic\template\Template.cs:365
   umbraco.settings.EditContentTypeNew.bindTemplates() in C:\Projects\288Group\
WestminsterCollection\Shared\Umbraco\presentation\umbraco\settings\
EditNodeTypeNew.aspx.cs:56
   umbraco.settings.EditContentTypeNew.Page_Load(Object sender, EventArgs e) 
in C:\Projects\288Group\WestminsterCollection\Shared\Umbraco\presentation\umbraco
\settings\EditNodeTypeNew.aspx.cs:35
   System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14
   System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35
   System.Web.UI.Control.OnLoad(EventArgs e) +99
   umbraco.BasePages.BasePage.OnLoad(EventArgs e) in C:\Projects\288Group
\WestminsterCollection\Shared\Umbraco\businesslogic\BasePages\BasePage.cs:325
   System.Web.UI.Control.LoadRecursive() +50
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint
, Boolean includeStagesAfterAsyncPoint) +627


After doing some digging around we found the answer was that one of the cmsTemplate records was missing from the database.

select * 
from UmbracoNode n 
left join cmsTemplate t on t.nodeid = n.id
where n.nodeObjectType = '6FBDE604-4178-42CE-A10B-8A2600A2F07D'

The fix is to either create a new record for this (we were able to do this because the error was on our development site and we copied the live record back) or to remove the umbracoNode record. Either wat you then fix this broken relationship and fixes the problem.

As usual the Umbraco site is invaluable!

http://forum.umbraco.org/yaf_postst8368_Losing-templates-from-tree.aspx

I have no idea how this record was removed but it is possible that it happened during our weekly live to dev copy of the database or something crashed during a delete of that template.

No comments:

Post a Comment