MantisBT: master 36a34464

Author Committer Branch Timestamp Parent
dregad dregad master 2011-09-08 20:17 master 94e68102
Affected Issues  0013280: Sort by accented custom field produces incorrect log entries
Changeset

Fix 0013280: Incorrect queries logged when sorting by custom field having accented chars

The offsets returned by preg_match are byte-based, which causes issues with
UTF-8 characters as the subsequent calls to utf8_substr operate on the wrong
part of the string; this results in logging of invalid SQL queries when
$g_show_queries_list = ON.

This commit fixes the problem by realigning the offsets prior to performing the
query parameter substitution.

It also simplifies the code by removing parenthesis in the regexp pattern,
which is not necessary since we are only matching a single element, this way
there is no need to deal with a multi-dimentional array.

mod - core/database_api.php Diff File