step to reproduce for me:
- enable "view", "workflow" and "workflow_access" module.
- create state of "Draft".
- create a user role of "editor".
- set "author" and "editor" can view at "Draft" state.
- login as "editor" and create a node at state of "Draft".
- with using "view" to display, there are two nodes appear.
my finding:
- go in deep, at function of db_distinct_field() in database.mysql.inc,
if $query="SELECT node.nid AS nid FROM {node} ...", no DISTINCT keyword has been inserted.
this function return "SELECT node.nid AS nid FROM {node} ..." unchanged.
my behavior expected:
- I expect the function return "SELECT DISTINCT(node.nid) AS nid FROM {node} ...".
my suggestion to change:
- at line 367 to 370, I suggest change from:
$select = preg_replace(
'/((?:^|,)\s*)(?<!DISTINCT\()(?:'. $table .'\.)?'. $field .'(\s*(?:,|$))/is',
'\1'. $field_to_select .'\2', $matches[1], 1
);
to
$select = preg_replace(
'/((?:^|,)\s*)(?<!DISTINCT\()(?:'. $table .'\.)?'. $field .'(\s*(?:,|$|AS))/is',
'\1'. $field_to_select .'\2', $matches[1], 1
);
Comments
Comment #1
hiwilson commentedSorry, I find my previous suggestion will be false triggered by case of "node.nidas". To adjust, I have the following suggestion.
to