umco / umbraco-ditto

Ditto - the friendly view-model mapper for Umbraco
http://our.umbraco.org/projects/developer-tools/ditto
MIT License
79 stars 33 forks source link

Properties from an included document type (content composition) do not appear to get mapped #100

Closed rustyswayne closed 9 years ago

rustyswayne commented 9 years ago

I have a simple document type 'Home' which has no properties and I've included a 'LanndPageHeading' document type which defines a single property "headline" which does not appear to be mapped by Ditto.

I'm using the DittoPublishedContentModelFactory

Latest version from NuGet.

rustyswayne commented 9 years ago

Follow up - Looks like a little caching issue. In my case, I had the headline originally on the Home content type and needed to use it on several other pages so I created the second content type "LandingPageHeading" to use in a composition for several other pages.

Doing this straight through the back office does not update the mapping but once the application pool resets, everything works as expected.

leekelleher commented 9 years ago

Thanks @rustyswayne, I'll take a look. Sounds like we're aggressively caching. I'll keep you posted.

JimBobSquarePants commented 9 years ago

@leekelleher @rustyswayne Agreed. Looks to me like this is the issue.

https://github.com/leekelleher/umbraco-ditto/blob/a825ca870d3f4a87c6ec6d08b73a7cffad41b73c/src/Our.Umbraco.Ditto.ModelFactory/DittoPublishedContentModelFactory.cs#L81

Making the Dictionary internal static and rebuilding it out in an event handler would probably do the trick.

JimBobSquarePants commented 9 years ago

Hi @rustyswayne I've been having a look at this again and I'm going to need a little bit more information to see what is going on and how best to avoid the issue.

As I understand it you were moving a property from your Home document type into a composite LandingPage document type. You did all this through the back office.

Were there any code changes to prompt a rebuild during this change?

I'm trying to figure out why the ApplicationStarting event is not getting triggered if so.

leekelleher commented 9 years ago

Just having a look over our model-factory code to see what the issue might be, but I'm struggling to figure out what we're caching that could be effected by this?

In the DittoPublishedContentModelFactory class, we have a private dictionary lookup called converterCache, which contains a DocType alias and a Func<> - in which the Func<> is only a call to .As(). So I can't see how changes to DocTypes in the back-office would affect this.

Ditto works purely from the IPublishedContent object, not the DocType... so I'm unsure where the caching issue is happening.


@rustyswayne - do you still see this as an issue, or a glitch that happened during dev?

JimBobSquarePants commented 9 years ago

@leekelleher That matches my analysis so far also.

rustyswayne commented 9 years ago

@JimBobSquarePants - sorry I missed your comment a week ago. In regards to ApplicationStarting event, all I did was to put a space in the web.config (and save) to check to see if it might be a run time cache issue.

@leekelleher Once I got the cache cleared I have not seen the issue again, albeit I have not made any changes either.

It may have been a glitch in dev ... if I see it again when I work with it next, I'll come back and comment on the issue.

leekelleher commented 9 years ago

Thanks @rustyswayne.

I'll set this issue as closed, then it can be reopened if happens again.

JimBobSquarePants commented 9 years ago

@rustyswayne No worries. If anything comes up again give us a shout.