U4-9125 - NotSupportedException while retrieving unpublished content after upgrading to the latest version (7.5.4)

Created by Marcin Zajkowski 28 Oct 2016, 11:32:47 Updated by Callum Whyte 03 Nov 2016, 15:22:03

What did you do?

We've upgraded client's website from 7.2.8 to 7.5.4. We have a custom membership provider (implementing System.Web.Security.MembershipProvider) there and we're using Our.Umbraco.CoreValueConverters.

What did you expect to happen?

We expect the site to work as it was before.

What actually happened?

On some pages which has multinodetreepickers we started to observe errors thrown from the Umbraco.Core.dll. It's a NotSupportedExpection thrown from the MembershipHelper which says: "Cannot access this method unless the Umbraco membership provider is active". We tracked the class and the code which was causing the problem and it was thrown from https://github.com/umbraco/Umbraco-CMS/blob/5397f2c53acbdeb0805e1fe39fda938f571d295a/src/Umbraco.Web/Security/MembershipHelper.cs while we're retrieving data for property through the GetPropertyValue<IEnumerable>("alias") on our models.

What's important it's happening only when we're using totally custom membership provider. It's checking if our membership provider is inheriting from UmbracoMembershipProvider / UmbracoMembershipProvider base, and when it's not - throwing an error.

Then we discovered that problem and error is thrown when we have items which are unpublished inside the multinodetreepicker property values. Tracked down the request pipeline and it was thrown inside the CoreValueConverters when it was casting the nodeId of unpublished item into IPublishedContent object (using umbracoHelper instance and TypedContent(nodeId) method). We created a pull-request for CoreValueConverters now, when we're just catching all the errors basically during cration of IPublishedContent, but we believe it needs additional attention from Umbraco side and potential fix in the next releases.

1 Attachments

Download stacktrace.txt

Comments

Callum Whyte 03 Nov 2016, 15:22:03

I spoke with @sebastiaan about this issue and we have concluded that whilst the exception message thrown on MembershipHelper.cs:267 isn't hugely clear, having the IsUmbracoMembershipProvider check makes sense as MemberService.GetById will look at the umbracoMembers database table (which isn't necessarily appropriate for a custom membership provider).

Please see https://github.com/umbraco/Umbraco-CMS/blob/dev-v7/src/Umbraco.Web/Security/MembershipHelper.cs#L267

MemberService.GetById won't work with a custom .NET Membership Provider as the GetById method does not exist. Therefore, we can't make a call to MemberService.GetById if we arn't using an Umbraco Membership Provider.

Instead, we could simply return null when using a custom membership provider and then write to the Umbraco log instead of throwing an exception. This would allow sites to function but also notify the developer of the issue via the logs.


Priority: Normal

Type: Bug

State: Submitted

Assignee:

Difficulty: Normal

Category:

Backwards Compatible: True

Fix Submitted:

Affected versions:

Due in version:

Sprint:

Story Points:

Cycle: