From b3b23e736b68a7b814ab5058a0459dd413d50dd0 Mon Sep 17 00:00:00 2001 From: Morten Christensen Date: Sun, 30 Dec 2012 07:17:04 -0100 Subject: [PATCH 1/2] Restructering strategies in folders --- src/Umbraco.Core/Services/MediaService.cs | 1 - .../EnsureAppsTreesUpdatedOnUpgrade.cs | 2 +- .../{ => Publishing}/UpdateCacheAfterPublish.cs | 2 +- .../{ => Publishing}/UpdateCacheAfterUnPublish.cs | 2 +- src/Umbraco.Web/Umbraco.Web.csproj | 10 ++++------ src/umbraco.cms/businesslogic/media/Media.cs | 11 ++++++----- 6 files changed, 13 insertions(+), 15 deletions(-) rename src/Umbraco.Web/Strategies/{ => Migrations}/EnsureAppsTreesUpdatedOnUpgrade.cs (93%) rename src/Umbraco.Web/Strategies/{ => Publishing}/UpdateCacheAfterPublish.cs (95%) rename src/Umbraco.Web/Strategies/{ => Publishing}/UpdateCacheAfterUnPublish.cs (95%) diff --git a/src/Umbraco.Core/Services/MediaService.cs b/src/Umbraco.Core/Services/MediaService.cs index e098c0a171..492fa4a77f 100644 --- a/src/Umbraco.Core/Services/MediaService.cs +++ b/src/Umbraco.Core/Services/MediaService.cs @@ -446,7 +446,6 @@ namespace Umbraco.Core.Services /// Id of the User saving the Content public void Save(IMedia media, int userId = -1) { - if (Saving.IsRaisedEventCancelled(new SaveEventArgs(media), this)) return; diff --git a/src/Umbraco.Web/Strategies/EnsureAppsTreesUpdatedOnUpgrade.cs b/src/Umbraco.Web/Strategies/Migrations/EnsureAppsTreesUpdatedOnUpgrade.cs similarity index 93% rename from src/Umbraco.Web/Strategies/EnsureAppsTreesUpdatedOnUpgrade.cs rename to src/Umbraco.Web/Strategies/Migrations/EnsureAppsTreesUpdatedOnUpgrade.cs index 6ccf84207e..2c5a63f802 100644 --- a/src/Umbraco.Web/Strategies/EnsureAppsTreesUpdatedOnUpgrade.cs +++ b/src/Umbraco.Web/Strategies/Migrations/EnsureAppsTreesUpdatedOnUpgrade.cs @@ -2,7 +2,7 @@ using umbraco.BusinessLogic; using umbraco.interfaces; -namespace Umbraco.Web.Strategies +namespace Umbraco.Web.Strategies.Migrations { /// /// This is kind of a hack to ensure that Apps and Trees that might still reside in the db is diff --git a/src/Umbraco.Web/Strategies/UpdateCacheAfterPublish.cs b/src/Umbraco.Web/Strategies/Publishing/UpdateCacheAfterPublish.cs similarity index 95% rename from src/Umbraco.Web/Strategies/UpdateCacheAfterPublish.cs rename to src/Umbraco.Web/Strategies/Publishing/UpdateCacheAfterPublish.cs index faf0795837..4718a64348 100644 --- a/src/Umbraco.Web/Strategies/UpdateCacheAfterPublish.cs +++ b/src/Umbraco.Web/Strategies/Publishing/UpdateCacheAfterPublish.cs @@ -9,7 +9,7 @@ using umbraco.cms.businesslogic.web; using umbraco.interfaces; using umbraco.presentation.cache; -namespace Umbraco.Web.Strategies +namespace Umbraco.Web.Strategies.Publishing { /// /// Represents the UpdateCacheAfterPublish class, which subscribes to the Published event diff --git a/src/Umbraco.Web/Strategies/UpdateCacheAfterUnPublish.cs b/src/Umbraco.Web/Strategies/Publishing/UpdateCacheAfterUnPublish.cs similarity index 95% rename from src/Umbraco.Web/Strategies/UpdateCacheAfterUnPublish.cs rename to src/Umbraco.Web/Strategies/Publishing/UpdateCacheAfterUnPublish.cs index b257dbb949..ef6995df1f 100644 --- a/src/Umbraco.Web/Strategies/UpdateCacheAfterUnPublish.cs +++ b/src/Umbraco.Web/Strategies/Publishing/UpdateCacheAfterUnPublish.cs @@ -7,7 +7,7 @@ using umbraco; using umbraco.interfaces; using umbraco.presentation.cache; -namespace Umbraco.Web.Strategies +namespace Umbraco.Web.Strategies.Publishing { /// /// Represents the UpdateCacheAfterUnPublish class, which subscribes to the UnPublished event diff --git a/src/Umbraco.Web/Umbraco.Web.csproj b/src/Umbraco.Web/Umbraco.Web.csproj index dfc4d8334a..49ba2aae94 100644 --- a/src/Umbraco.Web/Umbraco.Web.csproj +++ b/src/Umbraco.Web/Umbraco.Web.csproj @@ -326,9 +326,9 @@ - - - + + + @@ -2184,9 +2184,7 @@ umbraco_org_umbraco_update_CheckForUpgrade - - - + 10.0 $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) diff --git a/src/umbraco.cms/businesslogic/media/Media.cs b/src/umbraco.cms/businesslogic/media/Media.cs index f7dd6d62b2..d0ddd57986 100644 --- a/src/umbraco.cms/businesslogic/media/Media.cs +++ b/src/umbraco.cms/businesslogic/media/Media.cs @@ -294,15 +294,16 @@ namespace umbraco.cms.businesslogic.media public override void Save() { SaveEventArgs e = new SaveEventArgs(); + + foreach (var property in GenericProperties) + { + _media.SetValue(property.PropertyType.Alias, property.Value); + } + FireBeforeSave(e); if (!e.Cancel) { - foreach (var property in GenericProperties) - { - _media.SetValue(property.PropertyType.Alias, property.Value); - } - ApplicationContext.Current.Services.MediaService.Save(_media); base.Save(); From f4706fcfb75121b5307bbec4ed45b9f6447b99f8 Mon Sep 17 00:00:00 2001 From: Morten Christensen Date: Sun, 30 Dec 2012 18:26:08 -0100 Subject: [PATCH 2/2] Fixes U4-1370 for ContentTypes thats loading using new api meaning that the fix only applies to Content and Media, but currently not Members. For Members there is still an issue with MasterContentTypes, as the full structure is not loaded. Need to make the sql lookup recursive- --- .../Models/ContentTypeCompositionBase.cs | 14 +++++++++++++- .../Models/IContentTypeComposition.cs | 8 +++++++- .../umbraco/controls/ContentControl.cs | 3 ++- src/umbraco.cms/businesslogic/ContentType.cs | 19 +++++++++++++++---- 4 files changed, 37 insertions(+), 7 deletions(-) diff --git a/src/Umbraco.Core/Models/ContentTypeCompositionBase.cs b/src/Umbraco.Core/Models/ContentTypeCompositionBase.cs index 9681e2164e..93a77d5cac 100644 --- a/src/Umbraco.Core/Models/ContentTypeCompositionBase.cs +++ b/src/Umbraco.Core/Models/ContentTypeCompositionBase.cs @@ -116,7 +116,7 @@ namespace Umbraco.Core.Models /// /// Gets a list of ContentType aliases from the current composition /// - /// + /// An enumerable list of string aliases /// Does not contain the alias of the Current ContentType public IEnumerable CompositionAliases() { @@ -124,5 +124,17 @@ namespace Umbraco.Core.Models .Select(x => x.Alias) .Union(ContentTypeComposition.SelectMany(x => x.CompositionAliases())); } + + /// + /// Gets a list of ContentType Ids from the current composition + /// + /// An enumerable list of integer ids + /// Does not contain the Id of the Current ContentType + public IEnumerable CompositionIds() + { + return ContentTypeComposition + .Select(x => x.Id) + .Union(ContentTypeComposition.SelectMany(x => x.CompositionIds())); + } } } \ No newline at end of file diff --git a/src/Umbraco.Core/Models/IContentTypeComposition.cs b/src/Umbraco.Core/Models/IContentTypeComposition.cs index 6da7f2e9c9..8b5049f236 100644 --- a/src/Umbraco.Core/Models/IContentTypeComposition.cs +++ b/src/Umbraco.Core/Models/IContentTypeComposition.cs @@ -46,7 +46,13 @@ namespace Umbraco.Core.Models /// /// Gets a list of ContentType aliases from the current composition /// - /// + /// An enumerable list of string aliases IEnumerable CompositionAliases(); + + /// + /// Gets a list of ContentType Ids from the current composition + /// + /// An enumerable list of integer ids + IEnumerable CompositionIds(); } } \ No newline at end of file diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/controls/ContentControl.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/controls/ContentControl.cs index bd24324bcf..a8a549383d 100644 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/controls/ContentControl.cs +++ b/src/Umbraco.Web/umbraco.presentation/umbraco/controls/ContentControl.cs @@ -130,7 +130,8 @@ namespace umbraco.controls // Iterate through the property types and add them to the tab // zb-00036 #29889 : fix property types getter to get the right set of properties // ge : had a bit of a corrupt db and got weird NRE errors so rewrote this to catch the error and rethrow with detail - foreach (PropertyType propertyType in tab.GetPropertyTypes(_content.ContentType.Id)) + var propertyTypes = tab.GetPropertyTypes(_content.ContentType.Id); + foreach (PropertyType propertyType in propertyTypes) { var property = _content.getProperty(propertyType); if (property != null && tabPage != null) diff --git a/src/umbraco.cms/businesslogic/ContentType.cs b/src/umbraco.cms/businesslogic/ContentType.cs index 55f224c783..3db18b7762 100644 --- a/src/umbraco.cms/businesslogic/ContentType.cs +++ b/src/umbraco.cms/businesslogic/ContentType.cs @@ -582,14 +582,25 @@ namespace umbraco.cms.businesslogic if (m_masterContentTypes == null) { m_masterContentTypes = new List(); - using (var dr = SqlHelper.ExecuteReader(@"SELECT parentContentTypeId FROM cmsContentType2ContentType WHERE childContentTypeId = @id", SqlHelper.CreateParameter("@id", Id))) + if (_contentType == null) { - while (dr.Read()) + //TODO Make this recursive, so it looks up Masters of the Master ContentType + using ( + var dr = + SqlHelper.ExecuteReader( + @"SELECT parentContentTypeId FROM cmsContentType2ContentType WHERE childContentTypeId = @id", + SqlHelper.CreateParameter("@id", Id))) { - m_masterContentTypes.Add(dr.GetInt("parentContentTypeId")); + while (dr.Read()) + { + m_masterContentTypes.Add(dr.GetInt("parentContentTypeId")); + } } } - + else + { + m_masterContentTypes = _contentType.CompositionIds().ToList(); + } } return m_masterContentTypes;