I'm not sure if this will become obsolete if/when #2015149: Replace dblog recent log entries with a view gets done but here it is anyway.
When sorting the dblog by the User, an error is thrown:
Drupal\Core\Database\DatabaseExceptionWrapper: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'u.name' in 'order clause': SELECT w.wid AS wid, w.uid AS uid, w.severity AS severity, w.type AS type, w.timestamp AS timestamp, w.message AS message, w.variables AS variables, w.link AS link FROM {watchdog} w ORDER BY u.name ASC LIMIT 50 OFFSET 0; Array ( ) in Drupal\dblog\Controller\DbLogController->overview() (line 169 of /var/www/core/modules/dblog/src/Controller/DbLogController.php).
I believe this happens because the ordering is done in the query by u.name a column which is not joined into the dblog query. Patch coming.
| Comment | File | Size | Author |
|---|---|---|---|
| #12 | dblog-fix-2344103-12.patch | 2.19 KB | upchuk |
| #12 | dblog-test-2344103-12.patch | 1.38 KB | upchuk |
| #8 | dblog-fix-2344103-8.patch | 3.24 KB | upchuk |
| #7 | dblog-test-2344103-7.patch | 2.43 KB | upchuk |
| #2 | dblog-2344103-3.patch | 834 bytes | upchuk |
Comments
Comment #1
upchuk commentedComment #2
upchuk commentedHere's a patch that joins the user_data_field table in order to properly sort by the username.
Comment #3
upchuk commentedComment #4
xjmNice find!
The next step will be to add an automated test for this bug:
https://drupal.org/contributor-tasks/write-tests
Comment #5
xjmProviding an EXPLAIN for the new query could be helpful information too.
Comment #6
upchuk commentedI believe this is what you meant. Running the new query with EXPLAIN:
+----+-------------+-------+------+---------------+---------+---------+---------------+------+-------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+-------+------+---------------+---------+---------+---------------+------+-------------+
| 1 | SIMPLE | w | ALL | NULL | NULL | NULL | NULL | 261 | |
| 1 | SIMPLE | ufd | ref | PRIMARY | PRIMARY | 4 | VAGRANT.w.uid | 1 | Using index |
+----+-------------+-------+------+---------------+---------+---------+---------------+------+-------------+
Comment #7
upchuk commentedI wrote a test for the bug by creating a separate test class. I believe though that it may be incorporated into the existing
DbLogTestclass. I'm not sure how the procedure is though...Attaching the test patch (that should fail) and the test + fix patch (that should, hopefully, pass).
D
Comment #8
upchuk commentedAnd here is the patch with the test + fix.
Comment #10
upchuk commentedComment #11
wim leersPlease make this description similar to
DbLogTest::testfilter():Tests the database log sort functionality at admin/reports/dblog.We generally don't write these kinds of comments for test methods. We only provide a single-line description.
I think you can move this test into
DbLogTest— yoursetUp()method does almost exactly the same, so no need for a seperate web test.Extraneous newlines at the beginning and end of function bodies.
Hrm, shouldn't these variable names be the other way around? :)
You abstracted the expected response code, but it's always 200. Let's just remove this parameter and hardcode it to 200. This is a testing helper function; no need to abstract here unless absolutely necessary :)
… also no newlines between
@paramdoxygen statements.Comment #12
upchuk commentedHey Wim, thanks for reviewing.
I addressed most of the issues (apart from those that are obsolete with the move of the test to the existing DBLog one).
As for the variable names, they are given by the query params needed in the sorting (sort=asc&order=User) :)
Comment #14
eiriksmTested and verified that it fixes the issue.
Only thing I could think of was the variable names as pointed out by @Wim, but it makes sense to call them the same as the query parameters I guess, so that's probably another issue ;)
Comment #15
alexpottCommitted 5ad6a5e and pushed to 8.0.x. Thanks!