Problem/Motivation
I thought about adding this to #3436965: Submissions results not accessible, since there are some similarities, but they are different columns and showing up at a different time so I think should be reported separately.
If I try to click to sort on the User column of my log table at /admin/structure/webform/submissions/log, then I get:
Drupal\Core\Database\DatabaseExceptionWrapper: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'user.name' in 'order clause': SELECT "log"."lid" AS "lid", "log"."uid" AS "uid", "log"."webform_id" AS "webform_id", "log"."sid" AS "sid", "log"."handler_id" AS "handler_id", "log"."operation" AS "operation", "log"."message" AS "message", "log"."variables" AS "variables", "log"."timestamp" AS "timestamp", "log"."data" AS "data", "submission"."entity_type" AS "entity_type", "submission"."entity_id" AS "entity_id" FROM "webform_submission_log" "log" LEFT OUTER JOIN "users_field_data" "u" ON log.uid = u.uid LEFT OUTER JOIN "webform_submission" "submission" ON log.sid = submission.sid ORDER BY "user"."name" ASC LIMIT 50 OFFSET 0; Array ( ) in Drupal\webform_submission_log\WebformSubmissionLogManager->loadByEntities() (line 134 of modules/contrib/webform/modules/webform_submission_log/src/WebformSubmissionLogManager.php).
Drupal\Core\Database\StatementWrapperIterator->execute(Array, Array) (Line: 851)
Drupal\Core\Database\Connection->query('SELECT "log"."lid" AS "lid", "log"."uid" AS "uid", "log"."webform_id" AS "webform_id", "log"."sid" AS "sid", "log"."handler_id" AS "handler_id", "log"."operation" AS "operation", "log"."message" AS "message", "log"."variables" AS "variables", "log"."timestamp" AS "timestamp", "log"."data" AS "data", "submission"."entity_type" AS "entity_type", "submission"."entity_id" AS "entity_id"
FROM
{webform_submission_log} "log"
LEFT OUTER JOIN {users_field_data} "u" ON log.uid = u.uid
LEFT OUTER JOIN {webform_submission} "submission" ON log.sid = submission.sid
ORDER BY "user"."name" ASC
LIMIT 50 OFFSET 0', Array, Array) (Line: 524)
Drupal\Core\Database\Query\Select->execute() (Line: 329)
Drupal\Core\Database\Query\SelectExtender->execute() (Line: 81)
Drupal\Core\Database\Query\PagerSelectExtender->execute() (Line: 134)
Drupal\webform_submission_log\WebformSubmissionLogManager->loadByEntities(NULL, NULL, NULL, Array) (Line: 109)
Drupal\webform_submission_log\Controller\WebformSubmissionLogController->overview(NULL, NULL, NULL, NULL)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 638)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 121)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 181)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 76)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 53)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 28)
Drupal\Core\StackMiddleware\ContentLength->handle(Object, 1, 1) (Line: 32)
Drupal\big_pipe\StackMiddleware\ContentLength->handle(Object, 1, 1) (Line: 116)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 90)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 50)
Drupal\ban\BanMiddleware->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 36)
Drupal\Core\StackMiddleware\AjaxPageState->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object, 1, 1) (Line: 741)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
Steps to reproduce
As far as I know, the only requirements are to install it, have some webform submissions (some of those are from anonymous, if that matters), go to the log table view, and click on the User header to try to sort by user.
This is true on my production environment with:
Drupal core 10.3.13
Webform 6.2.8
And on my developer environment with:
Drupal core 10.4.3
Webform 6.3.0-beta1
I've tried it a couple times with some other versions in between as well, but those are the two I can currently replicate.
Proposed resolution
The error is accurate in that there is no user.name field in the webform_submission table. There is a uid in that table instead, so maybe it was trying to do something with that.
That suggests it is trying to sort alphabetically by the user's name. I found in src/Controller/WebformSubmissionLogController.php, line 104:
$header['uid'] = ['data' => $this->t('User'), 'field' => 'user.name', 'class' => [RESPONSIVE_PRIORITY_LOW]];
I think that's the culprit. The header says uid, then the field value says user.name, and there is no user.name to be able to sort by.
I could change that from user.name to uid and the sort will work, but it is sorting by the ID, not by their name. That is much better than a fatal error (most of the time in my case I don't really need them truly sorted, just grouped enough to get a sense of repeats), but certainly is confusing if you haven't looked at the code, since it does suggest in the interface that it would be sortable by name. Plus of course it looks like the code was trying to do, so me reverting it to sorting by uid would be regression.
Issue fork webform-3508995
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
cilefen commentedIt's definitely reproducible on the dev branch with a clean install. Your steps to reproduce are accurate.
Comment #5
jrockowitz commentedGotta love easy to reproduce bugs with one-liner fixes.
Comment #6
jrockowitz commentedComment #8
jrockowitz commentedComment #11
cmanalansan commentedI am using this on a Postgres setup, and fixing this issue appears to have reintroduced https://www.drupal.org/project/webform/issues/3307128
Comment #12
liam morlandThis caused an issue in Postgres fixed in #3565422: SQL table alias "user" invalid for PostgreSQL.
Perhaps it is
user.namethat needs to be changed in the code in the issue summary. Please test that this problem has not returned in the latest beta. If it has, try changinguser.nametoufd.name.Comment #13
liam morland