GetDataItem() returns the wrong type
I stumbled across what appears to be a bug in Sitefinity 7.1.5200. I was making a call to DynamicContent.GetDataItem(Type, Guid), and accidentally passed in an incorrect guid from a different item type. I expected GetDataItem to return null, since the guid does not exist for the Type that I passed in. Instead, it found the guid in the system under a different item type, and returned that one. I drilled down to the code for GetDataItem and found that the Type parameter is not being used.
Can someone please verify that this is incorrect behavior?
The method will indeed return the item even when a different object type is passed. The items are not filtered by the type parameter, which could lead to unexpected behavior. I have logged a bug regarding the issue, which can be reviewed here. I have also updated your Telerik points. As a workaround you can check whether the returned item type is of the one you expect, or make the query to get all items of those type and filter by the id and then to get the item in the memory.