Problem with keyvalueprevalueEditor Dataresolver (Fix included!)
We are having an issue transferring datatypes that use the KeyValuePrevalueEditor DataResolver in Courier 2.7 with Umbraco 6.1.1. We’ve upgraded to the latest nightly build of Courier (2.7.8.16) and the issue persists. We have been able to track the issue as far as a call to
When this method is called the Prevalues that are returned all have an Id of 0. The Alias, SortOrder and Value do match the cmsDataTypePreValues, just the Id is wrong. It appears that this Id is used by the DataResolver to set the value for Courier to transfer. The end result is that the value is always an empty string. A review of the Umbraco.Courier.Persistence.V6.NHibernate.dll seems to indicate that the Id is not being set. Below is a screenshot showing the issue in action with the application paused just after the call to RetrieveItem.
We will manually create our own fix - however, we'd greatly appreciate a fix in the core product!!
We used ILSpy to modify the Umbraco.Courier.Persistence.V6.NHibernate.dll. The problem area is near the end of the RetrieveItem method in the loop which assigns all the Prevalues (it is highlighted in the screenshot Steve posted). The fixed version of that loop is below.
Hi Nick. We used ILSpy to decompile the DLL then made the change and recompiled it. We overwrite the original file with our updated version. I should note that we ended up dropping Courier from this project due to issues similar to this repeatedly cropping up so we haven't been able to test the long term effects of this change. YMMV
Okay I managed to decompile and recompile however I get this during couriering:
System.InvalidCastException: Unable to cast object of type 'System.Int32' to type 'System.String'. at Umbraco.Courier.Persistence.V6.NHibernate.Persisters.DocumentItem.RetrieveItem[T]
Seems like Id is sometimes a string or something isn't casting properly
Jonathan's fix seems to work for me, but i would like to add that this only works when your datatype is being saved as an integer, when it is set to nvarchar or text this fix does not seem to work. Don't know if anyone ever created a support ticket? I just did :)
Problem with keyvalueprevalueEditor Dataresolver (Fix included!)
We are having an issue transferring datatypes that use the KeyValuePrevalueEditor DataResolver in Courier 2.7 with Umbraco 6.1.1. We’ve upgraded to the latest nightly build of Courier (2.7.8.16) and the issue persists. We have been able to track the issue as far as a call to
PersistenceManager.Default.RetrieveItem<DataType>( itemId);
When this method is called the Prevalues that are returned all have an Id of 0. The Alias, SortOrder and Value do match the cmsDataTypePreValues, just the Id is wrong. It appears that this Id is used by the DataResolver to set the value for Courier to transfer. The end result is that the value is always an empty string. A review of the Umbraco.Courier.Persistence.V6.NHibernate.dll seems to indicate that the Id is not being set. Below is a screenshot showing the issue in action with the application paused just after the call to RetrieveItem.
We will manually create our own fix - however, we'd greatly appreciate a fix in the core product!!
Steve,
We are seeing this issue as well. You mentioned there's a fix included; are there updated dlls/diffs available for this?
What's interesting is dropdowns using custom controls instead of the standard KeyValue pair seems to transfer using courier just fine.
Hi Tristan,
We used ILSpy to modify the Umbraco.Courier.Persistence.V6.NHibernate.dll. The problem area is near the end of the RetrieveItem method in the loop which assigns all the Prevalues (it is highlighted in the screenshot Steve posted). The fixed version of that loop is below.
foreach (CmsDataTypePreValue dataTypePreValue in Enumerable.Where((IEnumerable) currentSession.CreateCriteria().List(), (Func) (x => x.DatatypeNodeId == dt.UmbracoNode.Id)))
dataType.Prevalues.Add(new DataTypePrevalue()
{
Value = dataTypePreValue.Value,
Alias = dataTypePreValue.Alias,
SortOrder = dataTypePreValue.Sortorder,
Id = dataTypePreValue.Id
});
How did I not know about ILSpy? Thanks much, that was really helpful!
How do I modifly and save the DLL?
Or did you create a class that overrides this?
Hi Nick. We used ILSpy to decompile the DLL then made the change and recompiled it. We overwrite the original file with our updated version. I should note that we ended up dropping Courier from this project due to issues similar to this repeatedly cropping up so we haven't been able to test the long term effects of this change. YMMV
Okay I managed to decompile and recompile however I get this during couriering:
System.InvalidCastException: Unable to cast object of type 'System.Int32' to type 'System.String'. at Umbraco.Courier.Persistence.V6.NHibernate.Persisters.DocumentItem.RetrieveItem[T]
Seems like Id is sometimes a string or something isn't casting properly
I found the bug
I had to change Document.cs in Persisters.DocumentItem line 142 to:
document1.CourierFileName = cmsDocument.Text + (object) "_" + cmsDocument.UmbracoNode.Id.ToString();
and now it works!
Is anyone from the courier development team seeing this???
Hi,
Jonathan's fix seems to work for me, but i would like to add that this only works when your datatype is being saved as an integer, when it is set to nvarchar or text this fix does not seem to work. Don't know if anyone ever created a support ticket? I just did :)
Gerty
is working on a reply...