Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions wp-includes/translations.php
Original file line number Diff line number Diff line change
Expand Up @@ -1142,13 +1142,18 @@ function translate_findinset($query)
&& (stripos($query,'UPDATE') !== 0 && stripos($query,'UPDATE') !== FALSE) ) {
return $query;
}
$pattern = "/FIND_IN_SET\((.*),(.*)\)/";
$pattern = "/FIND_IN_SET\\s*\((.*),(.*)\)/";
$matched = preg_match($pattern, $query, $matches);
if ( $matched == 0 ) {
return $query;
}

// Replace the FIND_IN_SET
$query = preg_replace($pattern, "PATINDEX(','+" . $matches[1] . "+',', ','+" . $matches[2] . "+',')", $query);

// Note: the double percents here are because the result is going to go back via vsprintf,
// and we need it to not look like a replacement token there. Assumption: !empty($this->preg_data)
// holds true, which it should because FIND_IN_SET should originally have taken a string pattern.
$query = preg_replace($pattern, "PATINDEX('%%,'+" . $matches[1] . "+',%%', ','+" . $matches[2] . "+',')", $query);

return $query;
}
Expand Down