Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Object reference not set to an instance of an object on empty Vorto #41

Closed
jbreuer opened this issue Mar 2, 2016 · 9 comments
Closed
Milestone

Comments

@jbreuer
Copy link
Contributor

jbreuer commented Mar 2, 2016

I tried to upgrade the 1-1 multilingual example to Vorto 1.5.

When I have an empty value in Vorto I get an Object reference not set to an instance of an object.
empty vorto

The error happens with the following code:

var urlSegment = this.GetVortoValue<string>("urlSegment", culture);
https://github.com/jbreuer/1-1-multilingual-example/blob/master/Sources/Umbraco.Extensions/Models/UmbMaster.cs#L55

This is the stack trace:

at Our.Umbraco.Vorto.Extensions.IPublishedContentExtensions.DoInnerGetVortoValue[T](IPublishedContent content, String propertyAlias, String cultureName, Boolean recursive, T defaultValue)
   at Our.Umbraco.Vorto.Extensions.IPublishedContentExtensions.DoGetVortoValue[T](IPublishedContent content, String propertyAlias, String cultureName, Boolean recursive, T defaultValue)
   at Our.Umbraco.Vorto.Extensions.IPublishedContentExtensions.GetVortoValue[T](IPublishedContent content, String propertyAlias, String cultureName, Boolean recursive, T defaultValue, String fallbackCultureName)
   at Umbraco.Extensions.Models.UmbMaster.GetUrlSegment(String culture) in d:\data\inetpub\1-1-multilingual-example\Sources\Umbraco.Extensions\Models\UmbMaster.cs:line 55
   at Umbraco.Extensions.UrlProviders.MultilingualUrlProvider.<>c__DisplayClass3.<GetUrl>b__0() in d:\data\inetpub\1-1-multilingual-example\Sources\Umbraco.Extensions\UrlProviders\MultilingualUrlProvider.cs:line 80
   at Umbraco.Core.Cache.CacheProviderExtensions.<>c__DisplayClass9`1.<GetCacheItem>b__8()
   at Umbraco.Core.Cache.DictionaryCacheProviderBase.<>c__DisplayClass1.<GetSafeLazy>b__0()

Do you need any more info?

@alecrt
Copy link

alecrt commented Mar 2, 2016

I can confirm the problem.
In 1.5 GetVortoValue has changed its behaviour when the value of the specified culture in not set. Now throws an exception.

@mattbrailsford
Copy link
Collaborator

@alecrt which line specifically are you referring to that has changed?

@alecrt
Copy link

alecrt commented Mar 2, 2016

Sorry @mattbrailsford didn't look at the source code still.

The exception thrown is "The given key was not present in the dictionary" and happens when a specific culture is passed as cultureName parameter in DoInnerGetVortoValue method.

So my guess is that something goes wrong here:

var bestMatchCultureName = vortoModel.FindBestMatchCulture(cultureName);
var value = vortoModel.Values[bestMatchCultureName];

mattbrailsford added a commit that referenced this issue Mar 2, 2016
@mattbrailsford
Copy link
Collaborator

I've added some additional null checking to that area in DoInnerGetVorotValue (it should have actually been the same checks that occur in HasVortoValue but for some reason they were less restrictive) so hopefully this should fix it. There is a new release on the build server if you guys fancy giving it a try and letting me know if this fixes it for you?

https://ci.appveyor.com/project/mattbrailsford/umbraco-vorto/build/1.5.1.36/artifacts

Cheers

Matt

@jbreuer
Copy link
Contributor Author

jbreuer commented Mar 3, 2016

I have upgraded to Our.Umbraco.Vorto.1.5.1-alpha-000036.nupkg and now it's fixed. Thanks for the quick response.

@mattbrailsford
Copy link
Collaborator

Awesome! Thanks for reporting the issue.

@alecrt
Copy link

alecrt commented Mar 3, 2016

Thanks!

@jbreuer
Copy link
Contributor Author

jbreuer commented Mar 6, 2018

I just upgraded from Vorto 1.5.3 to 1.6.0 and I get the same error again. Is it possible this somehow got reverted in the latest version?

@jbreuer
Copy link
Contributor Author

jbreuer commented Mar 6, 2018

I have downgraded back to Vorto 1.5.3 and the error is gone. Could this issue be reopened?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants