0
votes

I'm supporting an existing Sitecore data provider that an outside consultant created. It's working for the most part, but there seems to be a bug when populating a field that I need to troubleshoot.

I'm trying to determine the best way to debug. Is a data provider executed when a content item is viewed/edited? Or when the content item is published? Or both?

Also, what is the best practice for debugging a data provider? Is it practical/possible to create unit tests?

This may or may not be relevant, but this particular data provider is built on top of the Spring Framework, which means a giant config file the Sitecore items and fields that this provider will populate.

1

1 Answers

3
votes

Each "database" (master/core/web) in Sitecore is actually an open channel that any number of data providers can subscribe to and respond on. When any database request happens in Sitecore, all data providers that have implemented that request method will fire and be given a chance to respond. Examples of these request methods would be:

  • GetParentID
  • GetItemVersions
  • GetItemFields
  • SaveItem

You can certainly debug these data providers as you would any other code in Sitecore (attach to the IIS worker process), whether it fires or not depends on which methods this data provider implements. One thing you might find is that the method isn't firing because the item is now cached, to ensure this isn't happening simply reset the app pool, best way to do that is tap the web.config or rebuilt the project.

Hope that helps, you could also try taking apart a data provider I wrote last year if you're looking for another example.