In views_panels_handler_relationship_panelizer_entity class, the relationship is created by matching the panelizer entity_id to the entity base - such as the NID of a node. If the entity has multiple revisions, the views query ends up creating multiple results. As far as I can tell, we can't display a link to the revision or anything that would distinguish one of the listings from another. There's nothing in the defined relationships that gives access to a revision ID other than the current one. There'd have to be a relationship to the node_revision table.
One way to fix this would be to instead match the panelizer entity revision_id to the entity revision ID, or vid, which is saved in the base table. I think this is safe to do now, because the panelizer integration currently only supports nodes, not other entity types.
For the future, taxonomy terms and fieldable panels panes have a vid column on the base table, but users and managed files do not. You'd have to fall back on the base field if a revision field is not present.
| Comment | File | Size | Author |
|---|---|---|---|
| #5 | views_panels-duplicate-rows-2896562-5.patch | 1.68 KB | dsnopek |
| #5 | interdiff.txt | 1.88 KB | dsnopek |
Comments
Comment #2
cboyden commentedHere's a patch that uses the revision ID to create the relationship. With this patch, there is only one result per pane per page, which points to the current revision.
Comment #3
cboyden commentedAnother wrinkle would be if workbench_moderation or something similar were in use. In that case, you might want to see pane usage on pending as well as current revisions. Which would require a relationship to node_revision and a means to specify in the view whether you wanted to look at just the current revision or not.
Comment #4
dsnopekThanks!
Hard-coding 'vid' isn't quite right, though - some entity types call this field something else (like 'revision_id'). We should look it up off the entity info. My goal with this handler is to allow us to use it for all the Panelizer entity types (even though it isn't currently)
Yeah... I'm thinking maybe we should have configuration for whether you want to limit it to the current revision or not. Joining to the revision table itself (like node_revision) would be a different relationship, but maybe we could use the same handler class? Having a relationship to the revision table should probably be another issue, but here lets handle the configuration part.
I'm gonna take a shot at improving this patch
Comment #5
dsnopekOk, here's an updated patch that I hope makes the handler generic enough to work with any entity type, and configurable enough that we could use the same handler class for a relationship with the revision table (like we'd need to do for workbench_moderation support). But I haven't actually tested it with a non-revisionable entity or workbench_moderation, so who knows :-)
Comment #6
cboyden commentedTested this patch locally and it looks good. The logic makes sense.
Comment #8
dsnopekThanks, committed!