Compare commits

...

7 Commits

Author SHA1 Message Date
Benedek Farkas
3a69399bd7 Adding the compile workflow to the solution 2023-06-28 14:33:23 +02:00
Benedek Farkas
2494c7872a Updating the compile workflow to run the build + tests on PR, dev and 1.10.x commits 2023-06-28 14:33:01 +02:00
Benedek Farkas
39bbc0fbe8 Specs: Workaround for the DefineDefaultCulture binding and removing the Settings feature which is now redundant with CreatingAndUsingDateTimeFieldsInAnotherCulture 2023-05-26 17:50:33 +02:00
Benedek Farkas
0f6c0c7f6b Merge branch '1.10.x' into issue/8686 2023-05-26 16:15:43 +02:00
Matteo Piovanelli
9122abbdec Added missing module dependency (#8694)
610b3c4f53/src/Orchard.Web/Modules/Orchard.Recipes/Providers/Executors/ModuleStep.cs (L14)

if feature PackagingServices is not enabled, `ModuleStep` cannot be constructed by Autofac, causing several things to fail (e.g. import/export).
2023-05-26 09:16:57 +02:00
Matteo Piovanelli
a215e606b7 Added dictionaries to memorize results of queries and avoid repeating them (#8690)
within a request.
2023-05-26 09:16:04 +02:00
Matteo Piovanelli
e55dbb0db8 Changed Loader and Setter delegates of the LazyFields of LocalizationPart to (#8693)
use Store/Retrieve implementations rather than go directly to the Record.
2023-05-26 09:12:14 +02:00
10 changed files with 71 additions and 158 deletions

View File

@@ -2,6 +2,11 @@ name: Compile
on:
workflow_dispatch:
pull_request:
push:
branches:
- dev
- 1.10.x
jobs:
compile:
@@ -22,18 +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
- name: Spec
run: msbuild Orchard.proj /m /t:Spec

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

@@ -188,11 +188,6 @@
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
</Compile>
<Compile Include="Settings.feature.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Settings.feature</DependentUpon>
</Compile>
<Compile Include="Text.feature.cs">
<DependentUpon>Text.feature</DependentUpon>
<AutoGen>True</AutoGen>
@@ -365,10 +360,6 @@
<DependentUpon>HostComponents.config</DependentUpon>
</None>
<None Include="packages.config" />
<None Include="Settings.feature">
<Generator>SpecFlowSingleFileGenerator</Generator>
<LastGenOutput>Settings.feature.cs</LastGenOutput>
</None>
<None Include="Text.feature">
<Generator>SpecFlowSingleFileGenerator</Generator>
<LastGenOutput>Text.feature.cs</LastGenOutput>

View File

@@ -1,14 +0,0 @@
Feature: Settings
In order to manage my site
As a privileged user
I want to be able to see and change site settings
Scenario: Adding a new site culture and selecting it as the default works
Given I have installed Orchard
When I go to "Admin/Settings/Index"
Then I should not see "hu-HU"
When I have "hu-HU" as the default culture
And I go to "Admin/Settings/Index"
Then I should see "<option selected="selected">hu-HU</option>"

View File

@@ -1,93 +0,0 @@
// ------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by SpecFlow (http://www.specflow.org/).
// SpecFlow Version:1.9.0.77
// SpecFlow Generator Version:1.9.0.0
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
// ------------------------------------------------------------------------------
#region Designer generated code
#pragma warning disable
namespace Orchard.Specs
{
using TechTalk.SpecFlow;
[System.CodeDom.Compiler.GeneratedCodeAttribute("TechTalk.SpecFlow", "1.9.0.77")]
[System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[NUnit.Framework.TestFixtureAttribute()]
[NUnit.Framework.DescriptionAttribute("Settings")]
public partial class SettingsFeature
{
private static TechTalk.SpecFlow.ITestRunner testRunner;
#line 1 "Settings.feature"
#line hidden
[NUnit.Framework.TestFixtureSetUpAttribute()]
public virtual void FeatureSetup()
{
testRunner = TechTalk.SpecFlow.TestRunnerManager.GetTestRunner();
TechTalk.SpecFlow.FeatureInfo featureInfo = new TechTalk.SpecFlow.FeatureInfo(new System.Globalization.CultureInfo("en-US"), "Settings", "\r\nIn order to manage my site\r\nAs a privileged user\r\nI want to be able to see and " +
"change site settings", ProgrammingLanguage.CSharp, ((string[])(null)));
testRunner.OnFeatureStart(featureInfo);
}
[NUnit.Framework.TestFixtureTearDownAttribute()]
public virtual void FeatureTearDown()
{
testRunner.OnFeatureEnd();
testRunner = null;
}
[NUnit.Framework.SetUpAttribute()]
public virtual void TestInitialize()
{
}
[NUnit.Framework.TearDownAttribute()]
public virtual void ScenarioTearDown()
{
testRunner.OnScenarioEnd();
}
public virtual void ScenarioSetup(TechTalk.SpecFlow.ScenarioInfo scenarioInfo)
{
testRunner.OnScenarioStart(scenarioInfo);
}
public virtual void ScenarioCleanup()
{
testRunner.CollectScenarioErrors();
}
[NUnit.Framework.TestAttribute()]
[NUnit.Framework.DescriptionAttribute("Adding a new site culture and selecting it as the default works")]
public virtual void AddingANewSiteCultureAndSelectingItAsTheDefaultWorks()
{
TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Adding a new site culture and selecting it as the default works", ((string[])(null)));
#line 7
this.ScenarioSetup(scenarioInfo);
#line 9
testRunner.Given("I have installed Orchard", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Given ");
#line 10
testRunner.When("I go to \"Admin/Settings/Index\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When ");
#line 11
testRunner.Then("I should not see \"hu-HU\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then ");
#line 12
testRunner.When("I have \"hu-HU\" as the default culture", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When ");
#line 13
testRunner.And("I go to \"Admin/Settings/Index\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And ");
#line 14
testRunner.Then("I should see \"<option selected=\"selected\">hu-HU</option>\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then ");
#line hidden
this.ScenarioCleanup();
}
}
}
#pragma warning restore
#endregion

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.Id;
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 Version 16
VisualStudioVersion = 16.0.29926.136
# 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
@@ -278,6 +278,13 @@ 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("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".github", ".github", "{C149D676-DC9E-4C3E-A218-955EFBBC4B74}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflows", "workflows", "{1A90D20E-90DF-4988-8E35-0A4C1275EC46}"
ProjectSection(SolutionItems) = preProject
..\.github\workflows\compile.yml = ..\.github\workflows\compile.yml
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
CodeCoverage|Any CPU = CodeCoverage|Any CPU
@@ -1191,9 +1198,10 @@ 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}
{1A90D20E-90DF-4988-8E35-0A4C1275EC46} = {C149D676-DC9E-4C3E-A218-955EFBBC4B74}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {3585D970-275B-4363-9F61-CD37CFC9DCD3}
EnterpriseLibraryConfigurationToolBinariesPath = packages\TransientFaultHandling.Core.5.1.1209.1\lib\NET4
SolutionGuid = {3585D970-275B-4363-9F61-CD37CFC9DCD3}
EndGlobalSection
EndGlobal