Commit c3c8d7f1 authored by Dries's avatar Dries
Browse files

- Patch #106370 by naquah and chx: fixed query rewriting in presence of OR-clause.

parent a7d58587
......@@ -269,30 +269,30 @@ function db_rewrite_sql($query, $primary_table = 'n', $primary_field = 'nid', $
if (!empty($where) || !empty($join)) {
if (!empty($where)) {
$new = " WHERE $where ";
$new = "WHERE $where ";
}
$new = " $join $new";
if (strpos($query, 'WHERE')) {
$replace = 'WHERE';
$add = 'AND';
$query = str_replace('WHERE', $new .'AND (', $query);
$insert = ') ';
}
elseif (strpos($query, 'GROUP')) {
else {
$insert = $new;
}
if (strpos($query, 'GROUP')) {
$replace = 'GROUP';
$add = 'GROUP';
}
elseif (strpos($query, 'ORDER')) {
$replace = 'ORDER';
$add = 'ORDER';
}
elseif (strpos($query, 'LIMIT')) {
$replace = 'LIMIT';
$add = 'LIMIT';
}
else {
$query .= $new;
$query .= $insert;
}
if (isset($replace)) {
$query = str_replace($replace, "$new $add ", $query);
$query = str_replace($replace, $insert . $replace, $query);
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment