When you're displaying a group of entities in a panel pane, the unpublished nodes are taken into account and even when not accessible by the current user, they add up to the count of items, leading to less items than what's desired being shown.

Take for example if you have a pane where 7 items are to be displayed. If 2 of these entities are unpublished, only 5 entities will be displayed, leading to possible breaking layouts and inconsistent design.

Comments

svenryen created an issue. See original summary.

svenryen’s picture

The attached patch fixes the issue by checking the entities with `entity_access('view', ...)` before returning the output. This way, we will always have a consistent number of entities shown in a panel pane.

I have also thought of the possibility that the entity collection would be split over several panes, so in that case it checks the visibility of all entities from the beginning of the collection.

svenryen’s picture

Title: Unpublished entities are counted/included when parts of a collection is shown in a panel, leading to less items than desired being displayed » Unpublished entities are counted causing less items than desired to be displayed
esolitos’s picture

It seems to me that the patch only considers 1 level of depth when counting?

On top of that i see a performance issue, for every item a foreach on all children is added which calls an entity_access in the itea, and the same call is then called again in renderTreeNode.
Maybe we can re-work how the ECStyleHierarchyLimited handles the limits.

svenryen’s picture

When the items are displayed on a page, only the first level is counted - any additional levels are ignored in the logic that figures out which elements to display in a pane, which is why I check only the first level.

Performance isn't affected. The result of entity_access is cached, so when it's called the consecutive times on all children it doesn't hit the database, which is also the case for the call in renderTreeNode.

You can also see on line 57 there's a fix for the performance issue you are implying.
if ($visible_items == $limitation['length']) { which will cause the loop to stop after it's checked the items which are necessary for the current pane to fill up.

  • esolitos committed 33315c5 on 7.x-2.x authored by svenryen
    Issue #2873691 by svenryen: Unpublished entities are counted causing...
esolitos’s picture

Status: Active » Fixed

Thanks for the patch, I rerolled it and applied to the current 2.1 release! :)

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.