All of our views that use the contextual filter: Field: Groups audience (og_group_ref) stopped working -- they return zero results. We made no changes to all these views, and only noticed it about 2 weeks ago, when our entire customer base contacted us to complain. We don't know what happened. Here's the error we get on Views:

SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'IN('3064', '3065', '3066', '3067', '3068', '3069', '3070', '3071', '3072', '3073' at line 2

The error message makes us wonder if the bug began when some change to the database architecture changed (perhaps because of a change from the old host's db server to the new one). We recently moved our hosting over to Platform.sh, but that was in December, and can't be certain if this bug occurred then (about a month ago) or just 2 weeks ago.

Here is the SQL query views is sending:

SELECT node.created AS node_created, node.sticky AS node_sticky, node.nid AS nid
FROM 
{node} node
LEFT JOIN {og_membership} og_membership_node ON node.nid = og_membership_node.etid AND og_membership_node.entity_type = 'node'
WHERE (( (.gid IN('3064', '3065', '3066', '3067', '3068', '3069', '3070', '3071', '3072', '3073', '3188', '9541', '9856', '9866', '9886', '9946', '9996', '10001', '10277') ) )AND(( (node.type IN  ('announcement', 'orientation')) AND (node.status = '1') )))
ORDER BY node_created DESC, node_sticky DESC
LIMIT 11 OFFSET 0

I contacted Platform.sh b/c I did think from that error that maybe they were the change causing the problem, and to see if perhaps they updated their db server recently. This is what they said about it:

I replaced (.gid IN('3064' with (gid IN('3064' and the query works for me.

Please make sure the SQL query sent from your application is not malformed.

However, obviously we don't have a way to change the code sent by Views. We have no idea what to do here or what is the actual cause: Did Views change it's code somehow 2 weeks ago (we did not update Views according to my records and recollection; we are using 7.x-3.14, which is the latest release but from last June)? Did Platform.sh? We are completely stuck and our site's entire membership section is now useless because all our Group-membership filtered views (in other words, pretty much the everything) is now blank.

Comments

somatics created an issue. See original summary.

MustangGB’s picture

Priority: Critical » Normal
renatog’s picture

Category: Bug report » Support request
Status: Active » Fixed

Hello Steven how are you?

Thanks for reporting. I was trying to see this error using my web host on Platform.sh using the last version of views and this error didn't appear for me. As all the points explained, the most probability was related with some change in the db host but it's a guess. When this error appears we were using 7.x-3.14 so my recommendation is to update to the last stable version 7.x-3.24, run update.php and clear all caches. It'll solve the problem on platform.sh. For is working in the same web host. Another possibility is to use the hook_query_alter https://api.drupal.org/api/views/views.api.php/function/hook_views_query... and implement it in a custom way to solve as troubleshooting. But updating the views project first will be better. After that the problem will be solved but if have any problem feel free to let us know ok?! Thank you so much Steven

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.