From 4d326e9f78239452c7eeccedfb0b4ab5d4563851 Mon Sep 17 00:00:00 2001 From: Mike Williamson <89110166+PBMikeW@users.noreply.github.com> Date: Sun, 20 Nov 2022 04:13:21 +1300 Subject: [PATCH] Fix NRE on migration from 1.4 -> 1.5 due to Lucene changes (#12831) --- .../OrchardCore.Search.Lucene/Migrations.cs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/OrchardCore.Modules/OrchardCore.Search.Lucene/Migrations.cs b/src/OrchardCore.Modules/OrchardCore.Search.Lucene/Migrations.cs index e45b666d5a3..d6bc1ee651f 100644 --- a/src/OrchardCore.Modules/OrchardCore.Search.Lucene/Migrations.cs +++ b/src/OrchardCore.Modules/OrchardCore.Search.Lucene/Migrations.cs @@ -42,14 +42,14 @@ public int Create() { if (analyzed != null) { - if ((bool)included) + if ((bool)included && !(bool)analyzed) { existingPartSettings["Keyword"] = true; } } else { - if ((bool)included && !(bool)analyzed) + if ((bool)included) { existingPartSettings["Keyword"] = true; } @@ -85,14 +85,14 @@ public int Create() { if (analyzed != null) { - if ((bool)included) + if ((bool)included && !(bool)analyzed) { existingPartSettings["Keyword"] = true; } } else { - if ((bool)included && !(bool)analyzed) + if ((bool)included) { existingPartSettings["Keyword"] = true; } @@ -119,16 +119,16 @@ public int Create() if (included != null) { - if (analyzed == null) + if (analyzed != null) { - if ((bool)included) + if ((bool)included && !(bool)analyzed) { existingFieldSettings["Keyword"] = true; } } else { - if ((bool)included && !(bool)analyzed) + if ((bool)included) { existingFieldSettings["Keyword"] = true; } @@ -178,7 +178,7 @@ public int Create() var updateCmd = $"UPDATE {dialect.QuoteForTableName(table, session.Store.Configuration.Schema)} SET Content = REPLACE(content, '\"$type\":\"OrchardCore.Lucene.LuceneQuery, OrchardCore.Lucene\"', '\"$type\":\"OrchardCore.Search.Lucene.LuceneQuery, OrchardCore.Search.Lucene\"') WHERE [Type] = 'OrchardCore.Queries.Services.QueriesDocument, OrchardCore.Queries'"; await transaction.Connection.ExecuteAsync(updateCmd, null, transaction); - + updateCmd = $"UPDATE {dialect.QuoteForTableName(table, session.Store.Configuration.Schema)} SET Content = REPLACE(content, '\"$type\":\"OrchardCore.Lucene.Deployment.LuceneIndexDeploymentStep, OrchardCore.Lucene\"', '\"$type\":\"OrchardCore.Search.Lucene.Deployment.LuceneIndexDeploymentStep, OrchardCore.Search.Lucene\"') WHERE [Type] = 'OrchardCore.Deployment.DeploymentPlan, OrchardCore.Deployment.Abstractions'"; await transaction.Connection.ExecuteAsync(updateCmd, null, transaction);