Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Multilingual select 7.x-1.4 module is not working with Drupal forum (7.12).
PDOException
: SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'status' in where clause is ambiguous: SELECT f.tid AS tid, COUNT(n.nid) AS topic_count, SUM(ncs.comment_count) AS comment_count FROM {node} n INNER JOIN {node_comment_statistics} ncs ON n.nid = ncs.nid INNER JOIN {forum} f ON n.vid = f.vid INNER JOIN {node} node ON f.tid = node.tid WHERE (status = :db_condition_placeholder_0) AND (n.language IN (:db_condition_placeholder_1, :db_condition_placeholder_2)) GROUP BY tid; Array ( [:db_condition_placeholder_0] => 1 [:db_condition_placeholder_1] => en [:db_condition_placeholder_2] => und ) in
forum_forum_load()
(line
779
of
C:\xampp\htdocs\drupal\modules\forum\forum.module
).
Related - http://drupal.org/node/1309142#comment-5592678 from #8 to #13.
Comment | File | Size | Author |
---|---|---|---|
#25 | i18n-clean_select_api-1437932-25.patch | 10.5 KB | Jose Reyero |
#18 | fix-i18n_select-i18n_forum_PDOException-1437932.patch | 2.96 KB | webflo |
Comments
Comment #0.0
kerios83 CreditAttribution: kerios83 commentededit
Comment #1
pwiniacki CreditAttribution: pwiniacki commentedI can confirm this. I also have this problem.
Comment #2
fergusong CreditAttribution: fergusong commentedThis was also reported as an issue against the core forum module at
http://drupal.org/node/1430386
But further research traced it to i18n_select.
In summary:
The ambiguous status error is a bit of a distraction,
the underlying problem is the
INNER JOIN {node} node ON f.tid = node.tid
The node table has no tid column.
And, as far I as can tell, the join doesn't serve any purpose.
My guess is the place to look is
i18n_select_query_node_access_alter(QueryAlterableInterface $query)
in i18n_select.module on l.137
Gordon
Comment #3
fergusong CreditAttribution: fergusong commentedIn i18n_select_check_table($query, $table_name, $field_name)
The logic is adding a join to the query on l.210 and that is related to the
problem. If I comment that line out (not recommended except to
make this point) the PDO exception does not occur. And vis versa.
Comment #4
bak CreditAttribution: bak commentedI think the problem occurs because the code inside i18n_select_check_table($query, $table_name, $field_name):
assumes that the node table has a column/field $field_name but it is not always true: i.e. if we use complex query like in the forum.module:
the fields are from the iner joined table forum, not from the node table. The code inside the i18n_select_check_table($query, $table_name, $field_name) function should be fixed.
Comment #5
SDC CreditAttribution: SDC commentedSubscribing. I get the exact same error on any Forum page when Multilingual Select module is turned on and it disappears when I turn it off.
Comment #6
Zarevac CreditAttribution: Zarevac commentedSame here, after applying the fix in the forum module topic the problem persists.
Comment #7
webflo CreditAttribution: webflo commentedI guess this is a regression introduced by #1392024: Pager not working properly. It counts all pages, not only for selected language..
Comment #8
fergusong CreditAttribution: fergusong commentedI can confirm #7. I backed out that patch and the PDO exception does not occur.
Comment #9
Zarevac CreditAttribution: Zarevac commentedWell, I now get this:
PDOException: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'node.tid' in 'on clause': SELECT f.tid AS tid, COUNT(n.nid) AS topic_count, SUM(ncs.comment_count) AS comment_count FROM {node} n INNER JOIN {node_comment_statistics} ncs ON n.nid = ncs.nid INNER JOIN {forum} f ON n.vid = f.vid INNER JOIN {node} node ON f.tid = node.tid WHERE (n.status = :db_condition_placeholder_0) AND (n.language IN (:db_condition_placeholder_1, :db_condition_placeholder_2)) GROUP BY tid; Array ( [:db_condition_placeholder_0] => 1 [:db_condition_placeholder_1] => en [:db_condition_placeholder_2] => und ) in forum_forum_load() (line 780 of /modules/forum/forum.module).
Comment #10
clemens.tolboom(please use [#issuenum] :)
From issue report #1309142: SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'vid' in field list is ambiguous
From #2 #1430386: forum.module D7.12 PDO Exception probably related to addTag('node_access')
Comment #11
clemens.tolboomStep to reproduce through drush on a git checkout of drupal core
Now visit http://drupal.d7/forum
Modules used:
Comment #12
Zarevac CreditAttribution: Zarevac commentedSorry, my bad. Re-tracting my steps again to see if I missed anything. Have all fixes been applied to the dev version?
Comment #13
webflo CreditAttribution: webflo commentedConfirmed the regression. Commit 07f6d61 is bad.
Comment #14
Zarevac CreditAttribution: Zarevac commentedI concur.
Comment #15
agoradesign CreditAttribution: agoradesign commentedI absolutely agree with webflo. When I remove these lines, I don't get an exception anymore...
Comment #16
Zarevac CreditAttribution: Zarevac commentedSame here, tested it on another site and removing the lines also remove the exception.
Comment #17
clemens.tolboomA little more helpful http://drupalcode.org/project/i18n.git/commitdiff/07f6d618f2a77ca9fcaf26... is bad.
Full code http://drupalcode.org/project/i18n.git/blob/07f6d618f2a77ca9fcaf26ea8b54...
Comment #18
webflo CreditAttribution: webflo commentedComment #19
Jose Reyero CreditAttribution: Jose Reyero commentedLast patch looks like some improvement (specially for the new tests), though I have some concerns about the i18n_select_query_node_access_alter() function, it may need some refactoring.
- The two if statements check for same conditions more than once.
- I suspect i18n_select_check_table() may be joining in the node table sometimes when not needed, if i18n_select_check_query() returns false on the first 'if'
- The function i18n_select_check_table() doesn't look very good to me anymore, maybe we should split it in two and not adding weird conditions.
So my concerns are not about the patch itself, which I guess just fixes the issue, but about how the logic in the query rewritting looks, which is not very good.
So you can commit it as a first step, also so people can download some (dev) version that temporarily fixes the bug, but this definitely needs some more refactoring...
Comment #20
kerios83 CreditAttribution: kerios83 commentedVery nice work guys! Lets polish this a little and fix it once and forever.
Comment #21
clemens.tolboomI'm still puzzled why forum.module was in err. Patching it (by adding table aliasses) made me step a little forward. This looks like a fix for #9 but I'm not sure. Should we file a patch for forum.module?
Comment #22
gwynnebaer CreditAttribution: gwynnebaer commentedPatch worked for me as well as is. Not sure if there are other implications.
Comment #23
mobonobomo CreditAttribution: mobonobomo commentedI got nipped by this too, very confusing. A very easy workaround is to go the the Multilingual Select settings at admin/config/regional/i18n/select and then add the path forum to the excluded pages "Enable for specific pages > All pages except those listed"
Comment #24
kerios83 CreditAttribution: kerios83 commented@mobonobomo this help me a lot, thx.
Comment #25
Jose Reyero CreditAttribution: Jose Reyero commentedThis one builds on webflo's patch (#18) but it is a bigger api rewrite, which also simplifies some parts:
- Properly check queries before adding any table or condition.
- Before joining any table, check all the fields have a proper table alias. Fix if possible, skip the query if not.
- Use schema information to find the table with the field to join new tables.
This should be much cleaner and more robust, maybe skipping some queries that were being rewritten previously (that ones with more than one table and no table alias for all conditions) but also altering some others, the kind of COUNT('nid') queries, since we use schema information to find the right table.
Please give it a try and let me know whether it works. Also more tests may be good.
Comment #26
webflo CreditAttribution: webflo commentedYep this looks much better. Whats this two settings "Select nodes by language" and "Select taxonomy terms by language". We should respect these settings. Right? see #1446200: Content to filter by language is setting never used.
Comment #27
Anonymous (not verified) CreditAttribution: Anonymous commentedThe patch "i18n-clean_select_api-1437932-25.patch" repaired problem identified in http://drupal.org/node/1431452 " 'status' in where clause is ambiguous". Thanks for the hard work! D7.12.
Comment #28
Jose Reyero CreditAttribution: Jose Reyero commentedCool, it seems we've got more than one issue fixed with this :-)
Committed.
@webflo,
Is there anything left about your comment in #26 ?
Comment #29
webflo CreditAttribution: webflo commentedNope. Everything is ok.
Comment #30
Bitbull CreditAttribution: Bitbull commentedUnfortunately, the mentioned patch failed to meet dependancies with me:
Working with latest version of Drupal (7.12) and i18n module (7.x-1.4) as well, and all multilingual modules enabled.
Any idea please?
Comment #31
Jose Reyero CreditAttribution: Jose Reyero commented@Bitbull,
What do you mean? The patch is already *committed*.
Comment #32
Bitbull CreditAttribution: Bitbull commented... which means it's already incorporated in the i18n module? I'm still trying to figure out why the patch fails on my system ...
Comment #33
Anonymous (not verified) CreditAttribution: Anonymous commentedBitBull: You can manually edit the file to include the contents from the patch. It takes a while, but worked for me.
Comment #34
grozozo CreditAttribution: grozozo commentedHi guys!
I had the issue with my multilanguage forum, I applied the patch and they work now :) Great job!
But...
(I'm on Drupal 7.12)
Now mi search form isn't working anymore :(
When I try to search something on site, all I find is:
I tried to pass to dev version of internationalization, and same result!
I googled my error message, and I found his solution: http://drupal.org/node/1062054, but it isn't possible to apply the solution as the internationalization code changed.
Is this related to this issue ? And am I the only one that got it?
Comment #35
whop CreditAttribution: whop commentedHello, same here.
but I have this Recoverable fatal error on pages with views in content. AND only when not logged!
So i can choose, working forum or everything other with views :D
Thanks for your work.
Comment #36
Jose Reyero CreditAttribution: Jose Reyero commentedAll this should be fixed in latest -dev, see #1062054: Recoverable fatal error: Method DatabaseCondition::__toString() must return a string value in i18n_select_check_query()
Comment #37
whop CreditAttribution: whop commentedWohoo fixed for me!
Thanks!!!!!!!
Please Jose, could you look at http://drupal.org/node/1451634
this is my last error with Drupal :D Maybe something with i18n, dont know.
Thanks
edit:
aha maybe i have it! is this patch
http://drupal.org/node/1438394
in this new dev version?
Comment #38
whop CreditAttribution: whop commentedSo I have installed latest i18n dev feb.24, and used #34 nodereference patch.
But working only for some content types.
so i used #2 patch (module) for i18n.
Now working in all of content types, but not for all fields :D
its difficult :D
thanks for help
Comment #40
CleoQc CreditAttribution: CleoQc commentedI downloaded everything new this Saturday, and I was getting the error. I followed what what suggested here and got it to work.
Comment #41
CleoQc CreditAttribution: CleoQc commentedOh, I followed the comment in #23, so I haven't really fixed anything, I just got a workaround that hides the problem
Comment #41.0
CleoQc CreditAttribution: CleoQc commentededit 2