I have only one node type assigned as containing webform: 'webform', as by default. But all the content nodes are shown on the webform management page. The problem is in the following code:
function webform_admin_content() {
$webform_types = webform_variable_get('webform_node_types');
$placeholders = implode(', ', array_fill(0, sizeof($webform_types), '%d'));
$result = db_query(db_rewrite_sql("SELECT n.* FROM {node} n WHERE n.type IN ($placeholders)", $webform_types));
- which generates the following SQL statement: SELECT n.* FROM node n WHERE n.type IN (%d) - which for some weird reason returns all nodes.
I don't really understand what happenes here and have no time to investigate the problem, but the following change solves it:
$webform_types = "'".implode(webform_variable_get('webform_node_types'), "', '")."'";
$result = db_query(db_rewrite_sql("SELECT n.* FROM {node} n WHERE n.type IN ($webform_types)"));
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | webform_admin_content_query.patch | 1 KB | quicksketch |
Comments
Comment #1
quicksketchThanks for the report. I think we just need to change '%d' to '"%s"', since the webform type name is going to be a string, not an integer. I must have not updated the code properly when I borrowed a similar line of code from organic groups.
Comment #2
quicksketchLooks like this was both because of using %d instead of %s and because we weren't passing in the variables correctly into db_query (instead we were passing them into db_rewrite_sql). While I was fixing this I also corrected a notice thrown by node.module because $node->format was not set, which is stored in the node_revisions table.
Comment #3
marrch_caat commentedWonderful, thanks for fast reaction and for wonderful helpful module itself!