Problem/Motivation

Entity lists that are generated by EntityListBuilder (and ConfigEntityListBuilder) have no paging. This includes nodes and taxonomy terms if the Views module is disabled. Given that, a sufficiently large site would not be able to load the content or term administration pages if Views happened to be disabled.

Originally posted as a follow-up to #1781372: Add an API for listing (configuration) entities.

Proposed resolution

Add paging to EntityListBuilder

Remaining tasks

User interface changes

Entities will have paging!

API changes

No public facing changes.

Beta phase evaluation

Reference: https://www.drupal.org/core/beta-changes
Issue category Bug/Task
Issue priority Major because sites with lots of content that disable Views, will be unable to browse nodes, terms, etc.
Unfrozen changes Unfrozen because it only changes entity listings to improve usability
Prioritized changes The main goal of this issue is usability
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

sun’s picture

Component: entity system » configuration entity system

With the new entity query for configurables, this might be possible and might even make sense :)

dawehner’s picture

Status: Active » Needs review
FileSize
1.94 KB
26.08 KB

Started to work on that.

This now uses entity query to recieve it's items, so using range() is pretty easy.
There are for sure still a lot of problems: How to inject stuff, should this handle a unique pager element ID? Should this patch take care about ALL the implementations in core which work different?

Status: Needs review » Needs work

The last submitted patch, drupal-1798332-2.patch, failed testing.

dawehner’s picture

Status: Needs work » Needs review
FileSize
1.94 KB
497 bytes

Let's see how much fails if there is a proper amount of items returned.

vrMarc’s picture

jibran’s picture

#4: drupal-1798332-4.patch queued for re-testing.

Status: Needs review » Needs work

The last submitted patch, drupal-1798332-4.patch, failed testing.

tim.plunkett’s picture

Title: Add paging to the EntityListController » Add paging to the EntityListBuilder
Issue summary: View changes
Issue tags: +Configurables, +VDC, +Entity system, +Needs issue summary update, +Needs reroll

Removing all the tags is one way to help everyone forget about an issue

willieseabrook’s picture

Issue tags: +TUNIS_2014_MARCH
MaherSakka’s picture

Assigned: Unassigned » MaherSakka
dawehner’s picture

I am not sure whether it is actually worth to do it.

Berdir’s picture

Shipping with a Node and User list controller that doesn't do paging seems absolutely crazy :)

However, I agree that for config entities, it doesn't make much sense, as it would solely be a UI thing, we have to load them anyway for the entity query.

But maybe we should only do this in a ContentEntityListBuilder by default?

sun’s picture

for config entities [...] we have to load them anyway for the entity query.

Isn't that a detail that is internal to the chosen storage implementation?

For example, in case #2162161: Change DatabaseStorage to use XML instead of serialize is going to happen, then the serialized config entities could be filtered and queried through native document query support in the storage engine; i.e., a corresponding config entity query implementation would not actually have to load all the entities first.

Berdir’s picture

Yes, maybe, *but* config storage and config entity query is not on the same implementation layer. Config entities use the Config API to deal with raw configuration data, they don't know which storage or serializer is used and they shouldn't.

I don't see a way to implement that without implementing completely new API's or violating the API layers there.

I also doubt that the performance gain of doing that query in the database will worse the considerably slower serialization that XML would imply?

jhedstrom’s picture

Priority: Normal » Major

This seems major. For instance, if a site turns views off, the node listing page doesn't have paging.

jhedstrom’s picture

Status: Needs work » Needs review
FileSize
1.85 KB

This is a reroll of #4 that gets paging working.

Status: Needs review » Needs work

The last submitted patch, 16: entitylistbuild-paging-1798332-16.patch, failed testing.

jhedstrom’s picture

Soooo...adding a pager to a table removes the HTML ID from the markup apparently, thus the fails.

jhedstrom’s picture

Actually, it isn't so much adding the pager, as moving the build array in one level to $build['table'] that strips the ID. Not sure if there is a known issue for that, or a workaround.

jhedstrom’s picture

FileSize
2.55 KB
722 bytes

Nevermind, I realized the ID was manually being added, and the change mentioned in #19 moved the table so the ID wasn't properly added. This should fix some, if not all, of the fails.

jhedstrom’s picture

Status: Needs work » Needs review
tim.plunkett’s picture

+++ b/core/lib/Drupal/Core/Entity/EntityListBuilder.php
@@ -74,7 +81,17 @@ public function getStorage() {
+    $current_page = pager_default_initialize($total_items, $this->limit, 0);

Let's wrap this function in a method, like protected function getCurrentPage($limit); or similar

Status: Needs review » Needs work

The last submitted patch, 20: entitylistbuild-paging-1798332-20.patch, failed testing.

jhedstrom’s picture

Status: Needs work » Needs review
FileSize
2.7 KB
4.46 KB

This should address the remaining fails. I also added a wrapper method as suggested in #22 for getting the current page.

Berdir’s picture

Status: Needs review » Needs work

See #2136559: Config entity admin lists show configuration with overrides (eg. localized), we will need to update for that issue. As commented there, I suggest we move the entity query in a separate helper function, so it is easier to re-use and override.

I don't get why this is using range() and not pager(), which is always available and takes care of the paging for us? Should simplify things.

prajaankit’s picture

Status: Needs work » Needs review
Issue tags: +SprintWeekend2015
FileSize
4.72 KB
jhedstrom’s picture

Status: Needs review » Needs work

The patch in #26 is still using range() instead of pager(). It also has several coding standard issues.

vedpareek’s picture

Status: Needs work » Needs review
FileSize
6.29 KB

Rerolled

vedpareek’s picture

FileSize
4.77 KB

The last submitted patch, 28: 1798332_28.patch, failed testing.

Status: Needs review » Needs work

The last submitted patch, 29: 1798332_29.patch, failed testing.

jhedstrom’s picture

Status: Needs work » Needs review
Issue tags: -Needs reroll
FileSize
940 bytes
4.1 KB

Here is a reroll that should apply. It also addresses the pager part of #25, which did significantly simplify things!

See #2136559: Config entity admin lists show configuration with overrides (eg. localized), we will need to update for that issue. As commented there, I suggest we move the entity query in a separate helper function, so it is easier to re-use and override.

I don't fully understand what needs to be changed regarding this comment though.

Berdir’s picture

The problem is that ConfigEntityListBuilder has overridden load() now, so config entities no longer call this.

So my suggestion is to move the entity query part into a protected function getEntityIds() or so, and then pass that to $storage->loadMultiple(), then you can call that as well in ConfigEntityListBuilder::load(), and we can use a pager for config entities too.

jhedstrom’s picture

FileSize
1.54 KB
5.02 KB

Thanks for the clarification Berdir, that makes sense. How's this approach look?

Berdir’s picture

Yes, that is what I meant.

We probably need some test coverage for this, e.g. create 51 nodes and check that we have a pager? And because the code path is different, the same for a config entity. We should use a different one than NodeType there I think, because those are expensive to create. Maybe use ConfigTest (and EntityTest, although I'm not sure if we have a collection route for them right now).

jhedstrom’s picture

Good call on tests.

In case there's any doubt, test also attached separately.

jhedstrom’s picture

Oops, forgot to add config entity test. I'll work on that.

The last submitted patch, 36: entitylistbuild-paging-1798332-36-TEST-ONLY.patch, failed testing.

jhedstrom’s picture

The last submitted patch, 39: entitylistbuild-paging-1798332-39-TEST-ONLY.patch, failed testing.

jhedstrom’s picture

Issue summary: View changes

Updating issue summary and adding a beta phase evaluation.

tim.plunkett’s picture

Assigned: MaherSakka » Unassigned
Status: Needs review » Reviewed & tested by the community
Issue tags: -Needs issue summary update, -TUNIS_2014_MARCH

Thanks @jhedstrom for doing this, the patch looks great.

catch’s picture

Status: Reviewed & tested by the community » Fixed

Committed/pushed to 8.0.x, thanks!

  • catch committed b9adf5d on 8.0.x
    Issue #1798332 by jhedstrom, dawehner, vedpareek, prajaankit: Add paging...

Status: Fixed » Closed (fixed)

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

andypost’s picture

Follow-up #2895320: Translated menu's name and description are not showing up under the target language.

List builder should load entities using overrides to reflect UI language