Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove 'Target' from LinkFieldIndex #16397

Merged
merged 2 commits into from
Jul 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,14 @@ public class LinkFieldIndex : ContentFieldIndex
{
// Maximum length that MySql can support in an index under utf8 collation is 768,
// minus 1 for the `DocumentId` integer (character size = integer size = 4 bytes).
// minus 1 (freeing 4 bytes) for the additional 'Published' and 'Latest' booleans.
// minus 1 (freeing 4 bytes) for the additional 'Published' and 'Latest' boolean.
public const int MaxUrlSize = 766;
public const int MaxTextSize = 766;

public string Url { get; set; }
public string BigUrl { get; set; }
public string Text { get; set; }
public string BigText { get; set; }
public string Target { get; set; }
}

public class LinkFieldIndexProvider : ContentFieldIndexProvider
Expand Down Expand Up @@ -63,17 +62,19 @@ public override void Describe(DescribeContext<ContentItem> context)
if (contentTypeDefinition == null)
{
_ignoredTypes.Add(contentItem.ContentType);

return null;
}

var fieldDefinitions = contentTypeDefinition
.Parts.SelectMany(x => x.PartDefinition.Fields.Where(f => f.FieldDefinition.Name == nameof(LinkField)))
.ToArray();

// This type doesn't have any LinkField, ignore it
// This type doesn't have any LinkField, ignore it.
if (fieldDefinitions.Length == 0)
{
_ignoredTypes.Add(contentItem.ContentType);

return null;
}

Expand All @@ -93,7 +94,6 @@ public override void Describe(DescribeContext<ContentItem> context)
BigUrl = pair.Field.Url,
Text = pair.Field.Text?[..Math.Min(pair.Field.Text.Length, LinkFieldIndex.MaxTextSize)],
BigText = pair.Field.Text,
Target = pair.Field.Target,
});
});
}
Expand Down