- Patch #106370 by naquah and chx: fixed query rewriting in presence of OR-clause.
parent
a7d58587cb
commit
c3c8d7f13d
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue