mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2026-01-23 13:22:08 +08:00
Added null check on taxonomyPart. (#8664)
This commit is contained in:
committed by
GitHub
parent
4455c66a64
commit
ff70011b69
@@ -1,5 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Web.Management;
|
||||||
using Orchard.ContentManagement;
|
using Orchard.ContentManagement;
|
||||||
using Orchard.Core.Title.Models;
|
using Orchard.Core.Title.Models;
|
||||||
using Orchard.Environment.Extensions;
|
using Orchard.Environment.Extensions;
|
||||||
@@ -30,6 +31,11 @@ namespace Orchard.Taxonomies.Services {
|
|||||||
.Where(r => r.Title == name)
|
.Where(r => r.Title == name)
|
||||||
.List()
|
.List()
|
||||||
.FirstOrDefault();
|
.FirstOrDefault();
|
||||||
|
// Null check on taxonomyPart
|
||||||
|
// It can be null in the case of a TaxonomyField with not taxonomy selected (misconfiguration).
|
||||||
|
if (taxonomyPart == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
if (String.IsNullOrWhiteSpace(culture) || _localizationService.GetContentCulture(taxonomyPart.ContentItem) == culture)
|
if (String.IsNullOrWhiteSpace(culture) || _localizationService.GetContentCulture(taxonomyPart.ContentItem) == culture)
|
||||||
return taxonomyPart;
|
return taxonomyPart;
|
||||||
else {
|
else {
|
||||||
|
|||||||
Reference in New Issue
Block a user