Merge remote-tracking branch 'origin/v8/dev' into netcore/dev
# Conflicts: # src/Umbraco.Abstractions/Constants-AppSettings.cs # src/Umbraco.Abstractions/ContentVariationExtensions.cs # src/Umbraco.Abstractions/IMainDom.cs # src/Umbraco.Abstractions/PropertyEditors/MultiUrlPickerConfiguration.cs # src/Umbraco.Abstractions/Runtime/IMainDom.cs # src/Umbraco.Abstractions/Runtime/MainDom.cs # src/Umbraco.Core/IMainDom.cs # src/Umbraco.Core/MainDom.cs # src/Umbraco.Core/Umbraco.Core.csproj # src/Umbraco.Infrastructure/MainDom.cs # src/Umbraco.Infrastructure/Migrations/Upgrade/UmbracoPlan.cs # src/Umbraco.Infrastructure/Runtime/CoreRuntime.cs # src/Umbraco.Web.UI/Umbraco/config/lang/en.xml # src/Umbraco.Web/Models/Mapping/ContentTypeMapDefinition.cs # src/Umbraco.Web/PublishedCache/NuCache/ContentStore.cs # src/Umbraco.Web/UmbracoApplication.cs # src/Umbraco.Web/UmbracoComponentRenderer.cs
This commit is contained in:
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using CSharpTest.Net.Collections;
|
||||
using Newtonsoft.Json;
|
||||
using Umbraco.Core;
|
||||
@@ -206,10 +207,15 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
/// </remarks>
|
||||
private void MainDomRelease()
|
||||
{
|
||||
_logger.Debug<PublishedSnapshotService>("Releasing from MainDom...");
|
||||
|
||||
lock (_storesLock)
|
||||
{
|
||||
_logger.Debug<PublishedSnapshotService>("Releasing content store...");
|
||||
_contentStore?.ReleaseLocalDb(); //null check because we could shut down before being assigned
|
||||
_localContentDb = null;
|
||||
|
||||
_logger.Debug<PublishedSnapshotService>("Releasing media store...");
|
||||
_mediaStore?.ReleaseLocalDb(); //null check because we could shut down before being assigned
|
||||
_localMediaDb = null;
|
||||
|
||||
@@ -393,7 +399,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
var contentTypes = _serviceContext.ContentTypeService.GetAll()
|
||||
.Select(x => _publishedContentTypeFactory.CreateContentType(x));
|
||||
|
||||
_contentStore.SetAllContentTypes(contentTypes);
|
||||
_contentStore.SetAllContentTypesLocked(contentTypes);
|
||||
|
||||
using (_logger.TraceDuration<PublishedSnapshotService>("Loading content from database"))
|
||||
{
|
||||
@@ -404,7 +410,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
|
||||
// IMPORTANT GetAllContentSources sorts kits by level + parentId + sortOrder
|
||||
var kits = _dataSource.GetAllContentSources(scope);
|
||||
return onStartup ? _contentStore.SetAllFastSorted(kits, true) : _contentStore.SetAll(kits);
|
||||
return onStartup ? _contentStore.SetAllFastSortedLocked(kits, true) : _contentStore.SetAllLocked(kits);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -412,7 +418,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
{
|
||||
var contentTypes = _serviceContext.ContentTypeService.GetAll()
|
||||
.Select(x => _publishedContentTypeFactory.CreateContentType(x));
|
||||
_contentStore.SetAllContentTypes(contentTypes);
|
||||
_contentStore.SetAllContentTypesLocked(contentTypes);
|
||||
|
||||
using (_logger.TraceDuration<PublishedSnapshotService>("Loading content from local cache file"))
|
||||
{
|
||||
@@ -464,7 +470,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
|
||||
var mediaTypes = _serviceContext.MediaTypeService.GetAll()
|
||||
.Select(x => _publishedContentTypeFactory.CreateContentType(x));
|
||||
_mediaStore.SetAllContentTypes(mediaTypes);
|
||||
_mediaStore.SetAllContentTypesLocked(mediaTypes);
|
||||
|
||||
using (_logger.TraceDuration<PublishedSnapshotService>("Loading media from database"))
|
||||
{
|
||||
@@ -476,7 +482,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
_logger.Debug<PublishedSnapshotService>("Loading media from database...");
|
||||
// IMPORTANT GetAllMediaSources sorts kits by level + parentId + sortOrder
|
||||
var kits = _dataSource.GetAllMediaSources(scope);
|
||||
return onStartup ? _mediaStore.SetAllFastSorted(kits, true) : _mediaStore.SetAll(kits);
|
||||
return onStartup ? _mediaStore.SetAllFastSortedLocked(kits, true) : _mediaStore.SetAllLocked(kits);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -484,7 +490,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
{
|
||||
var mediaTypes = _serviceContext.MediaTypeService.GetAll()
|
||||
.Select(x => _publishedContentTypeFactory.CreateContentType(x));
|
||||
_mediaStore.SetAllContentTypes(mediaTypes);
|
||||
_mediaStore.SetAllContentTypesLocked(mediaTypes);
|
||||
|
||||
using (_logger.TraceDuration<PublishedSnapshotService>("Loading media from local cache file"))
|
||||
{
|
||||
@@ -525,7 +531,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
return false;
|
||||
}
|
||||
|
||||
return onStartup ? store.SetAllFastSorted(kits, false) : store.SetAll(kits);
|
||||
return onStartup ? store.SetAllFastSortedLocked(kits, false) : store.SetAllLocked(kits);
|
||||
}
|
||||
|
||||
// keep these around - might be useful
|
||||
@@ -631,7 +637,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
.Where(x => x.RootContentId.HasValue && x.LanguageIsoCode.IsNullOrWhiteSpace() == false)
|
||||
.Select(x => new Domain(x.Id, x.DomainName, x.RootContentId.Value, CultureInfo.GetCultureInfo(x.LanguageIsoCode), x.IsWildcard)))
|
||||
{
|
||||
_domainStore.Set(domain.Id, domain);
|
||||
_domainStore.SetLocked(domain.Id, domain);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -679,10 +685,12 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
publishedChanged = publishedChanged2;
|
||||
}
|
||||
|
||||
|
||||
if (draftChanged || publishedChanged)
|
||||
((PublishedSnapshot)CurrentPublishedSnapshot)?.Resync();
|
||||
}
|
||||
|
||||
// Calling this method means we have a lock on the contentStore (i.e. GetScopedWriteLock)
|
||||
private void NotifyLocked(IEnumerable<ContentCacheRefresher.JsonPayload> payloads, out bool draftChanged, out bool publishedChanged)
|
||||
{
|
||||
publishedChanged = false;
|
||||
@@ -692,7 +700,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
// content (and content types) are read-locked while reading content
|
||||
// contentStore is wlocked (so readable, only no new views)
|
||||
// and it can be wlocked by 1 thread only at a time
|
||||
// contentStore is write-locked during changes
|
||||
// contentStore is write-locked during changes - see note above, calls to this method are wrapped in contentStore.GetScopedWriteLock
|
||||
|
||||
foreach (var payload in payloads)
|
||||
{
|
||||
@@ -712,7 +720,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
|
||||
if (payload.ChangeTypes.HasType(TreeChangeTypes.Remove))
|
||||
{
|
||||
if (_contentStore.Clear(payload.Id))
|
||||
if (_contentStore.ClearLocked(payload.Id))
|
||||
draftChanged = publishedChanged = true;
|
||||
continue;
|
||||
}
|
||||
@@ -735,7 +743,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
// ?? should we do some RV check here?
|
||||
// IMPORTANT GetbranchContentSources sorts kits by level and by sort order
|
||||
var kits = _dataSource.GetBranchContentSources(scope, capture.Id);
|
||||
_contentStore.SetBranch(capture.Id, kits);
|
||||
_contentStore.SetBranchLocked(capture.Id, kits);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -743,11 +751,11 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
var kit = _dataSource.GetContentSource(scope, capture.Id);
|
||||
if (kit.IsEmpty)
|
||||
{
|
||||
_contentStore.Clear(capture.Id);
|
||||
_contentStore.ClearLocked(capture.Id);
|
||||
}
|
||||
else
|
||||
{
|
||||
_contentStore.Set(kit);
|
||||
_contentStore.SetLocked(kit);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -805,7 +813,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
|
||||
if (payload.ChangeTypes.HasType(TreeChangeTypes.Remove))
|
||||
{
|
||||
if (_mediaStore.Clear(payload.Id))
|
||||
if (_mediaStore.ClearLocked(payload.Id))
|
||||
anythingChanged = true;
|
||||
continue;
|
||||
}
|
||||
@@ -828,7 +836,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
// ?? should we do some RV check here?
|
||||
// IMPORTANT GetbranchContentSources sorts kits by level and by sort order
|
||||
var kits = _dataSource.GetBranchMediaSources(scope, capture.Id);
|
||||
_mediaStore.SetBranch(capture.Id, kits);
|
||||
_mediaStore.SetBranchLocked(capture.Id, kits);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -836,11 +844,11 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
var kit = _dataSource.GetMediaSource(scope, capture.Id);
|
||||
if (kit.IsEmpty)
|
||||
{
|
||||
_mediaStore.Clear(capture.Id);
|
||||
_mediaStore.ClearLocked(capture.Id);
|
||||
}
|
||||
else
|
||||
{
|
||||
_mediaStore.Set(kit);
|
||||
_mediaStore.SetLocked(kit);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -942,14 +950,14 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
using (var scope = _scopeProvider.CreateScope())
|
||||
{
|
||||
scope.ReadLock(Constants.Locks.ContentTree);
|
||||
_contentStore.UpdateDataTypes(idsA, id => CreateContentType(PublishedItemType.Content, id));
|
||||
_contentStore.UpdateDataTypesLocked(idsA, id => CreateContentType(PublishedItemType.Content, id));
|
||||
scope.Complete();
|
||||
}
|
||||
|
||||
using (var scope = _scopeProvider.CreateScope())
|
||||
{
|
||||
scope.ReadLock(Constants.Locks.MediaTree);
|
||||
_mediaStore.UpdateDataTypes(idsA, id => CreateContentType(PublishedItemType.Media, id));
|
||||
_mediaStore.UpdateDataTypesLocked(idsA, id => CreateContentType(PublishedItemType.Media, id));
|
||||
scope.Complete();
|
||||
}
|
||||
}
|
||||
@@ -979,7 +987,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
}
|
||||
break;
|
||||
case DomainChangeTypes.Remove:
|
||||
_domainStore.Clear(payload.Id);
|
||||
_domainStore.ClearLocked(payload.Id);
|
||||
break;
|
||||
case DomainChangeTypes.Refresh:
|
||||
var domain = _serviceContext.DomainService.GetById(payload.Id);
|
||||
@@ -987,7 +995,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
if (domain.RootContentId.HasValue == false) continue; // anomaly
|
||||
if (domain.LanguageIsoCode.IsNullOrWhiteSpace()) continue; // anomaly
|
||||
var culture = CultureInfo.GetCultureInfo(domain.LanguageIsoCode);
|
||||
_domainStore.Set(domain.Id, new Domain(domain.Id, domain.DomainName, domain.RootContentId.Value, culture, domain.IsWildcard));
|
||||
_domainStore.SetLocked(domain.Id, new Domain(domain.Id, domain.DomainName, domain.RootContentId.Value, culture, domain.IsWildcard));
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1072,11 +1080,11 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
? Array.Empty<ContentNodeKit>()
|
||||
: _dataSource.GetTypeContentSources(scope, refreshedIds).ToArray();
|
||||
|
||||
_contentStore.UpdateContentTypes(removedIds, typesA, kits);
|
||||
_contentStore.UpdateContentTypesLocked(removedIds, typesA, kits);
|
||||
if (!otherIds.IsCollectionEmpty())
|
||||
_contentStore.UpdateContentTypes(CreateContentTypes(PublishedItemType.Content, otherIds.ToArray()));
|
||||
_contentStore.UpdateContentTypesLocked(CreateContentTypes(PublishedItemType.Content, otherIds.ToArray()));
|
||||
if (!newIds.IsCollectionEmpty())
|
||||
_contentStore.NewContentTypes(CreateContentTypes(PublishedItemType.Content, newIds.ToArray()));
|
||||
_contentStore.NewContentTypesLocked(CreateContentTypes(PublishedItemType.Content, newIds.ToArray()));
|
||||
scope.Complete();
|
||||
}
|
||||
}
|
||||
@@ -1103,11 +1111,11 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
? Array.Empty<ContentNodeKit>()
|
||||
: _dataSource.GetTypeMediaSources(scope, refreshedIds).ToArray();
|
||||
|
||||
_mediaStore.UpdateContentTypes(removedIds, typesA, kits);
|
||||
_mediaStore.UpdateContentTypesLocked(removedIds, typesA, kits);
|
||||
if (!otherIds.IsCollectionEmpty())
|
||||
_mediaStore.UpdateContentTypes(CreateContentTypes(PublishedItemType.Media, otherIds.ToArray()).ToArray());
|
||||
_mediaStore.UpdateContentTypesLocked(CreateContentTypes(PublishedItemType.Media, otherIds.ToArray()).ToArray());
|
||||
if (!newIds.IsCollectionEmpty())
|
||||
_mediaStore.NewContentTypes(CreateContentTypes(PublishedItemType.Media, newIds.ToArray()).ToArray());
|
||||
_mediaStore.NewContentTypesLocked(CreateContentTypes(PublishedItemType.Media, newIds.ToArray()).ToArray());
|
||||
scope.Complete();
|
||||
}
|
||||
}
|
||||
@@ -1178,12 +1186,14 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
// elements
|
||||
// just need to make sure nothing gets elements in another enlisted action... so using
|
||||
// a MaxValue to make sure this one runs last, and it should be ok
|
||||
|
||||
scopeContext.Enlist("Umbraco.Web.PublishedCache.NuCache.PublishedSnapshotService.Resync", () => this, (completed, svc) =>
|
||||
{
|
||||
((PublishedSnapshot)svc.CurrentPublishedSnapshot)?.Resync();
|
||||
}, int.MaxValue);
|
||||
}
|
||||
|
||||
|
||||
// create a new snapshot cache if snapshots are different gens
|
||||
if (contentSnap.Gen != _contentGen || mediaSnap.Gen != _mediaGen || domainSnap.Gen != _domainGen || _elementsCache == null)
|
||||
{
|
||||
@@ -1350,7 +1360,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
{
|
||||
//culture changed on an existing language
|
||||
var cultureChanged = e.SavedEntities.Any(x => !x.WasPropertyDirty(nameof(ILanguage.Id)) && x.WasPropertyDirty(nameof(ILanguage.IsoCode)));
|
||||
if(cultureChanged)
|
||||
if (cultureChanged)
|
||||
{
|
||||
RebuildContentDbCache();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user