Fix merge

This commit is contained in:
Stephan
2018-09-06 14:10:10 +02:00
parent bbd8315176
commit d9d51584ea
17 changed files with 159 additions and 90 deletions

View File

@@ -27,4 +27,10 @@ dotnet_naming_symbols.private_fields.applicable_kinds = field
dotnet_naming_symbols.private_fields.applicable_accessibilities = private
dotnet_naming_style.prefix_underscore.capitalization = camel_case
dotnet_naming_style.prefix_underscore.required_prefix = _
dotnet_naming_style.prefix_underscore.required_prefix = _
# https://github.com/MicrosoftDocs/visualstudio-docs/blob/master/docs/ide/editorconfig-code-style-settings-reference.md
[*.cs]
csharp_style_var_for_built_in_types = true:suggestion
csharp_style_var_when_type_is_apparent = true:suggestion
csharp_style_var_elsewhere = true:suggestion

View File

@@ -150,6 +150,8 @@ UNION
SELECT '4CountOfLockedOut' AS colName, COUNT(id) AS num FROM umbracoUser WHERE userNoConsole = 1
UNION
SELECT '5CountOfInvited' AS colName, COUNT(id) AS num FROM umbracoUser WHERE lastLoginDate IS NULL AND userDisabled = 1 AND invitedDate IS NOT NULL
UNION
SELECT '6CountOfDisabled' AS colName, COUNT(id) AS num FROM umbracoUser WHERE userDisabled = 0 AND userNoConsole = 0 AND lastLoginDate IS NULL
ORDER BY colName";
var result = Database.Fetch<dynamic>(sql);
@@ -160,7 +162,8 @@ ORDER BY colName";
{UserState.Active, (int) result[1].num},
{UserState.Disabled, (int) result[2].num},
{UserState.LockedOut, (int) result[3].num},
{UserState.Invited, (int) result[4].num}
{UserState.Invited, (int) result[4].num},
{UserState.Inactive, (int) result[5].num}
};
}
@@ -766,6 +769,12 @@ ORDER BY colName";
sb.Append("(userDisabled = 0 AND userNoConsole = 0 AND lastLoginDate IS NOT NULL)");
appended = true;
}
if (userState.Contains(UserState.Inactive))
{
if (appended) sb.Append(" OR ");
sb.Append("(userDisabled = 0 AND userNoConsole = 0 AND lastLoginDate IS NULL)");
appended = true;
}
if (userState.Contains(UserState.Disabled))
{
if (appended) sb.Append(" OR ");

View File

@@ -138,7 +138,7 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters // fixme MOVE TO MODELS O
/// </summary>
/// <returns></returns>
public bool HasFocalPoint()
=> FocalPoint != null && FocalPoint.Left != 0.5m && FocalPoint.Top != 0.5m;
=> FocalPoint != null && (FocalPoint.Left != 0.5m || FocalPoint.Top != 0.5m);
/// <summary>
/// Determines whether the value has a specified crop.

View File

@@ -11,6 +11,10 @@ namespace Umbraco.Core.Services
/// Represents the result of a service operation.
/// </summary>
/// <typeparam name="TResultType">The type of the result type.</typeparam>
/// <remarks>Type <typeparamref name="TResultType"/> must be an enumeration, and its
/// underlying type must be byte. Values indicating success should be in the 0-127
/// range, while values indicating failure should be in the 128-255 range. See
/// <see cref="OperationResultType"/> for a base implementation.</remarks>
public class OperationResult<TResultType>
where TResultType : struct
{
@@ -56,6 +60,10 @@ namespace Umbraco.Core.Services
/// </summary>
/// <typeparam name="TResultType">The type of the result type.</typeparam>
/// <typeparam name="TEntity">The type of the entity.</typeparam>
/// <remarks>Type <typeparamref name="TResultType"/> must be an enumeration, and its
/// underlying type must be byte. Values indicating success should be in the 0-127
/// range, while values indicating failure should be in the 128-255 range. See
/// <see cref="OperationResultType"/> for a base implementation.</remarks>
public class OperationResult<TResultType, TEntity> : OperationResult<TResultType>
where TResultType : struct
{
@@ -111,7 +119,8 @@ namespace Umbraco.Core.Services
return new OperationResult(OperationResultType.FailedCancelledByEvent, eventMessages);
}
// fixme wtf?
// fixme - this exists to support services that still return Attempt<OperationResult>
// these services should directly return an OperationResult, and then this static class should be deleted
internal static class Attempt
{
/// <summary>

View File

@@ -18,7 +18,7 @@ namespace Umbraco.Tests.Web.Mvc
[Test]
public void ReplaceLineBreaksWithHtmlBreak()
{
var output = _htmlStringUtilities.ReplaceLineBreaksForHtml("<div><h1>hello world</h1><p>hello world\r\nhello world\rhello world\nhello world</p></div>");
var output = _htmlStringUtilities.ReplaceLineBreaksForHtml("<div><h1>hello world</h1><p>hello world\r\nhello world\rhello world\nhello world</p></div>").ToString();
var expected = "<div><h1>hello world</h1><p>hello world<br />hello world<br />hello world<br />hello world</p></div>";
Assert.AreEqual(expected, output);
}
@@ -58,4 +58,4 @@ namespace Umbraco.Tests.Web.Mvc
}
}
}

View File

@@ -4,7 +4,7 @@ angular.module("umbraco").controller("Umbraco.Editors.LinkPickerController",
var vm = this;
var dialogOptions = $scope.model;
var anchorPattern = /<a id=\\"(.*?)\\">/gi;
var searchText = "Search...";
vm.submit = submit;
@@ -60,8 +60,14 @@ angular.module("umbraco").controller("Umbraco.Editors.LinkPickerController",
});
} else if ($scope.model.target.url.length) {
// a url but no id/udi indicates an external link - trim the url to remove the anchor/qs
$scope.model.target.url = $scope.model.target.url.substring(0, $scope.model.target.url.search(/(#|\?)/));
}
// only do the substring if there's a # or a ?
var indexOfAnchor = $scope.model.target.url.search(/(#|\?)/);
if (indexOfAnchor > -1) {
// populate the anchor
$scope.model.target.anchor = $scope.model.target.url.substring(indexOfAnchor);
// then rewrite the model and populate the link
$scope.model.target.url = $scope.model.target.url.substring(0, indexOfAnchor);
} }
} else if (dialogOptions.anchors) {
$scope.anchorValues = dialogOptions.anchors;
}

View File

@@ -23,7 +23,7 @@
placeholder="@general_url"
class="umb-property-editor umb-textstring"
ng-model="model.target.url"
ng-disabled="model.target.id" />
ng-disabled="model.target.id || model.target.udi" />
</umb-control-group>
<umb-control-group label="@defaultdialogs_anchorLinkPicker">

View File

@@ -37,7 +37,8 @@
type="button"
label-key="general_upload"
action="upload()"
disabled="lockedFolder">
disabled="lockedFolder"
button-style="info">
</umb-button>
</div>

View File

@@ -74,7 +74,8 @@
entity-type="{{vm.entityType}}"
start-node-id="vm.startNodeId"
on-select="vm.selectListViewNode(node)"
on-close="vm.closeMiniListView()">
on-close="vm.closeMiniListView()"
entity-type-filter="filter">
</umb-mini-list-view>
</umb-box-content>

View File

@@ -160,7 +160,8 @@ namespace Umbraco.Web.Components
var task = new InstructionProcessTask(_processTaskRunner,
60000, //delay before first execution
_messenger.Options.ThrottleSeconds*1000, //amount of ms between executions
_messenger);
_messenger,
_logger);
_processTaskRunner.TryAdd(task);
return task;
}
@@ -178,12 +179,14 @@ namespace Umbraco.Web.Components
private class InstructionProcessTask : RecurringTaskBase
{
private readonly DatabaseServerMessenger _messenger;
private readonly ILogger _logger;
public InstructionProcessTask(IBackgroundTaskRunner<RecurringTaskBase> runner, int delayMilliseconds, int periodMilliseconds,
DatabaseServerMessenger messenger)
DatabaseServerMessenger messenger, ILogger logger)
: base(runner, delayMilliseconds, periodMilliseconds)
{
_messenger = messenger;
_logger = logger;
}
public override bool IsAsync => false;
@@ -194,8 +197,14 @@ namespace Umbraco.Web.Components
/// <returns>A value indicating whether to repeat the task.</returns>
public override bool PerformRun()
{
// TODO what happens in case of an exception?
_messenger.Sync();
try
{
_messenger.Sync();
}
catch (Exception e)
{
_logger.Error<InstructionProcessTask>("Failed (will repeat).", e);
}
return true; // repeat
}
}

View File

@@ -328,10 +328,8 @@ namespace Umbraco.Web.Editors
var tryCreateTemplate = Services.FileService.CreateTemplateForContentType(contentTypeAlias, contentTypeName);
if (tryCreateTemplate == false)
{
Logger.Warn<ContentTypeController>(
"Could not create a template for the Content Type: {0}, status: {1}",
() => contentTypeAlias,
() => tryCreateTemplate.Result.StatusType);
Logger.Warn<ContentTypeController>("Could not create a template for Content Type: \"{ContentTypeAlias}\", status: {Status}",
contentTypeAlias, tryCreateTemplate.Result.Result);
}
template = tryCreateTemplate.Result.Entity;

View File

@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Umbraco.Core;
using Umbraco.Core.Models.PublishedContent;
using Umbraco.Core.PropertyEditors;
@@ -23,29 +22,27 @@ namespace Umbraco.Web.PropertyEditors.ValueConverters
public override object ConvertIntermediateToObject(IPublishedElement owner, PublishedPropertyType propertyType, PropertyCacheLevel referenceCacheLevel, object inter, bool preview)
{
if (inter == null)
{
return null;
}
var selectedValues = (string[])inter;
if (selectedValues.Any())
var multiple = propertyType.DataType.ConfigurationAs<DropDownFlexibleConfiguration>().Multiple;
var selectedValues = (string[]) inter;
if (selectedValues.Length > 0)
{
if (propertyType.DataType.ConfigurationAs<DropDownFlexibleConfiguration>().Multiple)
{
return selectedValues;
}
return selectedValues.First();
return multiple
? (object) selectedValues
: selectedValues[0];
}
return inter;
return multiple
? inter
: string.Empty;
}
public override Type GetPropertyValueType(PublishedPropertyType propertyType)
{
return propertyType.DataType.ConfigurationAs<DropDownFlexibleConfiguration>().Multiple
? typeof(IEnumerable<string>)
: typeof(string);
}
? typeof(IEnumerable<string>)
: typeof(string);
}
}
}

View File

@@ -77,7 +77,7 @@ namespace Umbraco.Web.PropertyEditors.ValueConverters
{
var strLinkId = linkData.Link;
var udiAttempt = strLinkId.TryConvertTo<GuidUdi>();
if (udiAttempt.Success)
if (udiAttempt.Success && udiAttempt.Result != null)
{
var content = _publishedSnapshotAccessor.PublishedSnapshot.Content.GetById(udiAttempt.Result.Guid);
if (content != null)

View File

@@ -93,7 +93,7 @@ namespace Umbraco.Web
if (content.TemplateId != templateId && UmbracoConfig.For.UmbracoSettings().WebRouting.ValidateAlternativeTemplates == true)
{
// fixme - perfs? nothing cached here
var publishedContentContentType = ApplicationContext.Current.Services.ContentTypeService.GetContentType(content.ContentType.Id);
var publishedContentContentType = Current.Services.ContentTypeService.Get(content.ContentType.Id);
if (publishedContentContentType == null)
throw new NullReferenceException("No content type returned for published content (contentType='" + content.ContentType.Id + "')");
@@ -105,8 +105,8 @@ namespace Umbraco.Web
public static bool IsAllowedTemplate(this IPublishedContent content, string templateAlias)
{
// fixme - perfs? nothing cached here
var template = ApplicationContext.Current.Services.FileService.GetTemplate(templateAlias);
return = template == null ? false : content.IsAllowedTemplate(template.Id);
var template = Current.Services.FileService.GetTemplate(templateAlias);
return template != null && content.IsAllowedTemplate(template.Id);
}
#endregion

View File

@@ -40,34 +40,49 @@ namespace Umbraco.Web.Routing
if (frequest.HasDomain)
path = DomainHelper.PathRelativeToDomain(frequest.Domain.Uri, path);
if (path != "/") // no template if "/"
{
var pos = path.LastIndexOf('/');
var templateAlias = path.Substring(pos + 1);
path = pos == 0 ? "/" : path.Substring(0, pos);
var template = _fileService.GetTemplate(templateAlias);
if (template != null)
{
Logger.Debug<ContentFinderByUrlAndTemplate>("Valid template: '{TemplateAlias}'", templateAlias);
var route = frequest.HasDomain ? (frequest.Domain.ContentId.ToString() + path) : path;
node = FindContent(frequest, route);
if (UmbracoConfig.For.UmbracoSettings().WebRouting.DisableAlternativeTemplates == false && node != null)
frequest.TemplateModel = template;
}
else
{
Logger.Debug<ContentFinderByUrlAndTemplate>("Not a valid template: '{TemplateAlias}'", templateAlias);
}
}
else
// no template if "/"
if (path == "/")
{
Logger.Debug<ContentFinderByUrlAndTemplate>("No template in path '/'");
return false;
}
return node != null;
// look for template in last position
var pos = path.LastIndexOf('/');
var templateAlias = path.Substring(pos + 1);
path = pos == 0 ? "/" : path.Substring(0, pos);
var template = _fileService.GetTemplate(templateAlias);
if (template == null)
{
Logger.Debug<ContentFinderByUrlAndTemplate>("Not a valid template: '{TemplateAlias}'", templateAlias);
return false;
}
Logger.Debug<ContentFinderByUrlAndTemplate>("Valid template: '{TemplateAlias}'", templateAlias);
// look for node corresponding to the rest of the route
var route = frequest.HasDomain ? (frequest.Domain.ContentId + path) : path;
node = FindContent(frequest, route); // also assigns to published request
if (node == null)
{
Logger.Debug<ContentFinderByUrlAndTemplate>("Not a valid route to node: '{Route}'", route);
return false;
}
// IsAllowedTemplate deals both with DisableAlternativeTemplates and ValidateAlternativeTemplates settings
if (!node.IsAllowedTemplate(template.Id))
{
Logger.Warn<ContentFinderByUrlAndTemplate>("Alternative template '{TemplateAlias}' is not allowed on node {NodeId}.", template.Alias, node.Id);
frequest.PublishedContent = null; // clear
return false;
}
// got it
frequest.TemplateModel = template;
return true;
}
}
}

View File

@@ -42,7 +42,7 @@ namespace Umbraco.Web.Routing
ProfilingLogger proflog,
Func<string, IEnumerable<string>> getRolesForLogin = null)
{
_webRoutingSection = webRoutingSection ?? throw new ArgumentNullException(nameof(webRoutingSection)); // fixme usage?
_webRoutingSection = webRoutingSection ?? throw new ArgumentNullException(nameof(webRoutingSection));
_contentFinders = contentFinders ?? throw new ArgumentNullException(nameof(contentFinders));
_contentLastChanceFinder = contentLastChanceFinder ?? throw new ArgumentNullException(nameof(contentLastChanceFinder));
_services = services ?? throw new ArgumentNullException(nameof(services));
@@ -678,9 +678,8 @@ namespace Umbraco.Web.Routing
// only if the published content is the initial once, else the alternate template
// does not apply
// + optionnally, apply the alternate template on internal redirects
var useAltTemplate = _webRoutingSection.DisableAlternativeTemplates == false
&& (request.IsInitialPublishedContent
|| (_webRoutingSection.InternalRedirectPreservesTemplate && request.IsInternalRedirectPublishedContent));
var useAltTemplate = request.IsInitialPublishedContent
|| (_webRoutingSection.InternalRedirectPreservesTemplate && request.IsInternalRedirectPublishedContent);
var altTemplate = useAltTemplate
? request.UmbracoContext.HttpContext.Request[Constants.Conventions.Url.AltTemplate]
: null;
@@ -693,28 +692,15 @@ namespace Umbraco.Web.Routing
if (request.HasTemplate)
{
_logger.Debug<PublishedRequest>("{0}Has a template already, and no alternate template.");
_logger.Debug<PublishedRequest>("FindTemplate: Has a template already, and no alternate template.");
return;
}
// TODO: When we remove the need for a database for templates, then this id should be irrelavent,
// TODO: When we remove the need for a database for templates, then this id should be irrelevant,
// not sure how were going to do this nicely.
var templateId = request.PublishedContent.TemplateId;
if (templateId > 0)
{
_logger.Debug<PublishedRouter>("FindTemplate: Look for template id={TemplateId}", templateId);
var template = _services.FileService.GetTemplate(templateId);
if (template == null)
throw new InvalidOperationException("The template with Id " + templateId + " does not exist, the page cannot render");
request.TemplateModel = template;
_logger.Debug<PublishedRouter>("FindTemplate: Got template id={TemplateId} alias='{TemplateAlias}'", template.Id, template.Alias);
}
else
{
_logger.Debug<PublishedRouter>("FindTemplate: No specified template.");
}
request.TemplateModel = GetTemplateModel(templateId);
}
else
{
@@ -725,18 +711,32 @@ namespace Umbraco.Web.Routing
// ignore if the alias does not match - just trace
if (request.HasTemplate)
_logger.Debug<PublishedRouter>("FindTemplate: Has a template already, but also an alternate template.");
_logger.Debug<PublishedRouter>("FindTemplate: Look for alternate template alias='{AltTemplate}'", altTemplate);
_logger.Debug<PublishedRouter>("FindTemplate: Has a template already, but also an alternative template.");
_logger.Debug<PublishedRouter>("FindTemplate: Look for alternative template alias='{AltTemplate}'", altTemplate);
var template = _services.FileService.GetTemplate(altTemplate);
if (template != null)
// IsAllowedTemplate deals both with DisableAlternativeTemplates and ValidateAlternativeTemplates settings
if (request.PublishedContent.IsAllowedTemplate(altTemplate))
{
request.TemplateModel = template;
_logger.Debug<PublishedRouter>("FindTemplate: Got template id={TemplateId} alias='{TemplateAlias}'", template.Id, template.Alias);
// allowed, use
var template = _services.FileService.GetTemplate(altTemplate);
if (template != null)
{
request.TemplateModel = template;
_logger.Debug<PublishedRouter>("FindTemplate: Got alternative template id={TemplateId} alias='{TemplateAlias}'", template.Id, template.Alias);
}
else
{
_logger.Debug<PublishedRouter>("FindTemplate: The alternative template with alias='{AltTemplate}' does not exist, ignoring.", altTemplate);
}
}
else
{
_logger.Debug<PublishedRouter>("FindTemplate: The template with alias='{AltTemplate}' does not exist, ignoring.", altTemplate);
_logger.Warn<PublishedRouter>("FindTemplate: Alternative template '{TemplateAlias}' is not allowed on node {NodeId}, ignoring.", altTemplate, request.PublishedContent.Id);
// no allowed, back to default
var templateId = request.PublishedContent.TemplateId;
request.TemplateModel = GetTemplateModel(templateId);
}
}
@@ -759,6 +759,23 @@ namespace Umbraco.Web.Routing
}
}
private ITemplate GetTemplateModel(int templateId)
{
if (templateId <= 0)
{
_logger.Debug<PublishedRouter>("GetTemplateModel: No template.");
return null;
}
_logger.Debug<PublishedRouter>("GetTemplateModel: Get template id={TemplateId}", templateId);
var template = _services.FileService.GetTemplate(templateId);
if (template == null)
throw new InvalidOperationException("The template with Id " + templateId + " does not exist, the page cannot render.");
_logger.Debug<PublishedRouter>("GetTemplateModel: Got template id={TemplateId} alias=\"{TemplateAlias}\"", template.Id, template.Alias);
return template;
}
/// <summary>
/// Follows external redirection through <c>umbracoRedirect</c> document property.
/// </summary>

View File

@@ -5,6 +5,7 @@ using System.Net;
using System.Net.Http.Formatting;
using System.Threading.Tasks;
using System.Web.Http;
using Umbraco.Core;
using Umbraco.Core.Models;
using Umbraco.Core.Services;
using Umbraco.Web.Models.Trees;