This is bug is caused by having a media picker pointing to a file which is no longer in the physical file system. In this circumstance, running the "Migrating Media Picker Fields" in the Upgrade module will cause these files to not be found AND the old url will remain. This will cause an error as the new MediaLibraryPicker is expecting integers in the Data column, not strings.
Here is the code which will fix this.
File: Upgrade.Controllers.MediaController
Method: MediaPicker (HttpPost)
Code Change:
if (media != null) {
contentField.Url = "{" + media.Id + "}";
}
else {
// We don't want "broken" links left behind so instead want them converted to empty fields as broken links cause the page to crash
// Because this might be run "twice", don't override already valid contentField Url's
string contentFieldUrl = contentField.Url;
if (!contentFieldUrl.StartsWith("{")) {
contentField.Url = "";
}
}
In a "normal" circumstance it would never be run "twice" but I perform the check just in case their are others out there who modify the database to be able to run through this upgrade two times.
@jeffolmstead created: https://orchard.codeplex.com/workitem/19919
This is bug is caused by having a media picker pointing to a file which is no longer in the physical file system. In this circumstance, running the "Migrating Media Picker Fields" in the Upgrade module will cause these files to not be found AND the old url will remain. This will cause an error as the new MediaLibraryPicker is expecting integers in the Data column, not strings.
Here is the code which will fix this.
File: Upgrade.Controllers.MediaController Method: MediaPicker (HttpPost) Code Change: if (media != null) { contentField.Url = "{" + media.Id + "}"; } else { // We don't want "broken" links left behind so instead want them converted to empty fields as broken links cause the page to crash // Because this might be run "twice", don't override already valid contentField Url's string contentFieldUrl = contentField.Url; if (!contentFieldUrl.StartsWith("{")) { contentField.Url = ""; } }
In a "normal" circumstance it would never be run "twice" but I perform the check just in case their are others out there who modify the database to be able to run through this upgrade two times.