diff --git a/ChangeLog b/ChangeLog
index 38e982085..3024d86d4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -20,6 +20,7 @@ $HeadURL: https://phpmyadmin.svn.sourceforge.net/svnroot/phpmyadmin/trunk/phpMyA
- bug #1989281 [export] CSV for MS Excel incorrect escaping of double quotes
- bug #1959855 [interface] Font size option problem when no config file
- bug #1982489 [relation] Relationship view should check for changes
+- bug [history] Do not save too big queries in history
2.11.7.0 (2008-06-23)
- bug #1908719 [interface] New field cannot be auto-increment and primary key
diff --git a/Documentation.html b/Documentation.html
index f569144ea..87417b633 100644
--- a/Documentation.html
+++ b/Documentation.html
@@ -1107,7 +1107,8 @@ ALTER TABLE `pma_column_comments`
The maximum number of characters when a SQL query is displayed. The
default limit of 1000 should be correct to avoid the display of tons
of hexadecimal codes that represent BLOBs, but some users have real
- SQL queries that are longer than 1000 characters.
+ SQL queries that are longer than 1000 characters. Also, if a query's
+ length exceeds this limit, this query is not saved in the history.
$cfg['OBGzip'] string/boolean
Defines whether to use GZip output buffering for increased
diff --git a/libraries/relation.lib.php b/libraries/relation.lib.php
index 7b4be9225..2d4dfb9ff 100644
--- a/libraries/relation.lib.php
+++ b/libraries/relation.lib.php
@@ -711,6 +711,7 @@ function PMA_setComment($db, $table, $col, $comment, $removekey = '', $mode = 'a
*
* @uses $_SESSION['sql_history']
* @uses $cfg['QueryHistoryMax']
+ * @uses $GLOBALS['cfg']['MaxCharactersInDisplayedSQL']
* @uses PMA_getRelationsParam()
* @uses PMA_query_as_cu()
* @uses PMA_backquote()
@@ -726,6 +727,9 @@ function PMA_setComment($db, $table, $col, $comment, $removekey = '', $mode = 'a
*/
function PMA_setHistory($db, $table, $username, $sqlquery)
{
+ if (strlen($sqlquery) > $GLOBALS['cfg']['MaxCharactersInDisplayedSQL']) {
+ return;
+ }
$cfgRelation = PMA_getRelationsParam();
if (! isset($_SESSION['sql_history'])) {
diff --git a/querywindow.php b/querywindow.php
index 4011d3154..17e5d5cf8 100644
--- a/querywindow.php
+++ b/querywindow.php
@@ -27,7 +27,6 @@
* @uses PMA_getRelationsParam()
* @uses PMA_isValid()
* @uses PMA_ifSetOr()
- * @uses PMA_setHistory()
* @uses PMA_getHistory()
* @uses PMA_generate_common_url()
* @uses PMA_generate_common_hidden_inputs()