Hi guys,
when viewing a node as an authenticated user with permissions granted by the Node View Permissions, I get the following error (when viewing the node as user 1, no problems):
PDOException: 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 'WHERE (c.nid = '283') AND (c.status = '1')' at line 2: SELECT COUNT(*) AS expression FROM {comment} c INNER JOIN {node} n ON n.nid = .nid WHERE (c.nid = :db_condition_placeholder_0) AND (c.status = :db_condition_placeholder_1) ; Array ( [:db_condition_placeholder_0] => 283 [:db_condition_placeholder_1] => 1 ) i PagerDefault->execute() (linje 74 af /<mypath>/includes/pager.inc).
The error goes away when disabling the Node View Permissions module.
The error has started appearing after upgrading PHP to v. 5.6.11 on a FreeBSD server.
The error is not present on a dev site running PHP v. 5.5.9 which makes me think it is related.
MySQL is v. 5.5.44
The site has SSL enabled (rewrites alias domains in .htaccess).
Here's a list of the enabled modules (Drupal v. 7.39):
Package Name Version
Access control Node view permissions (node_view_permissions) 7.x-1.5
Administration Administration menu (admin_menu) 7.x-3.0-rc5
Administration Administration menu Toolbar style 7.x-3.0-rc5
(admin_menu_toolbar)
Administration Module filter (module_filter) 7.x-2.0
Chaos tool suite Chaos tools (ctools) 7.x-1.9
Chaos tool suite Page manager (page_manager) 7.x-1.9
Core Block (block) 7.39
Core Color (color) 7.39
Core Comment (comment) 7.39
Core Content translation (translation) 7.39
Core Contextual links (contextual) 7.39
Core Dashboard (dashboard) 7.39
Core Database logging (dblog) 7.39
Core Field (field) 7.39
Core Field SQL storage (field_sql_storage) 7.39
Core Field UI (field_ui) 7.39
Core File (file) 7.39
Core Filter (filter) 7.39
Core Help (help) 7.39
Core Image (image) 7.39
Core List (list) 7.39
Core Locale (locale) 7.39
Core Menu (menu) 7.39
Core Node (node) 7.39
Core Number (number) 7.39
Core Options (options) 7.39
Core Overlay (overlay) 7.39
Core Path (path) 7.39
Core PHP filter (php) 7.39
Core RDF (rdf) 7.39
Core Search (search) 7.39
Core Shortcut (shortcut) 7.39
Core System (system) 7.39
Core Taxonomy (taxonomy) 7.39
Core Text (text) 7.39
Core Update manager (update) 7.39
Core User (user) 7.39
Fields Entity Reference (entityreference) 7.x-1.1
Fields Field Permissions (field_permissions) 7.x-1.0-beta2
Fields Link (link) 7.x-1.3
Helper modules cfdp_uf (cfdp_uf) 7.x-1.0
Other Backup and Migrate (backup_migrate) 7.x-2.8
Other Disable breadcrumbs (disable_breadcrumbs) 7.x-1.3
Other Email Registration (email_registration) 7.x-1.2
Other Entity API (entity) 7.x-1.6
Other Entity tokens (entity_token) 7.x-1.6
Other Masquerade (masquerade) 7.x-1.0-rc7
Other Prepopulate (prepopulate) 7.x-2.0
Other Profile2 (profile2) 7.x-1.3
Other Profile2 pages (profile2_page) 7.x-1.3
Other Profile2 Registration Path (profile2_regpath) 7.x-2.0-beta3
Panels Panels (panels) 7.x-3.5
Rules Rules (rules) 7.x-2.9
Rules Rules Link (rules_link) 7.x-1.1
Rules Rules Scheduler (rules_scheduler) 7.x-2.9
Rules Rules UI (rules_admin) 7.x-2.9
User interface Wysiwyg (wysiwyg) 7.x-2.2
Views Views (views) 7.x-3.11
Views Views Accordion (views_accordion) 7.x-1.1
Views Views Field View (views_field_view) 7.x-1.1
Views Views UI (views_ui) 7.x-3.11I am not at all sure that Node View Permissions is the culprit - but hoping you can lead me on the track.
| Comment | File | Size | Author |
|---|---|---|---|
| #22 | node_view_permissions-D7-2564273-22.patch | 672 bytes | oleksiy |
| #20 | node_view_permissions-D7-2564273-19.patch | 860 bytes | hgoto |
| #5 | node_view_permissions-2564273-D7.patch | 1.14 KB | mortenh |
Comments
Comment #2
sergei_semipiadniy commentedHi Benjamin,
Trouble happens at line 127 in node_view_permissions module "$query->join('node', 'n', 'n.nid = ' . key($tables) . '.nid');".
Comment #3
redsky commentedI am not sure if the cause is the identical but I I have the same error and I see the same problem in the generated SQL - a missing alias here:
INNER JOIN {node} n ON n.nid = .nidI haven't had any version changes in PHP or MySQL like the ones noted by benjamin_dk. I am also using the Node View Permissions module. I have a another content type that is configured similarly that does not produce this error. I'll report back if I learn more.
Comment #4
redsky commentedSorry about that, this turned out to be a problem with the nodeaccess module. When I turned off Node View Permissions the problem persisted however when I turned off Nodeaccess everything worked. And it still worked when I turned back on the Node View Permissions module.
Comment #5
mortenh commentedHi
We just had the same problem after a php 5.6 upgrade.
The attached patch solved the problem. Can't really explain why and it might be completely wrong :)
No php 5.6 migration docs mentions anything about the internal array pointer being moved differently.
Comment #6
nerdoc commentedI have the same error, but have no nodeaccess module installed, so that can't be the problem here. But node_view_permissions is installed and enabled here.
The problem started at Sept 1 2015 10:41 - but there were no module updates directly before that timestamp.
And I can confirm that patch #5 fixes the problem here.
Comment #7
Lonnytunes commentedComment #8
benjamin_dk commentedThanks for your help everybody - mhbellcom, your patch #5 works for me too!
Sorry for not replying sooner - my notifications were turned off :-/
Comment #9
ikeigenwijs commentedI can confirm that patch #5 fixes the problem here.
Thats 3 positive reviews --> changed status
Comment #10
delaBruyne commentedI can confirm that patch #5 fixes my problem too!
Thank you :)
Comment #11
stewestThanks! I can confirm that patch #5 fixes my problem too!
Comment #12
a.milkovsky+1 for #5. Fixed for me.
Thank you.
Comment #13
xavier.g commentedThe patch (#5) solved my issue too. Thanks !
Comment #14
hgoto commentedThe patch #5 works well also for me.
As mmhbellcom told, PHP 5.6 doesn't change the pointer behaviour and this should be a bug even with PHP 5.4 or 5.5. I tested and confirmed that there's no error with PHP 5.4 nor 5.5 but I don't understand why the current code works in PHP 5.5...
The patch #5 works well but we don't need to change some parts of code. Here is a simpler one. (The file's line break code is not correct but I avoided to change it here.)
Comment #15
qazema commentedPatch #5 and #14 works both.
Comment #16
drusite commentedAn authenticated user can't see any comments on the Node View Permissions Content. What's the problem?
Comment #17
Marko B commentedHad the same problem since PHP upgrade. Solved with this patch.
Comment #18
drusite commentedIt seems that these patches work only for some cases. In my case they didn't work.
Comment #19
hgoto commented@drusite, thank you for your feedback. If possible, could you share me the steps to reproduce the situation they don't work?
Comment #20
hgoto commentedMy recognition for the cause was wrong. The array pointer is not changed by the `foreach` loop just before the error. So I changed the comment slightly. Only difference between this patch and the #14 is the comment.
Comment #21
hgoto commentedComment #22
oleksiyCan't apply #14 and #20 patches. Got the following error:
Have simplified and recreated it.
Comment #23
hgoto commentedOleksiy, thank you for revising it.
Comment #24
jwineichen commented#22 worked for me
Comment #25
bdlangton commented#22 works for me.
Comment #26
bmango commented#22 worked for me. Many thanks.
Comment #27
peter caritas commentedThis patch works for me. The error only surfaced when I installed the site on a server running PHP 5.6.16 and mysql 5.6.31. Previously the error did not appear on a server running PHP 5.3.x and Mysql 5.5.50-cll.
However, the patch did not apply cleanly to 7.x-1.x-dev. I didn't try applying it to 7.x.15. But I think typically patches are made against dev so they can be committed?
Comment #28
ollie222 commentedI've just come across this error using the forum and advanced forum modules on a PHP 5.6 server.
The patch in #22 applied to 7.x-1.5 has solved the issue for me so thanks for the patch and I'd like to see the patch committed.
Comment #29
citizenkepler commentedI have had the same issue with the PDO error on php 5.6 with the advanced forum module. I have applied #20's patch and this has resolved the issue for me as well.
Comment #30
signaltrace commentedJust chiming in - I ran into this same issue after upgrading to PHP 5.6. Patch #22 fixed it for me as well. Thanks!
Comment #31
Philou88 commentedI got the problem after upgrading to PHP 5.6 in ".../includes/pager.inc (line 74)" and in ".../modules/forum/forum.module (line 716)".
Patch #22 fixed the 2 issues as well. Many Thanks!
Comment #32
p4trizio commented#22 works for me too
Comment #33
fietserwin+1 on #22. Please commit (and release a new version) or change the module maintenance status to "unsupported" or ""seeking new maintainer" to express that you don't maintain this module anymore.
Comment #34
krilo_89 commentedWorks for me, but saw a small spelling error: because.
Comment #35
helmo commentedThanks, #5 works as expected.
Comment #36
aytee commentedPatch #5 worked for me. Thanks!
Comment #37
jdhildeb commentedPatch #22 worked for me. I'd like to echo what @fietserwin said - please commit (and release a new version) or change the module maintenance status to "unsupported" or ""seeking new maintainer" to express that you don't maintain this module anymore.
Comment #38
nikolabintev commentedPatch #22 works for me. key() returns NULL, because at the end of loop, internal pointer is on the end, and that's how it works. The query is the default pager query for comments.
Comment #39
hongpong commented#22 worked for me. This needs to be committed! Was definitely triggered by updating to PHP5.6.
Comment #40
Anonymous (not verified) commented#22 patch worked for me, please commit.
Comment #41
blainelang commentedYes, please commit this as it prevented access for user access on a clients site's forum and it was not easy to track the SQL error down to this issue.
Comment #44
adci_contributor commentedHi, guys!
Sorry, we did not answer for a long time. Thank you for your feedback.
We added a patch and released a new version.
Please check and test it.
Comment #45
adci_contributor commented