-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/v15/dev' into v15/feature/determ…
…ine-urls-at-save-and-publish-time
- Loading branch information
Showing
33 changed files
with
302 additions
and
119 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
src/Umbraco.Cms.Api.Management/Controllers/Server/UpgradeCheckServerController.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
using Asp.Versioning; | ||
using Microsoft.AspNetCore.Authorization; | ||
using Microsoft.AspNetCore.Http; | ||
using Microsoft.AspNetCore.Mvc; | ||
using Umbraco.Cms.Api.Management.ViewModels.Server; | ||
using Umbraco.Cms.Core; | ||
using Umbraco.Cms.Core.Configuration; | ||
using Umbraco.Cms.Core.Services; | ||
using Umbraco.Cms.Web.Common.Authorization; | ||
using Umbraco.Extensions; | ||
|
||
namespace Umbraco.Cms.Api.Management.Controllers.Server; | ||
|
||
[ApiVersion("1.0")] | ||
[Authorize(Policy = AuthorizationPolicies.RequireAdminAccess)] | ||
public class UpgradeCheckServerController : ServerControllerBase | ||
{ | ||
private readonly IUpgradeService _upgradeService; | ||
private readonly IUmbracoVersion _umbracoVersion; | ||
|
||
public UpgradeCheckServerController(IUpgradeService upgradeService, IUmbracoVersion umbracoVersion) | ||
{ | ||
_upgradeService = upgradeService; | ||
_umbracoVersion = umbracoVersion; | ||
} | ||
|
||
[HttpGet("upgrade-check")] | ||
[MapToApiVersion("1.0")] | ||
[ProducesResponseType(typeof(UpgradeCheckResponseModel), StatusCodes.Status200OK)] | ||
public async Task<IActionResult> UpgradeCheck(CancellationToken cancellationToken) | ||
{ | ||
UpgradeResult upgradeResult = await _upgradeService.CheckUpgrade(_umbracoVersion.SemanticVersion); | ||
|
||
var responseModel = new UpgradeCheckResponseModel | ||
{ | ||
Type = upgradeResult.UpgradeType, | ||
Comment = upgradeResult.Comment, | ||
Url = upgradeResult.UpgradeUrl.IsNullOrWhiteSpace() | ||
? string.Empty | ||
: $"{upgradeResult.UpgradeUrl}?version={_umbracoVersion.Version.ToString(3)}" | ||
}; | ||
|
||
return Ok(responseModel); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
src/Umbraco.Cms.Api.Management/ViewModels/Server/UpgradeCheckResponseModel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
namespace Umbraco.Cms.Api.Management.ViewModels.Server; | ||
|
||
public class UpgradeCheckResponseModel | ||
{ | ||
public required string Type { get; init; } | ||
|
||
public required string Comment { get; init; } | ||
|
||
public required string Url { get; init; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
src/Umbraco.Infrastructure/Migrations/Upgrade/V_13_5_0/ChangeRedirectUrlToNvarcharMax.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
using System.Linq.Expressions; | ||
using System.Text; | ||
using NPoco; | ||
using Umbraco.Cms.Core; | ||
using Umbraco.Cms.Infrastructure.Migrations.Expressions.Create.Column; | ||
using Umbraco.Cms.Infrastructure.Persistence; | ||
using Umbraco.Cms.Infrastructure.Persistence.Dtos; | ||
|
||
namespace Umbraco.Cms.Infrastructure.Migrations.Upgrade.V_13_5_0; | ||
|
||
public class ChangeRedirectUrlToNvarcharMax : MigrationBase | ||
{ | ||
public ChangeRedirectUrlToNvarcharMax(IMigrationContext context) : base(context) | ||
{ | ||
} | ||
|
||
protected override void Migrate() | ||
{ | ||
// We don't need to run this migration for SQLite, since ntext is not a thing there, text is just text. | ||
if (DatabaseType == DatabaseType.SQLite) | ||
{ | ||
return; | ||
} | ||
|
||
string tableName = RedirectUrlDto.TableName; | ||
string colName = "url"; | ||
|
||
// Determine the current datatype of the column within the database | ||
string colDataType = Database.ExecuteScalar<string>($"SELECT TOP(1) CHARACTER_MAXIMUM_LENGTH FROM INFORMATION_SCHEMA.COLUMNS" + | ||
$" WHERE TABLE_NAME = '{tableName}' AND COLUMN_NAME = '{colName}'"); | ||
|
||
// 255 is the old length, -1 indicate MAX length | ||
if (colDataType == "255") | ||
{ | ||
// Upgrade to MAX length | ||
Database.Execute($"Drop Index IX_umbracoRedirectUrl_culture_hash on {Constants.DatabaseSchema.Tables.RedirectUrl}"); | ||
Database.Execute($"ALTER TABLE {tableName} ALTER COLUMN {colName} nvarchar(MAX) NOT NULL"); | ||
Database.Execute($"CREATE INDEX IX_umbracoRedirectUrl_culture_hash ON {Constants.DatabaseSchema.Tables.RedirectUrl} (urlHash, contentKey, culture, createDateUtc)"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.