Dear maintainer:

I get this error, when I try to see the forum (http://wiki9999.org/en/forum):
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 /usr/www/users/wikibi/drupal7-wiki9999/modules/forum/forum.module).

You can see the error here => http://wiki9999.org/en/forum (user: wiki9999; login: home9999) (Not yet productive)

That error happens independently if the "multilingual forum" module is activated or not activated.

The tables "forum" and "forum_index" are empty.

Please do not hesitate, if you need further information.

Best regards,
Schnittmenge

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

fergusong’s picture

For what it's worth, this seems similar to
http://drupal.org/node/1430386

larowlan’s picture

Version: 7.12 » 8.x-dev
Issue tags: +Needs backport to D7
larowlan’s picture

Status: Active » Needs review
FileSize
514 bytes
Schnittmenge’s picture

Version: 8.x-dev » 7.12

Thank you for the patch.
Now, I get other errors =>http://local.wiki9999.org:8888/de/forum =>
Warning: Invalid argument supplied for foreach() in forum_menu_local_tasks_alter() (Zeile 175 von ..../modules/forum/forum.module).

http://local.wiki9999.org:8888/de/forum#overlay=de/admin/structure/forum =>
Notice: Trying to get property of non-object in taxonomy_term_save() (Zeile 595 von /Users/daniel/svns-macbook/Drupal-7-wiki9999/modules/taxonomy/taxonomy.module).
EntityMalformedException: Fehlende Paketeigenschaft auf einem Element des Types taxonomy_term. in entity_extract_ids() (Zeile 7501 von /Users/daniel/svns-macbook/Drupal-7-wiki9999/includes/common.inc).

What should I do? (Drupal 7.12)

larowlan’s picture

Version: 7.12 » 8.x-dev

Bugs get fixed in 8 first then backported.
If the patch works for you, please mark the ticket as 'reviewed and tested by the community'.
Then after committed, we'll get the D7 backport.
Regarding invalid argument supplied for foreach() in forum_menu_local_tasks_alter() - there is an existing ticket for that - see #1157142: Watchdog: Undefined index: node in forum_menu_local_tasks_alter() (line 175 of ../forum/forum.module.

Zarevac’s picture

After applying patch #3 I 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).

Zarevac’s picture

#3: 1431452-ambiguos-status.patch queued for re-testing.

superthin’s picture

Drupal 7.12 when visiting my site http://mysite.com/forum

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] => vi [:db_condition_placeholder_2] => und ) trong advanced_forum_forum_load() (dòng 142 của /var/www/clients/client1/web29/web/sites/all/modules/advanced_forum/includes/core-overrides.inc).

superthin’s picture

Drupal 7.12 when visiting my site http://mysite.com/forum

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] => vi [:db_condition_placeholder_2] => und ) trong advanced_forum_forum_load() (dòng 142 của /var/www/clients/client1/web29/web/sites/all/modules/advanced_forum/includes/core-overrides.inc).

Schnittmenge’s picture

Status: Needs review » Reviewed & tested by the community

I tested drupal 8 with that patch and I had no errors.

Dries’s picture

Status: Reviewed & tested by the community » Fixed

Committed to 7.x and 8.x.

kerios83’s picture

webflo’s picture

Version: 8.x-dev » 7.x-dev
Status: Fixed » Reviewed & tested by the community
FileSize
494 bytes

Its not committed to 7.x. I rolled a patch for d7.

webflo’s picture

Status: Reviewed & tested by the community » Needs review

Go testbot!

webflo’s picture

Go testbot!

Tor Arne Thune’s picture

The patch name must not end in -D# if you want testbot to queue it :)

webflo’s picture

FileSize
494 bytes

Thanks :)

webflo’s picture

Status: Needs review » Reviewed & tested by the community

woho.

Yannick Menard’s picture

Getting this too after applying patch #3 :

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).

Anonymous’s picture

Version: 7.x-dev » 7.12
Status: Reviewed & tested by the community » Needs review

Applied 1431452-ambiguos-status.patch in D-7.12 release. Multilingual site, still getting same error msg:

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 advanced_forum_forum_load() (line 142 of /home1/reallig1/public_html/sites/all/modules/advanced_forum/includes/core-overrides.inc).

Anonymous’s picture

Just a note to let you know the patch i18n-clean_select_api-1437932-25.patch repaired the problem: http://drupal.org/node/1437932 . It is a lengthy, complex, and somewhat confusing patch to apply, but it does seem to work. I can now access my forums.

larowlan’s picture

Status: Needs review » Reviewed & tested by the community

Putting it back how it was

xjm’s picture

Version: 7.12 » 7.x-dev
webchick’s picture

Title: 'status' in where clause is ambiguous » Tests for 'status' in where clause is ambiguous
Version: 7.x-dev » 8.x-dev
Category: bug » task
Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs tests

Hm. I committed and pushed this to 7.x to get us parity with 8.x, however...

Why was this error not caught by our existing forum tests? We need the tests expanded so they would catch this in the future, because we /did/ run the full test suite against that security patch before it went in.

Jose Reyero’s picture

These issues only show up when a contrib module uses the query_alter() hook and joins in some more table.

I think the proper fix for this would be improving the query builder so it adds a table alias to every field in the query, this would me much more friendly with modules implementing query alter hooks.

The Internationalization related issue has been fixed, btw, #1437932: Multilingual select 7.x-1.4 module cause PDOException on drupal forum
Before joining in any other table, we are now adding table alias for fields without one when possible, that is if there's a single table.

xjm’s picture

Ah, thank you @Jose Reyero! I was at a loss for how to reproduce this. So actually this is not a core bug at all; it is a bug with the module adding the query alter, and this should be reverted in core, perhaps in favor of a more complete solution for table aliasing generally.

Can you provide an example of a module that causes the issue?

webchick’s picture

Status: Needs work » Fixed

I don't think the extra specificity in the core query really harms anything. But it indeed sounds like as far as core's concerned, there's nothing more to do here. We don't need tests to show how well we babysit broken code.

Bitbull’s picture

Status: Fixed » Needs work

Unfortunately, the mentioned patch failed to meet dependancies with me:

error: while searching for:
dependencies[] = i18n_node
package = Multilingual - Internationalization
core = 7.x


error: patch failed: i18n_forum/i18n_forum.info:5
error: i18n_forum/i18n_forum.info: patch does not apply
Checking patch i18n_forum/i18n_forum.test...
Checking patch i18n_select/i18n_select.module...

Working with latest version of Drupal (7.12) and i18n module (7.x-1.4) as well, and all multilingual modules enabled.
So, is it acceptable to change status to 'needs work' (as patch mentioned in topic didn't work either - see comment #6)?

xjm’s picture

Status: Needs work » Fixed

@Bitbull -- The patch was committed to Drupal core, not i18n. If there's an issue with i18n, you should file it in that module's queue. Thanks!

Bitbull’s picture

Version: 8.x-dev » 7.12
Status: Fixed » Needs work

@xjm -- I was actually replying to comment #21, stating that http://drupal.org/files/i18n-clean_select_api-1437932-25.patch repaired the problem. And as the versions match with mine (latest at this very moment) and the patch stated in #21 fails to apply on my installation (see output on comment # 26), and that the patch submitted in this topic (#17) throws the problem mentioned in #20, I unfortunately have still no solution to the problem ...

xjm’s picture

Version: 7.12 » 8.x-dev
Status: Needs work » Fixed

Please follow up in the i18n issue, which is where that patch is from. #1437932: Multilingual select 7.x-1.4 module cause PDOException on drupal forum.

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