Merge branch 'issue/8684' into issue/8686-dev

# Conflicts:
#	.github/workflows/compile.yml
#	src/Orchard.Specs/Hosting/Orchard.Web/Web.config
#	src/Orchard.Web/Modules/Orchard.JobsQueue/Tests/Orchard.Messaging.Tests.csproj
This commit is contained in:
Benedek Farkas
2023-06-28 17:18:13 +02:00
11 changed files with 96 additions and 113 deletions

View File

@@ -2,6 +2,11 @@ name: Compile
on:
workflow_dispatch:
pull_request:
push:
branches:
- dev
- 1.10.x
jobs:
compile:
@@ -22,15 +27,7 @@ jobs:
uses: microsoft/setup-msbuild@v1.3.1
- name: Compile
run: msbuild Orchard.proj /m /t:Compile /p:MvcBuildViews=true /p:TreatWarningsAsErrors=true -WarnAsError /bl:Orchard.binlog
- name: Upload MSBuild Binary Log
uses: actions/upload-artifact@v3.1.1
if: success() || failure()
with:
name: Orchard-${{ github.sha }}-${{ github.run_number }}.binlog
path: Orchard.binlog
if-no-files-found: ignore
run: msbuild Orchard.proj /m /t:Compile /p:MvcBuildViews=true /p:TreatWarningsAsErrors=true -WarnAsError
- name: Test
run: msbuild Orchard.proj /m /t:Test

View File

@@ -123,9 +123,6 @@
<Compile Include="Visitors\WhereArgumentsVisitor.cs" />
</ItemGroup>
<ItemGroup>
<None Include="..\NH.Linq.snk">
<Link>NH.Linq.snk</Link>
</None>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>

View File

@@ -1,15 +1,7 @@
using System;
using NUnit.Framework;
using Orchard.ContentManagement;
using Orchard.ContentManagement.Aspects;
using Orchard.Core.Contents;
using Orchard.Data;
using Orchard.Security;
using Orchard.Security.Permissions;
using System.Linq;
using Orchard.Localization.Services;
using Orchard.Specs.Hosting.Orchard.Web;
using TechTalk.SpecFlow;
using Orchard.Localization.Services;
using System.Linq;
namespace Orchard.Specs.Bindings {
[Binding]
@@ -20,7 +12,7 @@ namespace Orchard.Specs.Bindings {
var webApp = Binding<WebAppHosting>();
webApp.Host.Execute(() => {
using ( var environment = MvcApplication.CreateStandaloneEnvironment("Default") ) {
using (var environment = MvcApplication.CreateStandaloneEnvironment("Default")) {
var orchardServices = environment.Resolve<IOrchardServices>();
var cultureManager = environment.Resolve<ICultureManager>();
@@ -30,6 +22,11 @@ namespace Orchard.Specs.Bindings {
}
orchardServices.WorkContext.CurrentSite.SiteCulture = cultureName;
// Restarting the shell to reset the cache, because the cache entry storing the list of available
// cultures isn't invalidated by the signal in DefaultCultureManager.ListCultures when running
// inside the test webhost.
MvcApplication.RestartTenant("Default");
}
});
}

View File

@@ -172,33 +172,4 @@
</dependentAssembly>
</assemblyBinding>
</runtime>
<glimpse defaultRuntimePolicy="On" endpointBaseUri="~/Glimpse.axd">
<logging level="Error" logLocation="App_data/Logs/Glimpse.log" />
<tabs>
<ignoredTypes>
<add type="Glimpse.Mvc.Tab.Views, Glimpse.Mvc5" />
<add type="Glimpse.Mvc.Tab.ModelBinding, Glimpse.Mvc5" />
<add type="Glimpse.Mvc.Tab.Metadata, Glimpse.Mvc5" />
<add type="Glimpse.AspNet.Tab.Cache, Glimpse.AspNet" />
<add type="Glimpse.AspNet.Tab.Routes, Glimpse.AspNet" />
<add type="Glimpse.AspNet.Tab.Session, Glimpse.AspNet" />
</ignoredTypes>
</tabs>
<inspectors>
<ignoredTypes>
<add type="Glimpse.Mvc.Inspector.ViewEngineInspector, Glimpse.Mvc5" />
<add type="Glimpse.Mvc.Inspector.DependencyInjectionInspector, Glimpse.Mvc5" />
<add type="Glimpse.Mvc.Inspector.ModelBinderInspector, Glimpse.Mvc5" />
<add type="Glimpse.AspNet.Inspector.RoutesInspector, Glimpse.AspNet" />
</ignoredTypes>
</inspectors>
<runtimePolicies>
<ignoredTypes>
<!-- Uncomment the line below to allow Glimpse to be enabled for remote requests -->
<!-- NOTE: If you uncomment this line, you can still restrict access to a set of whitelisted IP Address by adding the app setting `Orchard.Glimpse:WhitelistedIpAddresses` with a value of a semi colon separated IP Addresses to allow into the `appSettings` section of this file -->
<!--<add type="Glimpse.AspNet.Policy.LocalPolicy, Glimpse.AspNet" />-->
</ignoredTypes>
</runtimePolicies>
<!--For more information on how to configure Glimpse, please visit http://getglimpse.com/Help/Configuration or access {your site}/Glimpse.axd for even more details and a Configuration Tool to support you.-->
</glimpse>
</configuration>

View File

@@ -34,9 +34,9 @@ namespace Orchard.Core.Common {
table.CreateIndex($"IDX_{nameof(CommonPartRecord)}_{nameof(CommonPartRecord.CreatedUtc)}", nameof(CommonPartRecord.CreatedUtc));
table.CreateIndex($"IDX_{nameof(CommonPartRecord)}_{nameof(CommonPartRecord.ModifiedUtc)}", nameof(CommonPartRecord.ModifiedUtc));
table.CreateIndex($"IDX_{nameof(CommonPartRecord)}_{nameof(CommonPartRecord.PublishedUtc)}", nameof(CommonPartRecord.PublishedUtc));
// This originally in UpdateFrom8
// This originally in UpdateFrom7
table.CreateIndex($"IDX_{nameof(CommonPartRecord)}_Container_id", "Container_id");
// This originally in UpdateFrom6
// This originally in UpdateFrom8
table.CreateIndex($"IDX_{nameof(CommonPartRecord)}_OwnedBy_ByCreation",
nameof(CommonPartRecord.OwnerId),
nameof(CommonPartRecord.CreatedUtc));
@@ -66,7 +66,7 @@ namespace Orchard.Core.Common {
.ContentPartRecord()
.Column<string>("Identifier", column => column.WithLength(255)))
.AlterTable(nameof(IdentityPartRecord), table => table
// This originally in UpdateFrom7
// This originally in UpdateFrom6
.CreateIndex($"IDX_{nameof(IdentityPartRecord)}_{nameof(IdentityPartRecord.Identifier)}", nameof(IdentityPartRecord.Identifier)));
ContentDefinitionManager.AlterPartDefinition("BodyPart", builder => builder
@@ -80,7 +80,7 @@ namespace Orchard.Core.Common {
ContentDefinitionManager.AlterPartDefinition("IdentityPart", builder => builder
.Attachable()
.WithDescription("Automatically generates a unique identity for the content item, which is required in import/export scenarios where one content item references another."));
return 9;
}
@@ -156,6 +156,23 @@ namespace Orchard.Core.Common {
}
public int UpdateFrom6() {
SchemaBuilder.AlterTable(nameof(IdentityPartRecord), table => table
.CreateIndex($"IDX_{nameof(IdentityPartRecord)}_{nameof(IdentityPartRecord.Identifier)}", nameof(IdentityPartRecord.Identifier)));
return 7;
}
public int UpdateFrom7() {
// The Container_Id is basically a foreign key, used in several queries
SchemaBuilder.AlterTable(nameof(CommonPartRecord), table => {
table.CreateIndex($"IDX_{nameof(CommonPartRecord)}_Container_id",
"Container_id");
});
return 8;
}
public int UpdateFrom8() {
// Studying SQL Server query execution plans we noticed that when the system
// tries to find content items for requests such as
// "The items of type TTT owned by me, ordered from the most recent"
@@ -193,22 +210,6 @@ namespace Orchard.Core.Common {
nameof(CommonPartRecord.OwnerId),
nameof(CommonPartRecord.PublishedUtc));
});
return 7;
}
public int UpdateFrom7() {
SchemaBuilder.AlterTable(nameof(IdentityPartRecord), table => table
.CreateIndex($"IDX_{nameof(IdentityPartRecord)}_{nameof(IdentityPartRecord.Identifier)}", nameof(IdentityPartRecord.Identifier)));
return 8;
}
public int UpdateFrom8() {
// The Container_Id is basically a foreign key, used in several queries
SchemaBuilder.AlterTable(nameof(CommonPartRecord), table => {
table.CreateIndex($"IDX_{nameof(CommonPartRecord)}_Container_id",
"Container_id");
});
return 9;
}

View File

@@ -1,4 +1,5 @@
using System.Web;
using System.Collections.Generic;
using System.Web;
using Orchard.ContentManagement;
using Orchard.ContentManagement.Aspects;
using Orchard.Core.Navigation.Models;
@@ -11,13 +12,22 @@ namespace Orchard.Core.Navigation.Services {
public DefaultMenuProvider(IContentManager contentManager) {
_contentManager = contentManager;
_menuPartsMemory = new Dictionary<int, IEnumerable<MenuPart>>();
}
// Prevent doing the same query for MenuParts more than once on a same request
// in case we are building the same menu several times.
private Dictionary<int, IEnumerable<MenuPart>> _menuPartsMemory;
public void GetMenu(IContent menu, NavigationBuilder builder) {
var menuParts = _contentManager
.Query<MenuPart, MenuPartRecord>()
.Where(x => x.MenuId == menu.Id)
.List();
if (!_menuPartsMemory.ContainsKey(menu.Id)) {
_menuPartsMemory[menu.Id] = _contentManager
.Query<MenuPart, MenuPartRecord>()
.Where(x => x.MenuId == menu.Id)
.List();
}
var menuParts = _menuPartsMemory[menu.Id];
foreach (var menuPart in menuParts) {
if (menuPart != null) {

View File

@@ -31,22 +31,26 @@ namespace Orchard.Localization.Handlers {
protected static void PropertySetHandlers(ActivatedContentContext context, LocalizationPart localizationPart) {
localizationPart.CultureField.Setter(cultureRecord => {
localizationPart.Record.CultureId = cultureRecord != null ? cultureRecord.Id : 0;
localizationPart.Store<LocalizationPart, LocalizationPartRecord, int>(r => r.CultureId,
cultureRecord != null ? cultureRecord.Id : 0);
return cultureRecord;
});
localizationPart.MasterContentItemField.Setter(masterContentItem => {
localizationPart.Record.MasterContentItemId = masterContentItem.ContentItem.Id;
localizationPart.Store<LocalizationPart, LocalizationPartRecord, int>(r => r.MasterContentItemId,
masterContentItem.ContentItem.Id);
return masterContentItem;
});
});
}
protected void LazyLoadHandlers(LocalizationPart localizationPart) {
localizationPart.CultureField.Loader(() =>
_cultureManager.GetCultureById(localizationPart.Record.CultureId));
localizationPart.CultureField.Loader(() =>
_cultureManager.GetCultureById(
localizationPart.Retrieve<LocalizationPart, LocalizationPartRecord, int>(r => r.CultureId)));
localizationPart.MasterContentItemField.Loader(() =>
_contentManager.Get(localizationPart.Record.MasterContentItemId, VersionOptions.AllVersions));
_contentManager.Get(
localizationPart.Retrieve<LocalizationPart, LocalizationPartRecord, int>(r => r.MasterContentItemId), VersionOptions.AllVersions));
}
}
}

View File

@@ -7,3 +7,4 @@ OrchardVersion: 1.10.3
Description: Provides Orchard Recipes.
FeatureDescription: Implementation of Orchard recipes.
Category: Core
Dependencies: PackagingServices

View File

@@ -22,8 +22,16 @@ namespace Orchard.Taxonomies.Navigation {
ITaxonomyService taxonomyService) {
_contentManager = contentManager;
_taxonomyService = taxonomyService;
_termsMemory = new Dictionary<string, TermPart[]>();
}
// Prevent doing the same query for terms more than once on a same request
// in case we are building menus from the same starting taxonomies. Key is a
// string to "combine" the Id of the root TermPart and the flag telling to
// add that root to the results.
private Dictionary<string, TermPart[]> _termsMemory;
public IEnumerable<MenuItem> Filter(IEnumerable<MenuItem> items) {
foreach (var item in items) {
@@ -34,14 +42,21 @@ namespace Orchard.Taxonomies.Navigation {
var rootTerm = _taxonomyService.GetTerm(taxonomyNavigationPart.TermId);
TermPart[] allTerms;
string memoryKey;
if (rootTerm != null) {
// if DisplayRootTerm is specified add it to the menu items to render
allTerms = _taxonomyService.GetChildren(rootTerm, taxonomyNavigationPart.DisplayRootTerm).ToArray();
memoryKey = $"{rootTerm.Id}_{taxonomyNavigationPart.DisplayRootTerm}";
if (!_termsMemory.ContainsKey(memoryKey)) {
// if DisplayRootTerm is specified add it to the menu items to render
_termsMemory[memoryKey] = _taxonomyService.GetChildren(rootTerm, taxonomyNavigationPart.DisplayRootTerm).ToArray();
}
}
else {
allTerms = _taxonomyService.GetTerms(taxonomyNavigationPart.TaxonomyId).ToArray();
memoryKey = taxonomyNavigationPart.TaxonomyId.ToString();
if (!_termsMemory.ContainsKey(memoryKey)) {
_termsMemory[memoryKey] = _taxonomyService.GetTerms(taxonomyNavigationPart.TaxonomyId).ToArray();
}
}
allTerms = _termsMemory[memoryKey];
var rootLevel = rootTerm != null
? rootTerm.GetLevels()

View File

@@ -1,6 +1,6 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.28307.1738
# Visual Studio Version 17
VisualStudioVersion = 17.6.33815.320
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Modules", "Modules", "{E9C9F120-07BA-4DFB-B9C3-3AFB9D44C9D5}"
EndProject
@@ -285,8 +285,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Orchard.Conditions", "Orcha
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Orchard.Resources", "Orchard.Web\Modules\Orchard.Resources\Orchard.Resources.csproj", "{D4E8F7C8-2DB2-4C50-A422-DA1DF1E3CC73}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Orchard.Azure.Tests", "Orchard.Azure.Tests\Orchard.Azure.Tests.csproj", "{1CC62F45-E6FF-43D5-84BF-509A1085D994}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Orchard.OpenId", "Orchard.Web\Modules\Orchard.OpenId\Orchard.OpenId.csproj", "{42E217C1-E163-4B6B-9E8F-42BEE21B6896}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Orchard.Glimpse", "Orchard.Web\Modules\Orchard.Glimpse\Orchard.Glimpse.csproj", "{71E17466-D937-49D7-8C7D-77CCBAB8CCF4}"
@@ -306,6 +304,7 @@ EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflows", "workflows", "{4C95F27D-A872-481F-A9AF-851DB178C186}"
ProjectSection(SolutionItems) = preProject
..\.github\workflows\build-crowdin-translation-packages.yml = ..\.github\workflows\build-crowdin-translation-packages.yml
..\.github\workflows\compile.yml = ..\.github\workflows\compile.yml
EndProjectSection
EndProject
Global
@@ -1134,16 +1133,6 @@ Global
{D4E8F7C8-2DB2-4C50-A422-DA1DF1E3CC73}.FxCop|Any CPU.ActiveCfg = Release|Any CPU
{D4E8F7C8-2DB2-4C50-A422-DA1DF1E3CC73}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D4E8F7C8-2DB2-4C50-A422-DA1DF1E3CC73}.Release|Any CPU.Build.0 = Release|Any CPU
{1CC62F45-E6FF-43D5-84BF-509A1085D994}.CodeCoverage|Any CPU.ActiveCfg = Release|Any CPU
{1CC62F45-E6FF-43D5-84BF-509A1085D994}.CodeCoverage|Any CPU.Build.0 = Release|Any CPU
{1CC62F45-E6FF-43D5-84BF-509A1085D994}.Coverage|Any CPU.ActiveCfg = Release|Any CPU
{1CC62F45-E6FF-43D5-84BF-509A1085D994}.Coverage|Any CPU.Build.0 = Release|Any CPU
{1CC62F45-E6FF-43D5-84BF-509A1085D994}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1CC62F45-E6FF-43D5-84BF-509A1085D994}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1CC62F45-E6FF-43D5-84BF-509A1085D994}.FxCop|Any CPU.ActiveCfg = Release|Any CPU
{1CC62F45-E6FF-43D5-84BF-509A1085D994}.FxCop|Any CPU.Build.0 = Release|Any CPU
{1CC62F45-E6FF-43D5-84BF-509A1085D994}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1CC62F45-E6FF-43D5-84BF-509A1085D994}.Release|Any CPU.Build.0 = Release|Any CPU
{42E217C1-E163-4B6B-9E8F-42BEE21B6896}.CodeCoverage|Any CPU.ActiveCfg = Release|Any CPU
{42E217C1-E163-4B6B-9E8F-42BEE21B6896}.Coverage|Any CPU.ActiveCfg = Release|Any CPU
{42E217C1-E163-4B6B-9E8F-42BEE21B6896}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
@@ -1278,7 +1267,6 @@ Global
{90EBEE36-B5CD-42A8-A21B-76270E2C5D24} = {DF3909B0-1DDD-4D8A-9919-56FC438E25E2}
{98251EAE-A41B-47B2-AA91-E28B8482DA70} = {E9C9F120-07BA-4DFB-B9C3-3AFB9D44C9D5}
{D4E8F7C8-2DB2-4C50-A422-DA1DF1E3CC73} = {E9C9F120-07BA-4DFB-B9C3-3AFB9D44C9D5}
{1CC62F45-E6FF-43D5-84BF-509A1085D994} = {74E681ED-FECC-4034-B9BD-01B0BB1BDECA}
{42E217C1-E163-4B6B-9E8F-42BEE21B6896} = {E9C9F120-07BA-4DFB-B9C3-3AFB9D44C9D5}
{71E17466-D937-49D7-8C7D-77CCBAB8CCF4} = {E9C9F120-07BA-4DFB-B9C3-3AFB9D44C9D5}
{A17BE797-D4AF-4CB4-A9FD-AE7BA09A95BD} = {E9C9F120-07BA-4DFB-B9C3-3AFB9D44C9D5}
@@ -1288,7 +1276,7 @@ Global
{4C95F27D-A872-481F-A9AF-851DB178C186} = {06A32C3C-10A2-472E-B725-5AF102E92C6F}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
EnterpriseLibraryConfigurationToolBinariesPath = packages\TransientFaultHandling.Core.5.1.1209.1\lib\NET4
SolutionGuid = {3585D970-275B-4363-9F61-CD37CFC9DCD3}
EnterpriseLibraryConfigurationToolBinariesPath = packages\TransientFaultHandling.Core.5.1.1209.1\lib\NET4
EndGlobalSection
EndGlobal

View File

@@ -25,7 +25,7 @@ namespace Orchard.Environment.Extensions {
private readonly ICacheManager _cacheManager;
private readonly IParallelCacheContext _parallelCacheContext;
private readonly IEnumerable<IExtensionLoader> _loaders;
public Localizer T { get; set; }
public ILogger Logger { get; set; }
@@ -107,14 +107,16 @@ namespace Orchard.Environment.Extensions {
Logger.Information("Loading features");
// generate a cachekey by hashing the ids of all feature descriptors
var cacheKey = BitConverter.ToString(
_md5.ComputeHash(
Encoding.UTF8.GetBytes(
string.Join(";",
featureDescriptors
.Select(fd => fd.Id)
.OrderBy(x => x)))));
string cacheKey;
lock (_md5) {
cacheKey = BitConverter.ToString(
_md5.ComputeHash(
Encoding.UTF8.GetBytes(
string.Join(";",
featureDescriptors
.Select(fd => fd.Id)
.OrderBy(x => x)))));
}
var result = _cacheManager.Get(cacheKey,
true,