Merge branch 'temp8' of https://github.com/umbraco/Umbraco-CMS into temp8

This commit is contained in:
Shannon
2019-01-30 19:48:55 +11:00
35 changed files with 66 additions and 535 deletions

View File

@@ -61,7 +61,6 @@
<Compile Include="StringReplaceManyBenchmarks.cs" />
<Compile Include="TryConvertToBenchmarks.cs" />
<Compile Include="XmlBenchmarks.cs" />
<Compile Include="XmlPublishedContentInitBenchmarks.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />

View File

@@ -1,311 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Xml;
using BenchmarkDotNet.Attributes;
using Moq;
using Umbraco.Core;
using Umbraco.Core.Logging;
using Umbraco.Core.Models;
using Umbraco.Core.Models.PublishedContent;
using Umbraco.Core.PropertyEditors;
using Umbraco.Core.Services;
using Umbraco.Tests.Benchmarks.Config;
using Umbraco.Web.PublishedCache.XmlPublishedCache;
namespace Umbraco.Tests.Benchmarks
{
[QuickRunWithMemoryDiagnoserConfig]
public class XmlPublishedContentInitBenchmarks
{
public XmlPublishedContentInitBenchmarks()
{
_xml10 = Build(10);
_xml100 = Build(100);
_xml1000 = Build(1000);
_xml10000 = Build(10000);
}
private readonly string[] _intAttributes = { "id", "parentID", "nodeType", "level", "writerID", "creatorID", "template", "sortOrder", "isDoc", "isDraft" };
private readonly string[] _strAttributes = { "nodeName", "urlName", "writerName", "creatorName", "path" };
private readonly string[] _dateAttributes = { "createDate", "updateDate" };
private readonly string[] _guidAttributes = { "key", "version" };
private XmlDocument Build(int children)
{
var xml = new XmlDocument();
var root = Build(xml, "Home", 10);
for (int i = 0; i < children; i++)
{
var child = Build(xml, "child" + i, 10);
root.AppendChild(child);
}
xml.AppendChild(root);
return xml;
}
private XmlElement Build(XmlDocument xml, string name, int propertyCount)
{
var random = new Random();
var content = xml.CreateElement(name);
foreach (var p in _intAttributes)
{
var a = xml.CreateAttribute(p);
a.Value = random.Next(1, 9).ToInvariantString();
content.Attributes.Append(a);
}
foreach (var p in _strAttributes)
{
var a = xml.CreateAttribute(p);
a.Value = Guid.NewGuid().ToString();
content.Attributes.Append(a);
}
foreach (var p in _guidAttributes)
{
var a = xml.CreateAttribute(p);
a.Value = Guid.NewGuid().ToString();
content.Attributes.Append(a);
}
foreach (var p in _dateAttributes)
{
var a = xml.CreateAttribute(p);
a.Value = DateTime.Now.ToString("o");
content.Attributes.Append(a);
}
for (int i = 0; i < propertyCount; i++)
{
var prop = xml.CreateElement("prop" + i);
var cdata = xml.CreateCDataSection(string.Join("", Enumerable.Range(0, 10).Select(x => Guid.NewGuid().ToString())));
prop.AppendChild(cdata);
content.AppendChild(prop);
}
return content;
}
private readonly XmlDocument _xml10;
private readonly XmlDocument _xml100;
private readonly XmlDocument _xml1000;
private readonly XmlDocument _xml10000;
//out props
int id, nodeType, level, writerId, creatorId, template, sortOrder;
Guid key, version;
string name, urlName, writerName, creatorName, docTypeAlias, path;
bool isDraft;
bool isPublished;
DateTime createDate, updateDate;
PublishedContentType publishedContentType;
Dictionary<string, IPublishedProperty> properties;
[Benchmark(Baseline = true, OperationsPerInvoke = 10)]
public void Original_10_Children()
{
OriginalInitializeNode(_xml10.DocumentElement, false, false,
out id, out key, out template, out sortOrder, out name, out writerName, out urlName,
out creatorName, out creatorId, out writerId, out docTypeAlias, out nodeType, out path,
out version, out createDate, out updateDate, out level, out isDraft, out isPublished, out publishedContentType,
out properties);
}
[Benchmark(OperationsPerInvoke = 10)]
public void Original_100_Children()
{
OriginalInitializeNode(_xml100.DocumentElement, false, false,
out id, out key, out template, out sortOrder, out name, out writerName, out urlName,
out creatorName, out creatorId, out writerId, out docTypeAlias, out nodeType, out path,
out version, out createDate, out updateDate, out level, out isDraft, out isPublished, out publishedContentType,
out properties);
}
[Benchmark(OperationsPerInvoke = 10)]
public void Original_1000_Children()
{
OriginalInitializeNode(_xml1000.DocumentElement, false, false,
out id, out key, out template, out sortOrder, out name, out writerName, out urlName,
out creatorName, out creatorId, out writerId, out docTypeAlias, out nodeType, out path,
out version, out createDate, out updateDate, out level, out isDraft, out isPublished, out publishedContentType,
out properties);
}
[Benchmark(OperationsPerInvoke = 10)]
public void Original_10000_Children()
{
OriginalInitializeNode(_xml10000.DocumentElement, false, false,
out id, out key, out template, out sortOrder, out name, out writerName, out urlName,
out creatorName, out creatorId, out writerId, out docTypeAlias, out nodeType, out path,
out version, out createDate, out updateDate, out level, out isDraft, out isPublished, out publishedContentType,
out properties);
}
[Benchmark(OperationsPerInvoke = 10)]
public void Enhanced_10_Children()
{
XmlPublishedContent.InitializeNode(null, _xml10.DocumentElement, false,
out id, out key, out template, out sortOrder, out name, out writerName, out urlName,
out creatorName, out creatorId, out writerId, out docTypeAlias, out nodeType, out path,
out createDate, out updateDate, out level, out isDraft, out publishedContentType,
out properties, GetPublishedContentType);
}
[Benchmark(OperationsPerInvoke = 10)]
public void Enhanced_100_Children()
{
XmlPublishedContent.InitializeNode(null, _xml100.DocumentElement, false,
out id, out key, out template, out sortOrder, out name, out writerName, out urlName,
out creatorName, out creatorId, out writerId, out docTypeAlias, out nodeType, out path,
out createDate, out updateDate, out level, out isDraft, out publishedContentType,
out properties, GetPublishedContentType);
}
[Benchmark(OperationsPerInvoke = 10)]
public void Enhanced_1000_Children()
{
XmlPublishedContent.InitializeNode(null, _xml1000.DocumentElement, false,
out id, out key, out template, out sortOrder, out name, out writerName, out urlName,
out creatorName, out creatorId, out writerId, out docTypeAlias, out nodeType, out path,
out createDate, out updateDate, out level, out isDraft,out publishedContentType,
out properties, GetPublishedContentType);
}
[Benchmark(OperationsPerInvoke = 10)]
public void Enhanced_10000_Children()
{
XmlPublishedContent.InitializeNode(null, _xml10000.DocumentElement, false,
out id, out key, out template, out sortOrder, out name, out writerName, out urlName,
out creatorName, out creatorId, out writerId, out docTypeAlias, out nodeType, out path,
out createDate, out updateDate, out level, out isDraft,out publishedContentType,
out properties, GetPublishedContentType);
}
internal static void OriginalInitializeNode(XmlNode xmlNode, bool legacy, bool isPreviewing,
out int id, out Guid key, out int template, out int sortOrder, out string name, out string writerName, out string urlName,
out string creatorName, out int creatorId, out int writerId, out string docTypeAlias, out int docTypeId, out string path,
out Guid version, out DateTime createDate, out DateTime updateDate, out int level, out bool isDraft, out bool isPublished,
out PublishedContentType contentType, out Dictionary<string, IPublishedProperty> properties)
{
//initialize the out params with defaults:
writerName = null;
docTypeAlias = null;
id = template = sortOrder = template = creatorId = writerId = docTypeId = level = default(int);
key = version = default(Guid);
name = writerName = urlName = creatorName = docTypeAlias = path = null;
createDate = updateDate = default(DateTime);
isDraft = false;
isPublished = true;
contentType = null;
properties = null;
//return if this is null
if (xmlNode == null)
{
return;
}
if (xmlNode.Attributes != null)
{
id = int.Parse(xmlNode.Attributes.GetNamedItem("id").Value);
if (xmlNode.Attributes.GetNamedItem("key") != null) // because, migration
key = Guid.Parse(xmlNode.Attributes.GetNamedItem("key").Value);
if (xmlNode.Attributes.GetNamedItem("template") != null)
template = int.Parse(xmlNode.Attributes.GetNamedItem("template").Value);
if (xmlNode.Attributes.GetNamedItem("sortOrder") != null)
sortOrder = int.Parse(xmlNode.Attributes.GetNamedItem("sortOrder").Value);
if (xmlNode.Attributes.GetNamedItem("nodeName") != null)
name = xmlNode.Attributes.GetNamedItem("nodeName").Value;
if (xmlNode.Attributes.GetNamedItem("writerName") != null)
writerName = xmlNode.Attributes.GetNamedItem("writerName").Value;
if (xmlNode.Attributes.GetNamedItem("urlName") != null)
urlName = xmlNode.Attributes.GetNamedItem("urlName").Value;
// Creatorname is new in 2.1, so published xml might not have it!
try
{
creatorName = xmlNode.Attributes.GetNamedItem("creatorName").Value;
}
catch
{
creatorName = writerName;
}
//Added the actual userID, as a user cannot be looked up via full name only...
if (xmlNode.Attributes.GetNamedItem("creatorID") != null)
creatorId = int.Parse(xmlNode.Attributes.GetNamedItem("creatorID").Value);
if (xmlNode.Attributes.GetNamedItem("writerID") != null)
writerId = int.Parse(xmlNode.Attributes.GetNamedItem("writerID").Value);
if (legacy)
{
if (xmlNode.Attributes.GetNamedItem("nodeTypeAlias") != null)
docTypeAlias = xmlNode.Attributes.GetNamedItem("nodeTypeAlias").Value;
}
else
{
docTypeAlias = xmlNode.Name;
}
if (xmlNode.Attributes.GetNamedItem("nodeType") != null)
docTypeId = int.Parse(xmlNode.Attributes.GetNamedItem("nodeType").Value);
if (xmlNode.Attributes.GetNamedItem("path") != null)
path = xmlNode.Attributes.GetNamedItem("path").Value;
if (xmlNode.Attributes.GetNamedItem("version") != null)
version = new Guid(xmlNode.Attributes.GetNamedItem("version").Value);
if (xmlNode.Attributes.GetNamedItem("createDate") != null)
createDate = DateTime.Parse(xmlNode.Attributes.GetNamedItem("createDate").Value);
if (xmlNode.Attributes.GetNamedItem("updateDate") != null)
updateDate = DateTime.Parse(xmlNode.Attributes.GetNamedItem("updateDate").Value);
if (xmlNode.Attributes.GetNamedItem("level") != null)
level = int.Parse(xmlNode.Attributes.GetNamedItem("level").Value);
isDraft = (xmlNode.Attributes.GetNamedItem("isDraft") != null);
}
// load data
var dataXPath = legacy ? "data" : "* [not(@isDoc)]";
var nodes = xmlNode.SelectNodes(dataXPath);
contentType = GetPublishedContentType(PublishedItemType.Content, docTypeAlias);
var propertyNodes = new Dictionary<string, XmlNode>();
if (nodes != null)
foreach (XmlNode n in nodes)
{
var attrs = n.Attributes;
if (attrs == null) continue;
var alias = legacy
? attrs.GetNamedItem("alias").Value
: n.Name;
propertyNodes[alias.ToLowerInvariant()] = n;
}
properties = contentType.PropertyTypes.Select(p =>
{
XmlNode n;
return propertyNodes.TryGetValue(p.Alias.ToLowerInvariant(), out n)
? new XmlPublishedProperty(p, null, isPreviewing, n)
: new XmlPublishedProperty(p, null, isPreviewing);
}).Cast<IPublishedProperty>().ToDictionary(
x => x.Alias,
x => x,
StringComparer.OrdinalIgnoreCase);
}
private static PublishedContentType GetPublishedContentType(PublishedItemType type, string alias)
{
var dataType = new DataType(new VoidEditor(Mock.Of<ILogger>())) { Id = 1 };
var dataTypeService = Mock.Of<IDataTypeService>();
Mock.Get(dataTypeService)
.Setup(x => x.GetDataType(It.IsAny<int>()))
.Returns<int>(id => id == 1 ? dataType : null);
Mock.Get(dataTypeService)
.Setup(x => x.GetAll())
.Returns(new[] { dataType });
var factory = new PublishedContentTypeFactory(Mock.Of<IPublishedModelFactory>(), new PropertyValueConverterCollection(Array.Empty<IPropertyValueConverter>()), dataTypeService);
return factory.CreateContentType(0, alias, new string[] {},
new List<PublishedPropertyType>(Enumerable.Range(0, 10).Select(x => factory.CreatePropertyType("prop" + x, 1))));
}
}
}

View File

@@ -7,12 +7,12 @@ using Umbraco.Core.Composing;
using Umbraco.Core.Configuration;
using Umbraco.Core.Configuration.UmbracoSettings;
using Umbraco.Core.Services;
using Umbraco.Tests.LegacyXmlPublishedCache;
using Umbraco.Tests.TestHelpers;
using Umbraco.Tests.Testing;
using Umbraco.Tests.Testing.Objects.Accessors;
using Umbraco.Web;
using Umbraco.Web.PublishedCache;
using Umbraco.Web.PublishedCache.XmlPublishedCache;
using Umbraco.Web.Routing;
using Umbraco.Web.Security;
@@ -66,7 +66,7 @@ namespace Umbraco.Tests.Cache.PublishedCache
var xmlStore = new XmlStore(() => _xml, null, null, null);
var appCache = new DictionaryAppCache();
var domainCache = new DomainCache(ServiceContext.DomainService, DefaultCultureAccessor);
var publishedShapshot = new Umbraco.Web.PublishedCache.XmlPublishedCache.PublishedSnapshot(
var publishedShapshot = new PublishedSnapshot(
new PublishedContentCache(xmlStore, domainCache, appCache, globalSettings, new SiteDomainHelper(), umbracoContextAccessor, ContentTypesCache, null, null),
new PublishedMediaCache(xmlStore, ServiceContext.MediaService, ServiceContext.UserService, appCache, ContentTypesCache, Factory.GetInstance<IEntityXmlSerializer>(), umbracoContextAccessor),
new PublishedMemberCache(null, appCache, Current.Services.MemberService, ContentTypesCache, umbracoContextAccessor),

View File

@@ -10,12 +10,12 @@ using Umbraco.Core.Composing;
using Umbraco.Core.Models.PublishedContent;
using Umbraco.Core.Strings;
using Umbraco.Tests.TestHelpers;
using Umbraco.Web.PublishedCache.XmlPublishedCache;
using Umbraco.Tests.Testing;
using Current = Umbraco.Web.Composing.Current;
using Umbraco.Core.Models;
using Umbraco.Core.Models.Membership;
using Umbraco.Core.Services;
using Umbraco.Tests.LegacyXmlPublishedCache;
using Umbraco.Tests.PublishedContent;
using Umbraco.Web;

View File

@@ -8,10 +8,12 @@ using Umbraco.Core;
using Umbraco.Core.Cache;
using Umbraco.Core.Logging;
using Umbraco.Core.Models.PublishedContent;
using Umbraco.Web;
using Umbraco.Web.Composing;
using Umbraco.Web.Models;
using Umbraco.Web.PublishedCache;
namespace Umbraco.Web.PublishedCache.XmlPublishedCache
namespace Umbraco.Tests.LegacyXmlPublishedCache
{
/// <summary>
/// An IPublishedContent that is represented all by a dictionary.

View File

@@ -1,11 +1,12 @@
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using Umbraco.Web.Routing;
using Umbraco.Core;
using Umbraco.Core.Services;
using Umbraco.Web.PublishedCache;
using Umbraco.Web.Routing;
namespace Umbraco.Web.PublishedCache.XmlPublishedCache
namespace Umbraco.Tests.LegacyXmlPublishedCache
{
internal class DomainCache : IDomainCache
{

View File

@@ -7,7 +7,7 @@ using Umbraco.Core.IO;
using Umbraco.Core.Logging;
using Umbraco.Web.Composing;
namespace Umbraco.Web.PublishedCache.XmlPublishedCache
namespace Umbraco.Tests.LegacyXmlPublishedCache
{
class PreviewContent
{

View File

@@ -1,17 +1,19 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Xml;
using System.Xml.XPath;
using Umbraco.Core.Configuration;
using Umbraco.Core;
using Umbraco.Core.Cache;
using Umbraco.Core.Configuration;
using Umbraco.Core.Models.PublishedContent;
using Umbraco.Core.Xml;
using Umbraco.Web;
using Umbraco.Web.PublishedCache;
using Umbraco.Web.Routing;
using System.Linq;
using Umbraco.Core.Cache;
namespace Umbraco.Web.PublishedCache.XmlPublishedCache
namespace Umbraco.Tests.LegacyXmlPublishedCache
{
internal class PublishedContentCache : PublishedCacheBase, IPublishedContentCache
{

View File

@@ -6,21 +6,21 @@ using System.Linq;
using System.Threading;
using System.Xml.XPath;
using Examine;
using Examine.Providers;
using Examine.Search;
using Lucene.Net.Store;
using Umbraco.Core;
using Umbraco.Core.Cache;
using Umbraco.Core.Logging;
using Umbraco.Core.Models;
using Umbraco.Core.Models.PublishedContent;
using Umbraco.Core.Services;
using Umbraco.Core.Xml;
using Umbraco.Examine;
using Umbraco.Core.Cache;
using Umbraco.Core.Services;
using Umbraco.Core.Services.Implement;
using Umbraco.Web;
using Umbraco.Web.Composing;
using Umbraco.Web.PublishedCache;
namespace Umbraco.Web.PublishedCache.XmlPublishedCache
namespace Umbraco.Tests.LegacyXmlPublishedCache
{
/// <summary>
/// An IPublishedMediaStore that first checks for the media in Examine, and then reverts to the database

View File

@@ -6,9 +6,11 @@ using Umbraco.Core.Models;
using Umbraco.Core.Models.PublishedContent;
using Umbraco.Core.Security;
using Umbraco.Core.Services;
using Umbraco.Web;
using Umbraco.Web.PublishedCache;
using Umbraco.Web.Security;
namespace Umbraco.Web.PublishedCache.XmlPublishedCache
namespace Umbraco.Tests.LegacyXmlPublishedCache
{
class PublishedMemberCache : IPublishedMemberCache
{

View File

@@ -1,8 +1,9 @@
using System;
using Umbraco.Core;
using Umbraco.Core.Cache;
using Umbraco.Web.PublishedCache;
namespace Umbraco.Web.PublishedCache.XmlPublishedCache
namespace Umbraco.Tests.LegacyXmlPublishedCache
{
/// <summary>
/// Implements a published snapshot.

View File

@@ -11,11 +11,12 @@ using Umbraco.Core.Models.PublishedContent;
using Umbraco.Core.Persistence.Repositories;
using Umbraco.Core.Scoping;
using Umbraco.Core.Services;
using Umbraco.Core.Strings;
using Umbraco.Web;
using Umbraco.Web.Cache;
using Umbraco.Web.PublishedCache;
using Umbraco.Web.Routing;
namespace Umbraco.Web.PublishedCache.XmlPublishedCache
namespace Umbraco.Tests.LegacyXmlPublishedCache
{
/// <summary>
/// Implements a published snapshot service.

View File

@@ -1,10 +1,7 @@
using System;
using System.Collections.Concurrent;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Umbraco.Web.PublishedCache.XmlPublishedCache
namespace Umbraco.Tests.LegacyXmlPublishedCache
{
// Note: RoutesCache closely follows the caching strategy dating from v4, which
// is obviously broken in many ways (eg it's a global cache but relying to some

View File

@@ -3,7 +3,7 @@ using System.Xml;
using Umbraco.Core;
using Umbraco.Core.Scoping;
namespace Umbraco.Web.PublishedCache.XmlPublishedCache
namespace Umbraco.Tests.LegacyXmlPublishedCache
{
// TODO: should be a ScopeContextualBase
internal class SafeXmlReaderWriter : IDisposable

View File

@@ -1,11 +1,8 @@
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.Concurrent;
using System.Runtime.CompilerServices;
using Umbraco.Web;
namespace Umbraco.Web.PublishedCache.XmlPublishedCache
namespace Umbraco.Tests.LegacyXmlPublishedCache
{
static class UmbracoContextCache
{

View File

@@ -7,10 +7,12 @@ using System.Xml.XPath;
using Umbraco.Core;
using Umbraco.Core.Cache;
using Umbraco.Core.Models.PublishedContent;
using Umbraco.Web;
using Umbraco.Web.Composing;
using Umbraco.Web.Models;
using Umbraco.Web.PublishedCache;
namespace Umbraco.Web.PublishedCache.XmlPublishedCache
namespace Umbraco.Tests.LegacyXmlPublishedCache
{
/// <summary>

View File

@@ -5,7 +5,7 @@ using Umbraco.Core.Models.PublishedContent;
using Umbraco.Core.PropertyEditors;
using Umbraco.Core.Xml;
namespace Umbraco.Web.PublishedCache.XmlPublishedCache
namespace Umbraco.Tests.LegacyXmlPublishedCache
{
/// <summary>

View File

@@ -12,7 +12,6 @@ using Umbraco.Core.IO;
using Umbraco.Core.Logging;
using Umbraco.Core.Models;
using Umbraco.Core.Persistence;
using Umbraco.Core.Persistence.DatabaseModelDefinitions;
using Umbraco.Core.Persistence.Dtos;
using Umbraco.Core.Persistence.Repositories;
using Umbraco.Core.Persistence.Repositories.Implement;
@@ -20,15 +19,15 @@ using Umbraco.Core.Scoping;
using Umbraco.Core.Services;
using Umbraco.Core.Services.Changes;
using Umbraco.Core.Services.Implement;
using Umbraco.Core.Strings;
using Umbraco.Core.Xml;
using Umbraco.Web.Cache;
using Umbraco.Web.Composing;
using Umbraco.Web.PublishedCache;
using Umbraco.Web.Scheduling;
using File = System.IO.File;
using Task = System.Threading.Tasks.Task;
namespace Umbraco.Web.PublishedCache.XmlPublishedCache
namespace Umbraco.Tests.LegacyXmlPublishedCache
{
/// <summary>
/// Represents the Xml storage for the Xml published cache.

View File

@@ -1,11 +1,10 @@
using System;
using System.Threading;
using System.Threading.Tasks;
using Umbraco.Core;
using Umbraco.Core.Logging;
using Umbraco.Web.Scheduling;
namespace Umbraco.Web.PublishedCache.XmlPublishedCache
namespace Umbraco.Tests.LegacyXmlPublishedCache
{
/// <summary>
/// This is the background task runner that persists the xml file to the file system

View File

@@ -8,7 +8,6 @@ using Umbraco.Tests.TestHelpers;
using Umbraco.Tests.TestHelpers.Entities;
using Umbraco.Tests.UmbracoExamine;
using Umbraco.Web;
using Umbraco.Web.PublishedCache.XmlPublishedCache;
using System.Linq;
using System.Threading;
using System.Xml;
@@ -23,6 +22,7 @@ using Umbraco.Core.Composing;
using Umbraco.Core.Models.Membership;
using Umbraco.Core.PropertyEditors;
using Umbraco.Core.Services;
using Umbraco.Tests.LegacyXmlPublishedCache;
namespace Umbraco.Tests.PublishedContent
{

View File

@@ -4,9 +4,9 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NUnit.Framework;
using Umbraco.Tests.LegacyXmlPublishedCache;
using Umbraco.Tests.TestHelpers;
using Umbraco.Tests.Testing;
using Umbraco.Web.PublishedCache.XmlPublishedCache;
namespace Umbraco.Tests.Routing
{

View File

@@ -9,11 +9,11 @@ using Umbraco.Core.Composing;
using Umbraco.Core.Configuration;
using Umbraco.Core.Models;
using Umbraco.Core.Models.PublishedContent;
using Umbraco.Tests.LegacyXmlPublishedCache;
using Umbraco.Tests.TestHelpers;
using Umbraco.Tests.TestHelpers.Stubs;
using Umbraco.Tests.Testing;
using Umbraco.Web.PublishedCache;
using Umbraco.Web.PublishedCache.XmlPublishedCache;
using Umbraco.Web.Routing;
namespace Umbraco.Tests.Routing

View File

@@ -4,9 +4,9 @@ using NUnit.Framework;
using Umbraco.Core.Composing;
using Umbraco.Core.Configuration;
using Umbraco.Core.Models;
using Umbraco.Tests.LegacyXmlPublishedCache;
using Umbraco.Tests.TestHelpers;
using Umbraco.Tests.Testing;
using Umbraco.Web.PublishedCache.XmlPublishedCache;
namespace Umbraco.Tests.Routing
{

View File

@@ -8,8 +8,8 @@ using Umbraco.Core.Composing;
using Umbraco.Core.Configuration;
using Umbraco.Core.Models;
using Umbraco.Core.Services;
using Umbraco.Tests.LegacyXmlPublishedCache;
using Umbraco.Tests.TestHelpers;
using Umbraco.Web.PublishedCache.XmlPublishedCache;
using Umbraco.Web.Routing;
namespace Umbraco.Tests.Routing

View File

@@ -6,9 +6,9 @@ using Umbraco.Core.Composing;
using Umbraco.Core.Configuration;
using Umbraco.Core.Models;
using Umbraco.Tests.TestHelpers;
using Umbraco.Web.PublishedCache.XmlPublishedCache;
using Umbraco.Web.Routing;
using Umbraco.Core.Services;
using Umbraco.Tests.LegacyXmlPublishedCache;
namespace Umbraco.Tests.Routing
{

View File

@@ -12,11 +12,11 @@ using Umbraco.Core.Models;
using Umbraco.Core.Services;
using Umbraco.Core.Services.Implement;
using Umbraco.Core.Sync;
using Umbraco.Tests.LegacyXmlPublishedCache;
using Umbraco.Tests.TestHelpers;
using Umbraco.Tests.Testing;
using Umbraco.Web.Cache;
using Umbraco.Web.PublishedCache;
using Umbraco.Web.PublishedCache.XmlPublishedCache;
namespace Umbraco.Tests.Scoping
{

View File

@@ -19,7 +19,6 @@ using Umbraco.Core.PropertyEditors;
using Umbraco.Core.Services;
using Umbraco.Web;
using Umbraco.Web.PublishedCache;
using Umbraco.Web.PublishedCache.XmlPublishedCache;
using Umbraco.Web.Security;
using Umbraco.Web.Routing;
using File = System.IO.File;
@@ -30,6 +29,7 @@ using Umbraco.Tests.Testing;
using Umbraco.Core.Migrations.Install;
using Umbraco.Core.Models.PublishedContent;
using Umbraco.Core.Persistence.Repositories;
using Umbraco.Tests.LegacyXmlPublishedCache;
using Umbraco.Tests.Testing.Objects.Accessors;
namespace Umbraco.Tests.TestHelpers

View File

@@ -493,6 +493,21 @@
<Compile Include="Web\WebExtensionMethodTests.cs" />
<Compile Include="CoreThings\XmlExtensionsTests.cs" />
<Compile Include="Misc\XmlHelperTests.cs" />
<Compile Include="LegacyXmlPublishedCache\DictionaryPublishedContent.cs" />
<Compile Include="LegacyXmlPublishedCache\DomainCache.cs" />
<Compile Include="LegacyXmlPublishedCache\PreviewContent.cs" />
<Compile Include="LegacyXmlPublishedCache\PublishedContentCache.cs" />
<Compile Include="LegacyXmlPublishedCache\PublishedMediaCache.cs" />
<Compile Include="LegacyXmlPublishedCache\PublishedMemberCache.cs" />
<Compile Include="LegacyXmlPublishedCache\PublishedSnapshot.cs" />
<Compile Include="LegacyXmlPublishedCache\PublishedSnapshotService.cs" />
<Compile Include="LegacyXmlPublishedCache\RoutesCache.cs" />
<Compile Include="LegacyXmlPublishedCache\SafeXmlReaderWriter.cs" />
<Compile Include="LegacyXmlPublishedCache\UmbracoContextCache.cs" />
<Compile Include="LegacyXmlPublishedCache\XmlPublishedContent.cs" />
<Compile Include="LegacyXmlPublishedCache\XmlPublishedProperty.cs" />
<Compile Include="LegacyXmlPublishedCache\XmlStore.cs" />
<Compile Include="LegacyXmlPublishedCache\XmlStoreFilePersister.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config">

View File

@@ -12,13 +12,13 @@ using Umbraco.Core.Logging;
using Umbraco.Core.Models.PublishedContent;
using Umbraco.Core.Services;
using Umbraco.Core.Strings;
using Umbraco.Tests.LegacyXmlPublishedCache;
using Umbraco.Tests.TestHelpers;
using Umbraco.Tests.Testing;
using Umbraco.Tests.Testing.Objects.Accessors;
using Umbraco.Web;
using Umbraco.Web.Models;
using Umbraco.Web.Mvc;
using Umbraco.Web.PublishedCache.XmlPublishedCache;
using Umbraco.Web.Routing;
using Umbraco.Web.Security;

View File

@@ -1,62 +0,0 @@
function XmlDataIntegrityReportController($scope, umbRequestHelper, $log, $http) {
function check(item) {
var action = item.check;
umbRequestHelper.resourcePromise(
$http.get(umbRequestHelper.getApiUrl("xmlDataIntegrityBaseUrl", action)),
'Failed to retrieve data integrity status')
.then(function(result) {
item.checking = false;
item.invalid = result === "false";
});
}
$scope.fix = function(item) {
var action = item.fix;
if (item.fix) {
if (confirm("This will cause all xml structures for this type to be rebuilt. " +
"Depending on how much content there is in your site this could take a while. " +
"It is not recommended to rebuild xml structures if they are not out of sync, during times of high website traffic " +
"or when editors are editing content.")) {
item.fixing = true;
umbRequestHelper.resourcePromise(
$http.post(umbRequestHelper.getApiUrl("xmlDataIntegrityBaseUrl", action)),
'Failed to retrieve data integrity status')
.then(function(result) {
item.fixing = false;
item.invalid = result === "false";
});
}
}
}
$scope.items = {
"contentXml": {
label: "Content in the cmsContentXml table",
checking: true,
fixing: false,
fix: "FixContentXmlTable",
check: "CheckContentXmlTable"
},
"mediaXml": {
label: "Media in the cmsContentXml table",
checking: true,
fixing: false,
fix: "FixMediaXmlTable",
check: "CheckMediaXmlTable"
},
"memberXml": {
label: "Members in the cmsContentXml table",
checking: true,
fixing: false,
fix: "FixMembersXmlTable",
check: "CheckMembersXmlTable"
}
};
for (var i in $scope.items) {
check($scope.items[i]);
}
}
angular.module("umbraco").controller("Umbraco.Dashboard.XmlDataIntegrityReportController", XmlDataIntegrityReportController);

View File

@@ -1,29 +0,0 @@
<div id="examineManagement" ng-controller="Umbraco.Dashboard.XmlDataIntegrityReportController">
<h3>Xml Cache Data integrity</h3>
<div ng-show="loading">
Loading...
</div>
<p>
This checks the data integrity for the xml structures for content, media and members that are stored in the cmsContentXml table.
This does not check the data integrity of the xml cache file, only the xml structures stored in the database used to create the xml cache file.
</p>
<div ng-repeat="(key, value) in items" style="padding: 4px 0;">
<span ><strong>{{value.label}}&nbsp;...</strong></span>
<span ng-if="value.checking" class="text-info">Checking...</span>
<span ng-if="!value.checking && !value.invalid" class="text-success"><strong>Ok</strong></span>
<span ng-if="!value.checking && value.invalid" class="text-error"><strong>Error</strong></span>
<div ng-show="value.fix && !value.fixing">
<button type="button" ng-click="fix(value)" class="btn btn-danger" ng-if="value.invalid">
<span>Fix</span>
</button>
</div>
<div class="umb-loader-wrapper" ng-show="value.fixing">
<div class="umb-loader"></div>
</div>
</div>
</div>

View File

@@ -265,10 +265,6 @@ namespace Umbraco.Web.Editors
"examineMgmtBaseUrl", _urlHelper.GetUmbracoApiServiceBaseUrl<ExamineManagementController>(
controller => controller.GetIndexerDetails())
},
{
"xmlDataIntegrityBaseUrl", _urlHelper.GetUmbracoApiServiceBaseUrl<XmlDataIntegrityController>(
controller => controller.CheckContentXmlTable())
},
{
"healthCheckBaseUrl", _urlHelper.GetUmbracoApiServiceBaseUrl<HealthCheckController>(
controller => controller.GetAllHealthChecks())

View File

@@ -17,9 +17,6 @@ namespace Umbraco.Web.Editors
[HttpGet]
public string GetPublishedStatusUrl()
{
if (_publishedSnapshotService is PublishedCache.XmlPublishedCache.PublishedSnapshotService)
return "views/dashboard/settings/xmldataintegrityreport.html";
//if (service is PublishedCache.PublishedNoCache.PublishedSnapshotService)
// return "views/dashboard/developer/nocache.html";

View File

@@ -1,61 +0,0 @@
using System;
using System.Web.Http;
using Umbraco.Web.PublishedCache;
using Umbraco.Web.PublishedCache.XmlPublishedCache;
using Umbraco.Web.WebApi;
using Umbraco.Web.WebApi.Filters;
namespace Umbraco.Web.Editors
{
[ValidateAngularAntiForgeryToken]
public class XmlDataIntegrityController : UmbracoAuthorizedApiController
{
private readonly PublishedSnapshotService _publishedSnapshotService;
public XmlDataIntegrityController(IPublishedSnapshotService publishedSnapshotService)
{
if (publishedSnapshotService == null) throw new ArgumentNullException(nameof(publishedSnapshotService));
_publishedSnapshotService = publishedSnapshotService as PublishedSnapshotService;
if (_publishedSnapshotService == null) throw new NotSupportedException("Unsupported IPublishedSnapshotService, only the Xml one is supported.");
}
[HttpPost]
public bool FixContentXmlTable()
{
_publishedSnapshotService.RebuildContentAndPreviewXml();
return _publishedSnapshotService.VerifyContentAndPreviewXml();
}
[HttpPost]
public bool FixMediaXmlTable()
{
_publishedSnapshotService.RebuildMediaXml();
return _publishedSnapshotService.VerifyMediaXml();
}
[HttpPost]
public bool FixMembersXmlTable()
{
_publishedSnapshotService.RebuildMemberXml();
return _publishedSnapshotService.VerifyMemberXml();
}
[HttpGet]
public bool CheckContentXmlTable()
{
return _publishedSnapshotService.VerifyContentAndPreviewXml();
}
[HttpGet]
public bool CheckMediaXmlTable()
{
return _publishedSnapshotService.VerifyMediaXml();
}
[HttpGet]
public bool CheckMembersXmlTable()
{
return _publishedSnapshotService.VerifyMemberXml();
}
}
}

View File

@@ -531,15 +531,6 @@
<Compile Include="PublishedCache\PublishedContentTypeCache.cs" />
<Compile Include="PublishedCache\DefaultCultureAccessor.cs" />
<Compile Include="PublishedCache\UmbracoContextPublishedSnapshotAccessor.cs" />
<Compile Include="PublishedCache\XmlPublishedCache\DictionaryPublishedContent.cs" />
<Compile Include="PublishedCache\XmlPublishedCache\DomainCache.cs" />
<Compile Include="PublishedCache\XmlPublishedCache\PublishedSnapshot.cs" />
<Compile Include="PublishedCache\XmlPublishedCache\PublishedSnapshotService.cs" />
<Compile Include="PublishedCache\XmlPublishedCache\PreviewContent.cs" />
<Compile Include="PublishedCache\XmlPublishedCache\PublishedMemberCache.cs" />
<Compile Include="PublishedCache\XmlPublishedCache\SafeXmlReaderWriter.cs" />
<Compile Include="PublishedCache\XmlPublishedCache\XmlStore.cs" />
<Compile Include="PublishedCache\XmlPublishedCache\XmlStoreFilePersister.cs" />
<Compile Include="PublishedElementExtensions.cs" />
<Compile Include="PublishedModels\DummyClassSoThatPublishedModelsNamespaceExists.cs" />
<Compile Include="Routing\ContentFinderByUrl.cs" />
@@ -1018,7 +1009,6 @@
<Compile Include="Models\PublishedContentBase.cs" />
<Compile Include="Mvc\AreaRegistrationExtensions.cs" />
<Compile Include="Mvc\QueryStringFilterAttribute.cs" />
<Compile Include="PublishedCache\XmlPublishedCache\PublishedMediaCache.cs" />
<Compile Include="Dictionary\UmbracoCultureDictionary.cs" />
<Compile Include="Dictionary\UmbracoCultureDictionaryFactory.cs" />
<Compile Include="Mvc\MemberAuthorizeAttribute.cs" />
@@ -1026,8 +1016,6 @@
<Compile Include="Mvc\ControllerFactoryExtensions.cs" />
<Compile Include="Mvc\IRenderMvcController.cs" />
<Compile Include="Mvc\SurfaceRouteHandler.cs" />
<Compile Include="PublishedCache\XmlPublishedCache\RoutesCache.cs" />
<Compile Include="PublishedCache\XmlPublishedCache\UmbracoContextCache.cs" />
<Compile Include="Routing\UrlProviderMode.cs" />
<Compile Include="Search\ExamineIndexModel.cs" />
<Compile Include="Security\ValidateRequestAttempt.cs" />
@@ -1134,10 +1122,7 @@
<Compile Include="UmbracoHelper.cs" />
<Compile Include="Mvc\ViewContextExtensions.cs" />
<Compile Include="Mvc\ViewDataContainerExtensions.cs" />
<Compile Include="PublishedCache\XmlPublishedCache\PublishedContentCache.cs" />
<Compile Include="Routing\PublishedContentNotFoundHandler.cs" />
<Compile Include="PublishedCache\XmlPublishedCache\XmlPublishedContent.cs" />
<Compile Include="PublishedCache\XmlPublishedCache\XmlPublishedProperty.cs" />
<Compile Include="Mvc\Constants.cs" />
<Compile Include="Mvc\IFilteredControllerFactory.cs" />
<Compile Include="Mvc\MasterControllerFactory.cs" />
@@ -1189,7 +1174,6 @@
<Compile Include="UmbracoWebService.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="Editors\XmlDataIntegrityController.cs" />
<Compile Include="WebViewPageExtensions.cs" />
</ItemGroup>
<ItemGroup>