After the views conversion of the admin/people listing, there's some cruft left behind that could be cleaned up.
- Extending $options but $options doesn't exist anymore
- Not using user_load_multiple()
- Unecessary loading of user roles with a query per user
- Loading unecessary data in the query.
See #1932068: People Admin Table Missing Labels and #1751274: Do not query user_roles directly, you can basically re-use all changes to that function from the last issue and additionally remove the $options line from the first. Possibly even more that I haven't noticed yet.
Comments
Comment #1
mgiffordBy disabling Views, you also should be able to get something on the People page that looks better than.
Comment #2
legolasboAttached patch should fix all of the issues mentioned above.
Comment #3
BerdirYou can use $uids = $query->execute()->fetchCol(), then you don't need the array_keys() below.
You also have some trailing spaces in the patch.
Comment #4
legolasboThanks for your feedback Berdir.
Apparently I forgot to enable automatic removal of trailing whitespace when I got my new laptop. Attached patch uses fetchCol() and has been cleared of whitespace.
Comment #5
BerdirPatch looks good except that it's unfortunately inversed :)
Comment #6
legolasboHaha, this should do it then.
Comment #7
BerdirThanks, remember to set issues to needs review after uploading a patch.
Comment #8
BerdirLooks good I think.
Comment #9
dawehnerThere should be probably a follow up to use a entity list controller for this piece of code?
Comment #10
tim.plunkett#1938884: Replace the fallback user listing with a list controller exists, is blocked.
Comment #11
alexpottThis can be removed as well as $roles is now unused.
Comment #12
legolasboAttached patch also removes the line spotted by alexpott.
Comment #14
Berdir#12: core-clean-up-user-admin-account-2037675-12.patch queued for re-testing.
Comment #15
BerdirApplied the patch and confirmed that there are no unused variables or something else to clean-up left.
Comment #16
alexpottCommitted 5600df4 and pushed to 8.x. Thanks!
Comment #17
dawehnerGreat. Let's do all the injection stuff (use the entity storage controller) in the followup.
Comment #18
dawehnerComment #19
tstoecklerCan someone explain the following code, I seem to be missing something:
Comment #20
BerdirAs discussed, opened #2057999: Add argument to AccountInterface::getRoles() that allows to exclude the anonymous/authenticated roles