Problem/Motivation
I just upgraded my site from drupal 9.5.2 to 9.5.4 (I also tried 9.5.3 with the same results). After the upgrade, one of my views throws this error:
[01-Mar-2023 20:08:53] WARNING: [pool www] child 70544 said into stderr: "NOTICE: PHP message: Uncaught PHP Exception Drupal\Core\Database\DatabaseExceptionWrapper: "SQLSTATE[42S22]: Column not found: 1054 Unknown column 'nametid' in 'group statement': SELECT "td"."tid" AS "tid", "td"."name" AS "name""
[01-Mar-2023 20:08:53] WARNING: [pool www] child 70544 said into stderr: "FROM"
[01-Mar-2023 20:08:53] WARNING: [pool www] child 70544 said into stderr: ""taxonomy_term_field_data" "td""
[01-Mar-2023 20:08:53] WARNING: [pool www] child 70544 said into stderr: "INNER JOIN "node__field_anonymized" "p" ON p.field_anonymized_target_id=td.tid"
[01-Mar-2023 20:08:53] WARNING: [pool www] child 70544 said into stderr: "WHERE ("td"."vid" = :db_condition_placeholder_0) AND ("p"."bundle" = :db_condition_placeholder_1)"
[01-Mar-2023 20:08:53] WARNING: [pool www] child 70544 said into stderr: "GROUP BY "nametid""
[01-Mar-2023 20:08:53] WARNING: [pool www] child 70544 said into stderr: "ORDER BY "name" ASC; Array"
[01-Mar-2023 20:08:53] WARNING: [pool www] child 70544 said into stderr: "("
[01-Mar-2023 20:08:53] WARNING: [pool www] child 70544 said into stderr: " [:db_condition_placeholder_0] => anonymized"
[01-Mar-2023 20:08:53] WARNING: [pool www] child 70544 said into stderr: " [:db_condition_placeholder_1] => anonymized_bundle"
[01-Mar-2023 20:08:53] WARNING: [pool www] child 70544 said into stderr: ")"
[01-Mar-2023 20:08:53] WARNING: [pool www] child 70544 said into stderr: "" at /var/www/html/docroot/core/modules/mysql/src/Driver/Database/mysql/ExceptionHandler.php line 53"
2023/03/01 20:08:53 [error] 2165#2165: *78352 FastCGI sent in stderr: "PHP message: Uncaught PHP Exception Drupal\Core\Database\DatabaseExceptionWrapper: "SQLSTATE[42S22]: Column not found: 1054 Unknown column 'nametid' in 'group statement': SELECT "td"."tid" AS "tid", "td"."name" AS "name"
FROM
"taxonomy_term_field_data" "td"
INNER JOIN "node__field_anonymized" "p" ON p.field_anonymized_target_id=td.tid
WHERE ("td"."vid" = :db_condition_placeholder_0) AND ("p"."bundle" = :db_condition_placeholder_1)
GROUP BY "nametid"
ORDER BY "name" ASC; Array
(
[:db_condition_placeholder_0] => anonymized
[:db_condition_placeholder_1] => anonymized_bundle
)
" at /var/www/html/docroot/core/modules/mysql/src/Driver/Database/mysql/ExceptionHandler.php line 53" while reading response header from upstream, client: 172.24.0.6, server: , request: "GET /anonymized/path/here HTTP/1.1", upstream: "fastcgi://unix:/run/php-fpm.sock:", host: "prod.local.ddev.site", referrer: "https://prod.local.ddev.site/admin/content?status=All&type=landing_page&title=anonymized&langcode=All"
[N.B. some details edited for anonymity]
The site is running on linux/apache with PHP v 8.1.
The problem shows itself in (at least) two ways. First, I have a page that shows this view as a block. That page now gives a WSOD. If I examine the view in the admin interface, the preview at the bottom doesn't appear...no visible SQL gets generated and there are no results.
Interestingly, I my a duplicate of the view and it works fine, with no changes whatsoever. So in a pinch, I can move forward by duplicating the view. However, it seems that some instability is at work here, and I'm hoping to resolve it more fully.
Steps to reproduce
Unfortunately, I couldn't find a way to reproduce the error. I tried to by duplicating the view, but that led to a working result, while the original, identical view is non-functioning. This view has operated without issue for years prior to this.
Despite this limitation, I wonder if anyone might have thoughts on diagnosing the matter further or solving it. Thanks.
Proposed resolution
Remaining tasks
User interface changes
API changes
Data model changes
Release notes snippet
| Comment | File | Size | Author |
|---|---|---|---|
| #10 | views_broken.txt | 25.73 KB | mefron |
| #10 | views_working.txt | 25.01 KB | mefron |
Comments
Comment #2
cilefen commentedComment #3
cilefen commentedThe release notes: https://www.drupal.org/project/drupal/releases/9.5.3
Comment #4
longwaveAgree with #2 that we need more info about the view itself and the site configuration to be able to help diagnose this.
I checked the changes in 9.5.3 and 9.5.4 and don't immediately see anything that was changed in Views that would affect this.
Comment #5
longwave#3191623: Select queries do not escape the GROUP BY fields did add escaping to GROUP BY, but as far as I can see that wouldn't have caused the syntax error in the query here. Somehow the
nameandtidcolumns have been merged together into a non-existentnametidcolumn, but I don't understand how that could happen.Comment #6
mefron commentedNo other modules have changed during this update; core is the only variable. There are a number of contrib and custom views-related modules installed. But none have changed at this time.
I exported the configurations of the working and non-working versions of the view and here is the result:
I'm not familiar enough with views to make much sense of this. But in case it's helpful, I built the working copy simply by using the `duplicate` function on the original, broken one.
Comment #7
mefron commentedAs a follow-up to my last post, I tried an experiment and got interesting results.
I wanted to see if I could import the working config to rebuild the broken view, and in the process, fix the break.
So I deleted the original, broken view and then imported the configuration from the working copy, replacing the UUID, id, and label fields with the data from the original. However, when I did the import, the resulting view still had the same SQL problem. So I tried again several times, keeping ALL fields constant except one at a time.
What I found was that the "id" field in the configuration seems to be the one that causes the sensitivity. That is, the original view had the id `presidential_recording`. If I change that to, say `new_presidential_recording`, keeping all other fields as in the config file (either one, working or the original, broken config), then the resulting view is fine.
So for whatever reason, there seems to be something about how the view's "id" field is handled that is causing the problem.
Comment #8
longwaveAre you able to upload the two full YAML files of the broken and working views? If not, a unified diff (
diff -u views_working.yaml views_broken.yaml) will be a little easier to read.Comment #9
cilefen commentedThis is interesting.
Comment #10
mefron commentedI just uploaded the config files to this issue. Please let me know if they aren't properly visible.
Comment #11
kachinsky commentedI faced the similar problem, not in a View, but in my custom query.
SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '."mailudn"."field_display_name_valuetotal_nodes_voted_on"."total_nodes_voted_on_' at line 44In my query I have this GROUP BY:
which becomes
GROUP BY "u"."uidu"."nameu"."mailudn"."field_display_name_valuetotal_nodes_voted_on"."total_nodes_voted_on_sumtotal_nodes_voted_on"."avg_total_nodes_voted_on_sumuser"."user_display_name_checkuser_name"."name_checkuser_mail"."mail_check")If I change my query to
everything becomes fine.
Comment #12
lapurddrupal commentedI have the same or similar problem: After installing Autoban I get when calling in Autoban rules list-> Log analyse:
Drupal\Core\Database\DatabaseExceptionWrapper: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'log.messagelog.type' in 'group statement': SELECT "log"."message" AS "message", "log"."type" AS "type", COUNT(*) AS "cnt" FROM "watchdog" "log" WHERE "log"."type" NOT IN (:db_condition_placeholder_0, :db_condition_placeholder_1, :db_condition_placeholder_2, :db_condition_placeholder_3, :db_condition_placeholder_4) GROUP BY "log"."messagelog"."type" HAVING (COUNT(*) >= :threshold) ORDER BY "cnt" DESC; Array ( [:db_condition_placeholder_0] => autoban [:db_condition_placeholder_1] => cron [:db_condition_placeholder_2] => php [:db_condition_placeholder_3] => system [:db_condition_placeholder_4] => user [:threshold] => 5 ) in Drupal\autoban\Form\AutobanAnalyzeForm->getAnalyzeResult() (line 286 of modules/contrib/autoban/src/Form/AutobanAnalyzeForm.php).
Drupal: 9.5.8 PHP: 8.1.16
Comment #13
cilefen commentedPlease let’s keep this on topic as a Views issue.
Comment #14
mefron commentedI think @kachinsky raises an interesting point, even though it's not views-specific. If SQL queries are getting built in a wonky way somewhere else (i.e. those group_by statements), couldn't that be responsible for the problem we're seeing in views?
Comment #16
smustgrave commentedWith D9 EOL should this be closed
Comment #17
smustgrave commentedWanted to bump 1 more time before closing. If no follow up could be closed in 3 months.