Closed (won't fix)
Project:
Drupal core
Version:
11.x-dev
Component:
node system
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
23 Oct 2015 at 09:57 UTC
Updated:
13 Aug 2025 at 05:14 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
felribeiro commentedMake Author column sortable
Comment #3
rakesh.gectcrpls review the patch attached
Comment #4
rakesh.gectcrComment #5
cosmicdreams 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 commentedComment #7
capuleto 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 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 commentedWell at least it is a simple thing to change
Comment #11
yoroy commentedComment #12
cosmicdreams 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 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 commentedIt is not sortable since #373897: admin/content still has sortable author column resulting in SQL errors.
Comment #17
surbz 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 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 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 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 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.
Comment #40
mariacha1 commentedComment #41
mariacha1 commentedComment #42
xjmGiven the extent of my issue update in #27 and the fact that it was over seven years ago, this issue probably isn't a good novice contribution candidate. Thanks!
Comment #45
acbramley commentedRolled into an MR.
I think the decision on whether this makes sense is valid when sites implement hook_user_format_name_alter, however those sites could simply turn it off?
I don't think we need tests here as we're just toggling on sorting - this should be tested elsewhere.
I don't think we need profiling here as the db query is simple.
Comment #46
smustgrave commentedSeems pretty straight forward.
Comment #47
quietone commentedComment #48
catchThis is the only column in that view that's not on the node base table, and given there can be filters on published status etc., it seems quite possible we could end up with a temporary table and filesort on the query that there otherwise wouldn't be when it has to filter on one table and sort on another, so I think this does need an
EXPLAINper #27.Agreed it doesn't need automated tests though, views should cover this in its own test coverage.
Comment #49
smustgrave commentedMay be the right status?
Comment #50
acbramley commentedHere's the explain on the query from loading the view and clicking the tablesort.
So yeah we're using temp tables.
Setting to PMNMI for the decision on whether we want to do this. Personally I'm happy to close.
Comment #51
acbramley commentedGiven all the points raised in #27, especially the potential performance impact and the fact that this is so easy to toggle on for a site I think it's best that we leave it off by default.
Comment #52
acbramley commentedUpdating credits.