1
Vote

BlogPostPartHandler NullReferenceException

description

Happens in 1.7.1 for each request in admin zone.

BlogPostPartHandler.GetContentItemMetadata
     if (blogPost == null)
                return;
blogPost is not null
 context.Metadata.CreateRouteValues = new RouteValueDictionary {
                {"Area", "Orchard.Blogs"},
                {"Controller", "BlogPostAdmin"},
                {"Action", "Create"},
                {"blogId", blogPost.BlogPart.Id}
            };
blogPost.BlogPart is null

blogPost.ContentItem.Id = 0

comments

sebastienros wrote Feb 4 at 7:54 PM

Can you please provide a repro to get in that state ?

x0r wrote Feb 5 at 9:39 AM

I tried to look for any specifics to my project and i tracked this issue to a point where the admin menu is built, context.ContentItem.As<BlogPostPart>() is not null, yet its Id==0.

Now I figured that it is coming from menu New -> Blog Post. I changed the Blog Post Content type not to be Creatable and the issue is gone.

The reason I made it createable is i utilize the Content Picker Field for selecting related blogposts and other content types. When i started to use that field, it wasn't possible filter it to a not-creatable ContentType - unlike now and i forgot to make it non-creatable again...

Sorry for the inconvenience Sebastien...