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.
Comment | File | Size | Author |
---|---|---|---|
#3 | 2599626-1.patch | 550 bytes | rakesh.gectcr |
#2 | make-author-column-sortable-2599626-8.patch | 382 bytes | felribeiro |
Comments
Comment #2
felribeiro CreditAttribution: felribeiro at CI&T commentedMake Author column sortable
Comment #3
rakesh.gectcrpls review the patch attached
Comment #4
rakesh.gectcrComment #5
cosmicdreams CreditAttribution: cosmicdreams as a volunteer commentedSuch a simple patch. Now that you mention it. It IS rather odd that the author is the only field in the default view that isn't sortable. I wonder if that was intentional or an outcome of converting the default admin_view for the content page to Drupal 8.
I think making this small change will dodge a source of confusion to content managers who visit this page on their shiny new Drupal 8 sites.
RTBC.
Comment #6
Chi CreditAttribution: Chi commentedComment #7
capuleto CreditAttribution: capuleto at Eksponent commentedI believe this patch won't work as soon as one implementation of hook_user_format_name_alteralters the user name since the view will sort by the username stored in the database and not by the one displayed
Comment #8
Chi CreditAttribution: Chi commentedI just found that the Author column is not sortable in Drupal 7 as well.
Comment #9
xjmThanks for submitting this patch!
As a feature request, this change should now be postponed to 8.1.x since Drupal 8.0.x is in its release candidate phase. Reference: https://www.drupal.org/core/d8-allowed-changes
Comment #10
cosmicdreams CreditAttribution: cosmicdreams as a volunteer commentedWell at least it is a simple thing to change
Comment #11
yoroy CreditAttribution: yoroy as a volunteer commentedComment #12
cosmicdreams CreditAttribution: cosmicdreams as a volunteer commentedWhat's to review, it's a simple configuration change. Are you saying that it should be manually tested? I could do that.
Comment #13
yoroy CreditAttribution: yoroy as a volunteer commentedJust checking if the patch still applies :)
Comment #14
catch@capuleto's point is worth discussing a bit more I think. Not sure if that's why it isn't sortable now.
Also sorting on username is only very helpful if you're looking for something authored by A or Z - otherwise you're clicking through pages and could use a filter instead.
Comment #15
Chi CreditAttribution: Chi commentedIt is not sortable since #373897: admin/content still has sortable author column resulting in SQL errors.
Comment #17
surbz CreditAttribution: surbz at Srijan | A Material+ Company commentedReviewed patch #3 in 8.2.x-dev and it works correctly.
Comment #18
naveenvalechacan we add tests here for testing this functionality ?
do we need an update hook here for views update ?
Comment #19
alexpott@naveenvalecha I don;t think we need to change existing sites - the functionality is not that important - plus they could have manually changed this view.
There's still not a decent response to @capuleto's point in #7 - about what happens when the user name is changed completely by the hook. For example by the realname module.
Comment #20
Chi CreditAttribution: Chi commentedWhat makes hook_user_format_name_alter() so special? There are lots of other hooks that may break the view. My point is that the developer who changes the name format owes fixing the view sorting to himself.
Comment #21
dawehnerThere is the realname module which implements this for example. It is more common to have this hook implemented than other hooks, which might break the view. In general though I agree with you, it should not prevent us from this here.
Comment #24
ronchica CreditAttribution: ronchica as a volunteer commentedI tested this manually. It might still need automated tests, but I think this is a good feature to have, so helping it along.
Without the patch, the author is not sortable/clickable:
With the patch:
Ordered by updated date:
Click on "Author" ascending:
Click on "Author" again, descending:
I also tried changing usernames, and still all worked.
Comment #25
shadcn CreditAttribution: shadcn at Chapter Three commented#1986606: Convert the comments administration screen to a view might be a related issue. Most patches there makes
uid
, hence author, sortable. And right now the comment overview form has "Author" sortable.Comment #26
ronchica CreditAttribution: ronchica as a volunteer commentedComment #27
xjmThanks @arshadcn for looking for other precedents in core; that is helpful. Thanks also @ronchica for the thorough manual testing; that's exactly the sort of review this issue needed to make progress.
I am changing the title so that everyone will keep in mind this is just a small change to new installations and will not affect existing ones.
core/modules/node/src/Tests/NodeAdminTest.php
(although it's maybe not... the most modern automated test out there). Other sorting for the view is tested in that class, so let's add tests there for this feature as well. However, I would not do the work to add tests until we confirm the performance is acceptable.NW for #3 especially.