U4-6702 - Culture not being set correctly using UmbracoVirtualNodeHandler (wildcard domains not handled correctly)

Created by Asbjørn Riis-Knudsen 14 Jun 2015, 14:05:34 Updated by Asbjørn Riis-Knudsen 16 Jun 2015, 12:48:10

I have a multilingual site where I use a UmbracoVirtualNodeHandler in a couple of different places. This works well, apart from the fact that the culture does not get set correctly. Example: I have a page at /de/suchen using a UmbracoVirtualNodeHandler. You would expect this page to get the "de" culture like /de/haefen which is a real Umbraco node, but it does not. It gets the default culture ("da") in this case.

From looking at the Umbraco source, I think the issue comes from this code (PublishedContentRequestEngine.cs, line 77) //find the published content if it's not assigned. This could be manually assigned with a custom route handler, or // with something like EnsurePublishedContentRequestAttribute or UmbracoVirtualNodeRouteHandler. Those in turn call this method // to setup the rest of the pipeline but we don't want to run the finders since there's one assigned. if (_pcr.PublishedContent == null) { // find the document & template FindPublishedContentAndTemplate();

// set the culture on the thread -- again, 'cos it might have changed due to a wildcard domain
Thread.CurrentThread.CurrentUICulture = Thread.CurrentThread.CurrentCulture = _pcr.Culture;

}

This code says that if the PublishedContent is already set (as it is when using the UmbracoVirtualNodeHandler), it will skip calling FindPublishedContentAndTemplate() - which is probably fine.

BUT - FindPublishedContentAndTemplate() also calls HandleWildcardDomains(). This means that when using UmbracoVirtualNodeHandler, HandleWildcardDomains() is never called. Hence the problem.

My solution is to simply move the call to HandleWildcardDomains out of the FindPublishedContentAndTemplate() method and place it directly after the if statement quoted above. This works fine in my very limited testing so far.

Pull request here: https://github.com/umbraco/Umbraco-CMS/pull/712

Comments

Stephan 15 Jun 2015, 12:58:59

Fixed: 52c33055af1ab9410ad1ae63568cbcd9f477b4a2


Vincent Baaij 15 Jun 2015, 13:59:56

@zpqrtbnk Does this also fix the error for when there is no domain set on a node but there is a culture set? In my implementation the virtual nodes always got assigned the default (en) culture in this case. If not, should I raise an issue for that?


Asbjørn Riis-Knudsen 15 Jun 2015, 15:07:19

@Vincent This is exactly the issue I describe here and the fix as well. So this should definitely fix it - though I haven't tested it yet.


Stephan 15 Jun 2015, 15:34:12

@vincentb - another issue I'd say. @arknu - would be great if you could test


Asbjørn Riis-Knudsen 15 Jun 2015, 20:03:17

@zpqrtbnk Isn't the problem that @vincentb describes exactly the same as I describe in this issue? It seems that way to me...

I shall test it tomorrow.


Asbjørn Riis-Knudsen 16 Jun 2015, 12:48:10

Verified fixed in newest 7.3.0 build. The culture is now set correctly when using virtual nodes. Thanks!


Priority: Normal

Type: Bug

State: Fixed

Assignee: Stephan

Difficulty: Normal

Category:

Backwards Compatible: True

Fix Submitted: Pull request

Affected versions: 7.2.6

Due in version: 7.3.0

Sprint:

Story Points:

Cycle: