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.
If you try the Top Search Phrases report (admin/reports/search), and click on the Message column to sort by the message, the messages are not sorted alphabetically. See screen shot.
I have also tried clicking repeatedly to change from forward to reverse sorting order, and the sort order does not change.
Other "top" reports do not seem to have this same problem, just the top search phrases report.
Comment | File | Size | Author |
---|---|---|---|
#16 | 830642-16.patch | 1.43 KB | ameymudras |
#2 | 830642-nosort-topreport.patch | 1.6 KB | jhodgdon |
report-bad-sort.png | 9.75 KB | jhodgdon |
Comments
Comment #1
jhodgdonI see the problem. The "top" report sorts by the 'message' field of the {watchdog} table.
The search entries all have the same message:
Searched %type for %keys.
So I think sorting by message should be turned off for this type of report. It is meaningless, given that the message uses variable substitution to compose what the UI would see as the message.
This is function dblog_top() in modules/dblog/dblog.admin.inc for future reference.
Comment #2
jhodgdonHere's a patch.
There was an additional bug in this function: the count query was wrong -- the main query was grouping on (message, variables), but the count query was only counting distinct(message).
So... This loses some functionality for the Top Access Denied and Top Page Not Found reports. For them, it probably makes sense to use a table header sort. But for the generic case, where the on-screen-displayed message is a substitution of variables into message, sorting by the message field doesn't work in the UI.
Maybe there should be two functions, one that does table sort and one that doesn't? Anyway, this patch doesn't...
Comment #3
jhodgdon#2: 830642-nosort-topreport.patch queued for re-testing.
Comment #4
dagmarThis is valid for D8 too.
Comment #15
quietone CreditAttribution: quietone at PreviousNext commentedThis is still valid.
.
Comment #16
ameymudras CreditAttribution: ameymudras at Salsa Digital commentedWas able to replicate the issue on 9.5.x, used reference from #2 to create a patch. Couldn't generate an interdiff
Comment #18
dagmarI'm afraid this fix won't be compatible with Drupal using SQLITE. There is no
CONCAT
function there.Comment #19
dagmarHm... Maybe it is supported somehow by the Drupal layer.
Drupal\Driver\Database\sqlite\Connection::sqlFunctionConcat
but anyways this needs tests, and specially run them against Sqlite.