Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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
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 |
Comment | File | Size | Author |
---|---|---|---|
#39 | entitylistbuild-paging-1798332-39.patch | 8.76 KB | jhedstrom |
#39 | entitylistbuild-paging-1798332-39-TEST-ONLY.patch | 3.74 KB | jhedstrom |
Comments
Comment #1
sunWith the new entity query for configurables, this might be possible and might even make sense :)
Comment #2
dawehnerStarted 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?
Comment #4
dawehnerLet's see how much fails if there is a proper amount of items returned.
Comment #5
vrMarc CreditAttribution: vrMarc commented#4: drupal-1798332-4.patch queued for re-testing.
Comment #6
jibran#4: drupal-1798332-4.patch queued for re-testing.
Comment #8
tim.plunkettRemoving all the tags is one way to help everyone forget about an issue
Comment #9
willieseabrook CreditAttribution: willieseabrook commentedComment #10
MaherSakka CreditAttribution: MaherSakka commentedComment #11
dawehnerI am not sure whether it is actually worth to do it.
Comment #12
BerdirShipping 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?
Comment #13
sunIsn'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.
Comment #14
BerdirYes, 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?
Comment #15
jhedstromThis seems major. For instance, if a site turns views off, the node listing page doesn't have paging.
Comment #16
jhedstromThis is a reroll of #4 that gets paging working.
Comment #18
jhedstromSoooo...adding a pager to a table removes the HTML ID from the markup apparently, thus the fails.
Comment #19
jhedstromActually, 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.Comment #20
jhedstromNevermind, 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.
Comment #21
jhedstromComment #22
tim.plunkettLet's wrap this function in a method, like
protected function getCurrentPage($limit);
or similarComment #24
jhedstromThis should address the remaining fails. I also added a wrapper method as suggested in #22 for getting the current page.
Comment #25
BerdirSee #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.
Comment #26
prajaankit CreditAttribution: prajaankit commentedComment #27
jhedstromThe patch in #26 is still using
range()
instead ofpager()
. It also has several coding standard issues.Comment #28
vedpareek CreditAttribution: vedpareek commentedRerolled
Comment #29
vedpareek CreditAttribution: vedpareek commentedComment #32
jhedstromHere is a reroll that should apply. It also addresses the pager part of #25, which did significantly simplify things!
I don't fully understand what needs to be changed regarding this comment though.
Comment #33
BerdirThe 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.
Comment #34
jhedstromThanks for the clarification Berdir, that makes sense. How's this approach look?
Comment #35
BerdirYes, 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).
Comment #36
jhedstromGood call on tests.
In case there's any doubt, test also attached separately.
Comment #37
jhedstromOops, forgot to add config entity test. I'll work on that.
Comment #39
jhedstromThis adds a config entity test.
Comment #41
jhedstromUpdating issue summary and adding a beta phase evaluation.
Comment #42
tim.plunkettThanks @jhedstrom for doing this, the patch looks great.
Comment #43
catchCommitted/pushed to 8.0.x, thanks!
Comment #46
andypostFollow-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