mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-07-31 21:32:56 +08:00
Don't migrate Media Picker fields twice
When attached to a custom part, fields were migrated twice
This commit is contained in:
parent
859b2316e9
commit
266b92d7a0
@ -209,21 +209,28 @@ namespace Upgrade.Controllers {
|
||||
}
|
||||
}
|
||||
|
||||
var processedParts = new List<string>();
|
||||
foreach (var match in matches) {
|
||||
|
||||
|
||||
// process each part only once as they could be used by multiple content types
|
||||
if (processedParts.Contains(match.Part.PartDefinition.Name)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
processedParts.Add(match.Part.PartDefinition.Name);
|
||||
|
||||
string hint, required;
|
||||
match.Field.Settings.TryGetValue("MediaPickerFieldSettings.Hint", out hint);
|
||||
match.Field.Settings.TryGetValue("MediaPickerFieldSettings.Required", out required);
|
||||
|
||||
_contentDefinitionManager.AlterPartDefinition(match.Part.PartDefinition.Name,
|
||||
cfg => cfg.RemoveField(match.Field.Name));
|
||||
_contentDefinitionManager.AlterPartDefinition(match.Part.PartDefinition.Name, cfg => cfg.RemoveField(match.Field.Name));
|
||||
|
||||
_contentDefinitionManager.AlterPartDefinition(match.Part.PartDefinition.Name, cfg => cfg
|
||||
.WithField(match.Field.Name, builder => builder
|
||||
.OfType("MediaLibraryPickerField")
|
||||
.WithDisplayName(match.Field.DisplayName)
|
||||
.WithSetting("MediaLibraryPickerFieldSettings.Hint", hint)
|
||||
.WithSetting("MediaLibraryPickerFieldSettings.Required", required)
|
||||
.WithSetting("MediaLibraryPickerFieldSettings.Hint", hint ?? "")
|
||||
.WithSetting("MediaLibraryPickerFieldSettings.Required", required ?? "")
|
||||
.WithSetting("MediaLibraryPickerFieldSettings.Multiple", false.ToString(CultureInfo.InvariantCulture))
|
||||
.WithSetting("MediaLibraryPickerFieldSettings.DisplayedContentTypes", String.Empty)
|
||||
));
|
||||
|
Loading…
Reference in New Issue
Block a user