diff --git a/libraries/Util.php b/libraries/Util.php
index c175ab06c3..cbbb80e175 100644
--- a/libraries/Util.php
+++ b/libraries/Util.php
@@ -1130,44 +1130,38 @@ class Util
}
if ($render_sql) {
+ $query_too_big = false;
+
+ $queryLength = mb_strlen($sql_query);
+ if ($queryLength > $cfg['MaxCharactersInDisplayedSQL']) {
+ // when the query is large (for example an INSERT of binary
+ // data), the parser chokes; so avoid parsing the query
+ $query_too_big = true;
+ $query_base = mb_substr(
+ $sql_query,
+ 0,
+ $cfg['MaxCharactersInDisplayedSQL']
+ ) . '[...]';
+ } else {
+ $query_base = $sql_query;
+ }
+
// Html format the query to be displayed
// If we want to show some sql code it is easiest to create it here
/* SQL-Parser-Analyzer */
if (! empty($GLOBALS['show_as_php'])) {
- $new_line = '\\n"
' . "\n"
- . ' . "';
- $query_base = htmlspecialchars(addslashes($sql_query));
+ $new_line = '\\n"
' . "\n" . ' . "';
+ $query_base = htmlspecialchars(addslashes($query_base));
$query_base = preg_replace(
'/((\015\012)|(\015)|(\012))/',
$new_line,
$query_base
);
+ $query_base = '$sql = "' . $query_base . '"';
+ } elseif ($query_too_big) {
+ $query_base = htmlspecialchars($query_base);
} else {
- $query_base = $sql_query;
- }
-
- $query_too_big = false;
-
- $queryLength = mb_strlen($query_base);
- if ($queryLength > $cfg['MaxCharactersInDisplayedSQL']) {
- // when the query is large (for example an INSERT of binary
- // data), the parser chokes; so avoid parsing the query
- $query_too_big = true;
- $shortened_query_base = nl2br(
- htmlspecialchars(
- mb_substr(
- $sql_query,
- 0,
- $cfg['MaxCharactersInDisplayedSQL']
- ) . '[...]'
- )
- );
- }
-
- if (! empty($GLOBALS['show_as_php'])) {
- $query_base = '$sql = "' . $query_base;
- } elseif (isset($query_base)) {
$query_base = self::formatSql($query_base);
}
@@ -1302,11 +1296,7 @@ class Util
} //refresh
$retval .= '