Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/v13/dev' into v14/dev
Browse files Browse the repository at this point in the history
  • Loading branch information
bergmania committed Sep 13, 2024
2 parents a96a304 + b237285 commit 26bf04c
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/Umbraco.Infrastructure/Migrations/Upgrade/UmbracoPlan.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ protected virtual void DefinePlan()
To<V_13_0_0.ChangeWebhookUrlColumnsToNvarcharMax>("{21C42760-5109-4C03-AB4F-7EA53577D1F5}");
To<V_13_0_0.AddExceptionOccured>("{6158F3A3-4902-4201-835E-1ED7F810B2D8}");
To<V_13_3_0.AlignUpgradedDatabase>("{985AF2BA-69D3-4DBA-95E0-AD3FA7459FA7}");
To<V_13_5_0.ChangeRedirectUrlToNvarcharMax>("{CC47C751-A81B-489A-A2BC-0240245DB687}");

// To 14.0.0
To<V_14_0_0.AddPropertyEditorUiAliasColumn>("{419827A0-4FCE-464B-A8F3-247C6092AF55}");
Expand Down Expand Up @@ -91,5 +92,8 @@ protected virtual void DefinePlan()

// To 14.2.0
To<V_14_2_0.AddMissingDateTimeConfiguration>("{20ED404C-6FF9-4F91-8AC9-2B298E0002EB}");

// To 14.3.0
To<V_13_5_0.ChangeRedirectUrlToNvarcharMax>("{EEF792FC-318C-4921-9859-51EBF07A53A3}"); // Execute again, to ensure all that migrated to 14.0.0 without 13.5 will have this
}
}
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)");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ internal class RedirectUrlDto

[Column("url")]
[NullSetting(NullSetting = NullSettings.NotNull)]
[SpecialDbType(SpecialDbTypes.NVARCHARMAX)]
public string Url { get; set; } = null!;

[Column("culture")]
Expand Down
6 changes: 6 additions & 0 deletions src/Umbraco.PublishedCache.NuCache/Property.cs
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,12 @@ private class CacheValues : CacheValue

public CacheValue For(string? culture, string? segment)
{
// As noted on IPropertyValue, null value means invariant
// But as we need an actual string value to build a CompositeStringStringKey
// We need to convert null to empty
culture ??= string.Empty;
segment ??= string.Empty;

if (culture == string.Empty && segment == string.Empty)
{
return this;
Expand Down
1 change: 0 additions & 1 deletion src/Umbraco.Web.UI.Client
Submodule Umbraco.Web.UI.Client deleted from f30f89

0 comments on commit 26bf04c

Please sign in to comment.