Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: mantisbt/mantisbt
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 758c840
Choose a base ref
...
head repository: mantisbt/mantisbt
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 4c3ffce
Choose a head ref
  • 3 commits
  • 2 files changed
  • 1 contributor

Commits on Mar 27, 2012

  1. Fix utf8 offset when logging SQL in db_query_bound

    The fix for #13280 (5835572) only fixed
    one part of the problem, i.e. when the UTF8 characters were in the SQL
    query itself. This commit fixes the remaining case when the string
    parameters contain multibyte chars.
    
    Fixes #14097
    dregad committed Mar 27, 2012
    Copy the full SHA
    50f45ad View commit details
  2. Copy the full SHA
    ba21cce View commit details
  3. Copy the full SHA
    4c3ffce View commit details
Showing with 13 additions and 24 deletions.
  1. +13 −13 core/database_api.php
  2. +0 −11 docbook/Admin_Guide/en-US/Configuration.xml
26 changes: 13 additions & 13 deletions core/database_api.php
Original file line number Diff line number Diff line change
@@ -328,39 +328,39 @@ function db_query_bound( $p_query, $arr_parms = null, $p_limit = -1, $p_offset =

if( ON == $g_db_log_queries ) {
$lastoffset = 0;
$i = 1;
$i = 0;
if( !( is_null( $arr_parms ) || empty( $arr_parms ) ) ) {
while( preg_match( '/\?/', $p_query, $matches, PREG_OFFSET_CAPTURE, $lastoffset ) ) {
$matches = $matches[0];
# Realign the offset returned by preg_match as it is byte-based,
# which causes issues with UTF-8 characters in the query string
# (e.g. from custom fields names)
$matches[1] = utf8_strlen( substr( $p_query, 0, $matches[1]), mb_internal_encoding() );
$t_utf8_offset = utf8_strlen( substr( $p_query, 0, $matches[1]), mb_internal_encoding() );
if( $i <= count( $arr_parms ) ) {
if( is_null( $arr_parms[$i - 1] ) ) {
if( is_null( $arr_parms[$i] ) ) {
$replace = 'NULL';
}
else if( is_string( $arr_parms[$i - 1] ) ) {
$replace = "'" . $arr_parms[$i - 1] . "'";
else if( is_string( $arr_parms[$i] ) ) {
$replace = "'" . $arr_parms[$i] . "'";
}
else if( is_integer( $arr_parms[$i - 1] ) || is_float( $arr_parms[$i - 1] ) ) {
$replace = (float) $arr_parms[$i - 1];
else if( is_integer( $arr_parms[$i] ) || is_float( $arr_parms[$i] ) ) {
$replace = (float) $arr_parms[$i];
}
else if( is_bool( $arr_parms[$i - 1] ) ) {
else if( is_bool( $arr_parms[$i] ) ) {
switch( $t_db_type ) {
case 'pgsql':
$replace = "'" . $arr_parms[$i - 1] . "'";
$replace = "'" . $arr_parms[$i] . "'";
break;
default:
$replace = $arr_parms[$i - 1];
$replace = $arr_parms[$i];
break;
}
} else {
echo( "Invalid argument type passed to query_bound(): $i" );
echo( "Invalid argument type passed to query_bound(): " . $i + 1 );
exit( 1 );
}
$p_query = utf8_substr( $p_query, 0, $matches[1] ) . $replace . utf8_substr( $p_query, $matches[1] + utf8_strlen( $matches[0] ) );
$lastoffset = $matches[1] + utf8_strlen( $replace );
$p_query = utf8_substr( $p_query, 0, $t_utf8_offset ) . $replace . utf8_substr( $p_query, $t_utf8_offset + utf8_strlen( $matches[0] ) );
$lastoffset = $matches[1] + strlen( $replace ) + 1;
} else {
$lastoffset = $matches[1] + 1;
}
11 changes: 0 additions & 11 deletions docbook/Admin_Guide/en-US/Configuration.xml
Original file line number Diff line number Diff line change
@@ -2379,17 +2379,6 @@
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>$g_show_queries_list</term>
<listitem>
<para>Shows the list of all queries that are executed in
chronological order from top to bottom. This option is only
effective when $g_show_queries_count is ON. Default is OFF.
WARNING: Potential security hazard. Only turn this on when you
really need it (for debugging or profiling)
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>$g_register_globals</term>
<listitem>