I had this inspiration in the shower this morning (tmi, I know) to help resolve supposed entity metadata wrapper problems. It seems the largest (if not only) culprit pertaining to line item saving at least is that somehow people are ending up with Commerce installed but entities missing. Various modules when they are enabled or when they detect other module implementing their info hooks are enabled are adding some default, required fields to entities (like unit price and total price fields on every line item type). When these fields are missing, it results in errors any time we assume the fields' presence in the code.
What I'm proposing then is a page in the Development menu where we can display the default required fields on the various Commerce entities and their status (present or missing). If any are missing, we'd have a form button that could be submitted to create them afresh. We can do this with a simple hook_commerce_default_fields() that returns the various default fields and a callback to create them. These callbacks are already in place, and everywhere we're making fields we're first checking to make sure the field / instance doesn't already exist... so this could be a potentially lightweight fix to a common problem. It'd give us a great place to refer users to when we're trying to debug their field problems, too.
Thoughts?
Comments
Comment #1
rfayWhy not just put this into hook_requirements()? It's a great idea.
Comment #2
rszrama commentedThought about that, but I didn't know if the information would get lost in the general table or how we'd get the re-build form on there.
Comment #3
rfayI think we could just have a link there that points to the page that would rebuild the default fields. That page to rebuild default fields is a big win here too.
Comment #4
Balbo commentedAny news on this?
Comment #5
1kenthomas commentedIt would certainly be very useful to have some way to check each of a series of entities for data integrity: I, for instance, am being asked to diagnose this message on a webpage, with no obvious way to discover the entity/entities which are causing it to appear.