Logged in as a user with "Contributor" - type access, having already created some content in "Draft" status,
When I try to load the "My Drafts" tab, I get the error:
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 ')) AND (workbench_access_node.access_scheme = 'menu') ))) subquery' at line 5: SELECT COUNT(*) AS expression FROM (SELECT 1 AS expression FROM {node_revision} node_revision LEFT JOIN {users} users_node_revision ON node_revision.uid = users_node_revision.uid INNER JOIN {workbench_moderation_node_history} workbench_moderation_node_history ON node_revision.vid = workbench_moderation_node_history.vid LEFT JOIN {workbench_access_node} workbench_access_node ON node_revision.nid = workbench_access_node.nid LEFT JOIN {node} node ON node_revision.nid = node.nid WHERE ((( (users_node_revision.uid = :db_condition_placeholder_0) )AND (workbench_moderation_node_history.current <> :db_condition_placeholder_1) AND (workbench_access_node.access_id IN ()) AND (workbench_access_node.access_scheme = :db_condition_placeholder_2) ))) subquery; Array ( [:db_condition_placeholder_0] => 33 [:db_condition_placeholder_1] => 0 [:db_condition_placeholder_2] => menu ) in views_plugin_pager->execute_count_query() (line 140 of D:\wamp\www\drupal\sites\all\modules\views\plugins\views_plugin_pager.inc)
seems to be from that empty "In()" statement.
I'm using workbench 7.x.1.0-beta5, with workbench_access and workbench_moderation activated.
any ideas on this? I'm not sure what that check is supposed to be doing.
thanks.
Comments
Comment #1
donundeen commentedAddition:
I tested with a few different users, and it seems this error only pops up where there is some content in draft state for this user.
Comment #2
donundeen commentedAddition: this error also occurs on the "Needs Review" tab.
Comment #3
stevectorIs this coming from the WB Access views filter?
#1095354: PDOException when I attempt to load the workbench page
Comment #4
donundeen commented#3: I don't know, but I can say that I fixed (for myself, anyways), the bug at :
#1095354: PDOException when I attempt to load the workbench page
And this doesn't appear to be related.
Comment #5
donundeen commented#3, you're right, in that the access_id value array, which is empty, is getting passed in, in
workbench_access_handler_filter_access.inc
near the bottom of the file, at:
function query() {
global $user;
$account = $user; // Not a clone, but that's ok, since we need this data on $user.
if (!isset($account->workbench_access)) {
workbench_access_user_load_data($account);
}
if (empty($account->workbench_access)) {
$table = $this->query->ensure_table('node');
$field = $this->query->add_field('node', 'nid');
// $this->query->add_where($this->options['group'], "$table.$field", -1, '=');
$this->query->add_where($this->options['group'], "$table.nid", -1, '='); // donundeen : I modified this lie from teh one above.
return;
}
$active = workbench_access_get_active_tree();
$tree = $active['tree'];
// No selection? Use the user's tree.
if (empty($this->value) || $this->value == -5) {
workbench_access_build_tree($tree, array_keys($account->workbench_access));
}
// Build the selection tree.
else {
workbench_access_build_tree($tree, array_keys($this->value));
}
$ids = array_keys($tree);
$table = $this->query->ensure_table($active['access_scheme']['field_table']);
// Using this field alias breaks the COUNT query. Views bug?
$field = $this->query->add_field($table, $active['access_scheme']['query_field']);
$this->query->add_where($this->options['group'], "$table." . $active['access_scheme']['query_field'], $ids, 'IN'); // this $ids array is empty, so either it shouldn't be empty, or it should be passed in
$field = $this->query->add_field($table, 'access_scheme');
$this->query->add_where($this->options['group'], "$table." . 'access_scheme', $active['access_scheme']['access_scheme']);
}
the $ids array is empty coming out of $ids = array_keys($tree), so I guess the tree is empty as well.
So either there should be a different behaviour when $ids is empty, or there's a problem building $tree.
I'll look into that next...
Comment #6
donundeen commentedok, looking further at this section:
// No selection? Use the user's tree.
if (empty($this->value) || $this->value == -5) {
workbench_access_build_tree($tree, array_keys($account->workbench_access));
}
// Build the selection tree.
else {
workbench_access_build_tree($tree, array_keys($this->value));
}
in this case, $this->value is an array:
Array
(
[0] => -5
)
so the check for $this->value == -5 fails, though it seems like that's what you're looking for.
does this make sense? What is the code trying to do here?
Comment #7
donundeen commentedok, so I've made the following fix, though it may not be correct:
around line 90, in
workbench_access_handler_filter_access.inc:
// No selection? Use the user's tree.
// if (empty($this->value) || $this->value == -5 ) { // donundeen: I changed this to:
if (empty($this->value) || $this->value == -5 || in_array(-5, $this->value)) {
I don't know enough about $this->value to know if this is the right way to do it.
any thoughts?
Comment #8
donundeen commentedok, here's another error, that pops up when the $this->value array is :
Array
(
[0] => Array
(
[main-menu] => main-menu
)
)
Similar thing; when
array_keys($this->value)
is called, you get array(0), instead of array("main-menu") which is probably what you want.
So my guess is, something changed in how $this->value gets put together (I'm guessing that happens in views_handler_filter ), and workbench_access hasn't caught up the to change yet?
does this seem like a correct analysis?
Don
Comment #9
donundeen commentedI made a modification like this:
if (empty($this->value) || $this->value == -5 || in_array(-5, $this->value)) {
workbench_access_build_tree($tree, array_keys($account->workbench_access));
}
// Build the selection tree.
else {
// workbench_access_build_tree($tree, array_keys($this->value));
workbench_access_build_tree($tree, array_keys($this->value[0])); // modification from above line
}
That sure seems hackish, but it gets the page loading.
Comment #10
dave reidSounds like this is a duplicate of #1095354: PDOException when I attempt to load the workbench page