Problem/Motivation
The following SQL error happens if a view contains "Has new content" filter and there are no any content types with comment field.
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 '> (1445975102 - 2592000))) OR history.timestamp < node_field_data.changed OR his' at line 2: SELECT node_field_data.nid AS nid FROM {node_field_data} node_field_data LEFT JOIN {history} history ON node_field_data.nid = history.nid AND history.uid = :views_join_condition_0 WHERE (( ((history.timestamp IS NULL AND (node_field_data.changed > (1445975102 - 2592000) OR .last_comment_timestamp > (1445975102 - 2592000))) OR history.timestamp < node_field_data.changed OR history.timestamp < .last_comment_timestamp) )); Array ( [:views_join_condition_0] => 1 )
Proposed resolution
- This errors happens if we have no comment type yet, which causes the relationship between the
comment_entity_statisticstable and the entity type to not be created yet by CommentViewsData. - Check whether the join to the table can be resolved before adding the filter condition
Remaining tasks
User interface changes
API changes
Data model changes
Why should this be committed before the RC
Pro
This fixes a fatal error, which always gives a bad sign for users about the state of Drupal itself.
Contra
This is just a normal bug which can be easily committed once 8.0.0 is out.
| Comment | File | Size | Author |
|---|---|---|---|
| #38 | 2591147-37.patch | 1.7 KB | chi |
| #35 | 2591147-35-test_only.patch | 922 bytes | chi |
| #26 | 2591147-26.patch | 1.69 KB | chi |
| #13 | test-2591147.yml | 3.99 KB | chi |
| #10 | Без-имени-1.jpg | 171.22 KB | fomenkoandrey |
Comments
Comment #2
cilefen commentedComment #3
fomenkoandrey commentedi hope, fixed first post. Thank U
Comment #4
cilefen commentedDo you mean the filter named "Content: Has new content"?
Comment #5
fomenkoandrey commentedWhen I select the Filter criteria option in the list:
i see in russian:
the translation would be something:
because I chose updated content, this option is more likely to:
I do not know how to look the exact value in English.
Comment #6
cilefen commentedThank you for translating. I tried that filter on a view of nodes and did not see the error you reported.
Can you post the database version you are running and any other possibly relevant details in the issue summary? And was this on the current Drupal 8.0.x HEAD from git?
Perhaps someone else can reproduce the issue.
Comment #7
fomenkoandrey commentedI installed the latest version of Drupal two days ago, i think from there https://www.drupal.org/project/drupal
of the extensions - only taxonomy menu, but it is not used.
from the report of Drupal :
Drupal 8.0.0-dev
Drupal core 8.0.0-rc1+6-dev (2015-Окт-09)
PHP 5.5.30
Web server Apache
database version 10.1.2-MariaDB-wsrep-log
database MySQL, MariaDB, Percona Server
System Linux skm71.hostsila.org 2.6.32-531.29.2.lve1.3.11.1.el6.x86_64 #1 SMP Thu Dec 18 06:49:17 EST 2014 x86_64
Build Date Oct 2 2015 14:49:36
Server API CGI/FastCGI
Comment #8
cilefen commentedI moved this to the views_ui module, which is the Views management module.
Comment #9
dawehnerviews_ui is wrong, this is certainly views which causes the problem.
@fomenkoandrey Do you mind providing an export of the view
Comment #10
fomenkoandrey commentedI'm sorry, I did not understand the question.
view created in Drupal 8, do not be exported or imported.
I attach the screenshot.
Comment #11
fomenkoandrey commentedadded
lines 1374-1409
Comment #12
fomenkoandrey commentedthe same error in RC2
Comment #13
chi commentedA simplified view to reproduce the bug.
Comment #14
chi commentedThe error disappeared after attaching comment field to Article content type.
Comment #15
chi commentedComment #16
chi commentedshould fail
Comment #18
chi commentedcombined 15 and 16
Comment #19
chi commentedComment #20
chi commentedComment #21
chi commentedComment #22
dawehnerIt would be great if someone could describe in the issue summary or better via a comment in the code why this ensureTable call could fail ...
Needs work as we need tests.
Comment #23
chi commentedadded a note
Comment #24
dawehnerInteresting, so we already have sort of a test coverage, great!
Comment #25
cilefen commentedThis should read "...has an attached comment field." or "... has attached comment fields.", whichever is more correct. Then, it can go right back to RTBC.
Comment #26
chi commentedBack to RTBC per #25.
Comment #27
chi commentedComment #30
fomenkoandrey commentedthe same error in RC3:
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 '> (1446791122 - 2592000))) OR history.timestamp < node_field_data.changed OR his' at line 2: SELECT COUNT(*) AS expression FROM (SELECT 1 AS expression FROM {node_field_data} node_field_data LEFT JOIN {history} history ON node_field_data.nid = history.nid AND history.uid = :views_join_condition_0 WHERE (( (node_field_data.status = :db_condition_placeholder_0) AND (node_field_data.type IN (:db_condition_placeholder_1)) AND ((history.timestamp IS NULL AND (node_field_data.changed > (1446791122 - 2592000) OR .last_comment_timestamp > (1446791122 - 2592000))) OR history.timestamp < node_field_data.changed OR history.timestamp < .last_comment_timestamp) ))) subquery; Array ( [:db_condition_placeholder_0] => 0 [:db_condition_placeholder_1] => article [:views_join_condition_0] => 1 )Comment #31
chi commented@fomenkoandrey, the patch is not commited yet.
Comment #32
dawehnerIts still green
@Chi
Do you think this has to be committed before 8.0.0? For me this is a normal bugfix, but let's see whether we can convince the core committers
Comment #33
chi commented@dawehner, I was unaware that usual bugfixes are not allowed in release candidates. I do not understand the reason behind this but that won't be a big problem since D8 release is coming soon.
Comment #34
xjmSo this is what provides the test coverage, but I have no indication as to why it's necessary for the comment module to be added in this test.
Can we either add an explicit test or at least a comment as to how it provides coverage? I'd prefer the former probably to decouple the coverage.
@effulgentsia and I agreed with both the points in the summary in terms of RC. This is indeed a bug that can be fixed in a patch release. Since it causes a fatal, though, that seems like an OK reason to make the change during RC since there is no disruption.
Comment #35
chi commentedShould fail.
Comment #36
chi commentedIt looks for me that moduleExists('comment') is not needed here since we are checking comment_entity_statistics table.
Comment #38
chi commentedComment #39
dawehnerWell,
Comment #41
catchCommitted/pushed to 8.0.x, thanks!
Comment #43
alexpott