From ab35508894e63f15e143e4563e788153e175e566 Mon Sep 17 00:00:00 2001 From: Mike Alhayek Date: Fri, 19 Jul 2024 14:23:22 -0700 Subject: [PATCH 1/2] Correct zero length check expressions --- .../Controllers/AdminController.cs | 2 +- .../Drivers/FlowPartDisplayDriver.cs | 2 +- .../Settings/MediaFieldSettingsDriver.cs | 2 +- .../Views/AzureAISearchSettings.Edit.cshtml | 2 +- .../DefaultContentManager.cs | 2 +- .../Services/DefaultQueryManager.cs | 2 +- .../Recipes/AzureAISearchIndexSettingsStep.cs | 16 +++++++++++----- .../ElasticConnectionOptionsConfigurations.cs | 2 +- 8 files changed, 18 insertions(+), 12 deletions(-) diff --git a/src/OrchardCore.Modules/OrchardCore.Flows/Controllers/AdminController.cs b/src/OrchardCore.Modules/OrchardCore.Flows/Controllers/AdminController.cs index db2c0cd9e69..0c639eebe1e 100644 --- a/src/OrchardCore.Modules/OrchardCore.Flows/Controllers/AdminController.cs +++ b/src/OrchardCore.Modules/OrchardCore.Flows/Controllers/AdminController.cs @@ -111,7 +111,7 @@ private async Task> GetContainedContentTypesA { var settings = (await _contentDefinitionManager.GetTypeDefinitionAsync(contentType))?.Parts.SingleOrDefault(x => x.Name == partName)?.GetSettings(); - if (settings?.ContainedContentTypes?.Length == 0) + if (settings?.ContainedContentTypes == null || settings.ContainedContentTypes.Length == 0) { return (await _contentDefinitionManager.ListTypeDefinitionsAsync()).Where(t => t.StereotypeEquals("Widget")); } diff --git a/src/OrchardCore.Modules/OrchardCore.Flows/Drivers/FlowPartDisplayDriver.cs b/src/OrchardCore.Modules/OrchardCore.Flows/Drivers/FlowPartDisplayDriver.cs index 9f361066cd5..efbd89db5d2 100644 --- a/src/OrchardCore.Modules/OrchardCore.Flows/Drivers/FlowPartDisplayDriver.cs +++ b/src/OrchardCore.Modules/OrchardCore.Flows/Drivers/FlowPartDisplayDriver.cs @@ -132,7 +132,7 @@ private async Task> GetContainedContentTypesA { var settings = typePartDefinition.GetSettings(); - if (settings?.ContainedContentTypes?.Length == 0) + if (settings?.ContainedContentTypes == null || settings.ContainedContentTypes.Length == 0) { return (await _contentDefinitionManager.ListTypeDefinitionsAsync()) .Where(t => t.StereotypeEquals("Widget")); diff --git a/src/OrchardCore.Modules/OrchardCore.Media/Settings/MediaFieldSettingsDriver.cs b/src/OrchardCore.Modules/OrchardCore.Media/Settings/MediaFieldSettingsDriver.cs index ff290147dd0..47c63661ea4 100644 --- a/src/OrchardCore.Modules/OrchardCore.Media/Settings/MediaFieldSettingsDriver.cs +++ b/src/OrchardCore.Modules/OrchardCore.Media/Settings/MediaFieldSettingsDriver.cs @@ -41,7 +41,7 @@ public override IDisplayResult Edit(ContentPartFieldDefinition partFieldDefiniti model.Multiple = settings.Multiple; model.AllowMediaText = settings.AllowMediaText; model.AllowAnchors = settings.AllowAnchors; - model.AllowAllDefaultMediaTypes = settings.AllowedExtensions?.Length == 0; + model.AllowAllDefaultMediaTypes = settings.AllowedExtensions == null || settings.AllowedExtensions.Length == 0; var items = new List(); foreach (var extension in _mediaOptions.AllowedFileExtensions) diff --git a/src/OrchardCore.Modules/OrchardCore.Search.AzureAI/Views/AzureAISearchSettings.Edit.cshtml b/src/OrchardCore.Modules/OrchardCore.Search.AzureAI/Views/AzureAISearchSettings.Edit.cshtml index 5b8e1ec43ea..a1836ac1de4 100644 --- a/src/OrchardCore.Modules/OrchardCore.Search.AzureAI/Views/AzureAISearchSettings.Edit.cshtml +++ b/src/OrchardCore.Modules/OrchardCore.Search.AzureAI/Views/AzureAISearchSettings.Edit.cshtml @@ -28,7 +28,7 @@ return; } -@if (Model.SearchIndexes == null || Model.SearchIndexes?.Count == 0) +@if (Model.SearchIndexes == null || Model.SearchIndexes.Count == 0) {