ViewableInterface should provide a method to get required relations for canView

Kirby

Well-known member
Affected version
2.3.0 Beta 6
ViewableInterface allows to perform viewability checks on arbitrary entities that implement this interface.

Depending on the entity, actually calling canView requires quite a few relations to performan viewability checks:
A Post entity for example requires Thread, Thread.Forum, Thread.Forum.Node and Thread.Forum.Node.Permissions.

If those entitites are not already available in the entity cache this causes quite a few additional queries; if multiple arbitrary entities need to be checked this could cause m*n additional queries in worst case.

It would therefore be great if ViewableInterface had a method to get the required relations so they can be included in finder with
 
This has effectively been implemented in several places in XF.

I think part of the issue is while the entity structure record has a with argument, there isn't any consistent structure to how it is used/implemented for this sort of use-case (ie for view/for list/etc).
 
Back
Top Bottom