diff --git a/wp-includes/translations.php b/wp-includes/translations.php index b0e3c1e21..4626164f1 100644 --- a/wp-includes/translations.php +++ b/wp-includes/translations.php @@ -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; }