U4-2157 - Importing a template that already exists does not update the design as of changeset 0507c4271499

Created by Adam Nelson 26 Apr 2013, 02:03:07 Updated by Sebastiaan Janssen 26 Apr 2013, 08:42:09

There were some changes in http://umbraco.codeplex.com/SourceControl/changeset/0507c4271499 related to U4-1009 and U4-1010 and masterpage handling for MVC (which looks to be for the 4.9.1 release).

I use the {{umbraco.cms.businesslogic.template.Template.Import()}} method as a way to push in template updates programmatically from source control (and macros, doctypes and datatypes too - our.umbraco.org project coming soon!). However the change in {{0507c4271499}} means that existing templates never have their design updated.

Previous method in {{umbraco.cms.businesslogic.template.Template}}:

public static Template Import(XmlNode n, User u) { string alias = xmlHelper.GetNodeValue(n.SelectSingleNode("Alias"));

Template t = Template.GetByAlias(alias);

if (t == null)
{
    t = MakeNew(xmlHelper.GetNodeValue(n.SelectSingleNode("Name")), u);
}

t.Alias = alias;

t.ImportDesign(xmlHelper.GetNodeValue(n.SelectSingleNode("Design")));

return t;

}

Since 0507c4271499, the code to actually import the design has been removed ''for existing templates'' (it gets imported ok only for new templates):

public static Template Import(XmlNode n, User u) { string alias = xmlHelper.GetNodeValue(n.SelectSingleNode("Alias"));

Template t = Template.GetByAlias(alias);
var design = xmlHelper.GetNodeValue(n.SelectSingleNode("Design"));

if (t == null)
{
    //create the template with the design if one is specified
    t = MakeNew(xmlHelper.GetNodeValue(n.SelectSingleNode("Name")), u, 
    design.IsNullOrWhiteSpace() ? null : design);
}

t.Alias = alias;

return t;

}

I have no problem changing my code to also call ImportDesign() after Import() - however since this was a breaking change on a public interface I thought it should be raised.

Cheers.

Comments

Sebastiaan Janssen 26 Apr 2013, 08:42:01

Okay. Yes, you will need to update your code. Since this has been in place for half a year now it would be another breaking change to revert this change so we're going to leave it as it is now.


Priority: Normal

Type: Bug

State: Closed

Assignee:

Difficulty: Easy

Category:

Backwards Compatible: True

Fix Submitted:

Affected versions: 4.10.0, 4.11.0, 4.9.1, 4.11.1, 4.11.2, 4.11.3, 4.11.4, 4.11.5, 4.11.6, 4.11.7

Due in version:

Sprint:

Story Points:

Cycle: