diff --git a/js/ajax.js b/js/ajax.js index c11f9b7ee1b3..41043f559e9c 100644 --- a/js/ajax.js +++ b/js/ajax.js @@ -291,6 +291,7 @@ var AJAX = { "
" + data.message + "
" ); PMA_highlightSQL($('#page_content')); + checkNumberOfFields(); } if (data._selflink) { diff --git a/js/common.js b/js/common.js index 468036d4c64f..22891bf8542a 100644 --- a/js/common.js +++ b/js/common.js @@ -11,6 +11,8 @@ $(function () { event.preventDefault(); PMA_querywindow.focus(); }); + + checkNumberOfFields(); }); /** diff --git a/js/functions.js b/js/functions.js index ba730ea0795d..3edee4cbc981 100644 --- a/js/functions.js +++ b/js/functions.js @@ -4112,3 +4112,23 @@ function PMA_formatDateTime(date, seconds) { } ); } + +/** + * Check than forms have less fields than max allowed by PHP. + */ +function checkNumberOfFields() { + if (typeof maxInputVars === 'undefined') { + return false; + } + $('form').each(function() { + var nbInputs = $(this).find(':input').length; + if (nbInputs > maxInputVars) { + var warning = $.sprintf(PMA_messages.strTooManyInputs, maxInputVars); + PMA_ajaxShowMessage(warning); + return false; + } + return true; + }); + + return true; +} diff --git a/js/messages.php b/js/messages.php index 43caa56cd172..259c4558ebdd 100644 --- a/js/messages.php +++ b/js/messages.php @@ -402,6 +402,12 @@ $js_messages['strTimeOutError'] = __( "Your export is incomplete, due to a low execution time limit at the PHP level!" ); + +$js_messages['strTooManyInputs'] = __( + "Warning: a form on this page has more than %d fields and could not be " + . "processed." +); + echo "var PMA_messages = new Array();\n"; foreach ($js_messages as $name => $js_message) { PMA_printJsValue("PMA_messages['" . $name . "']", $js_message); @@ -419,6 +425,9 @@ echo "var mysql_doc_template = '" . PMA_Util::getMySQLDocuURL('%s') . "';\n"; +//Max input vars allowed by PHP. +echo 'var maxInputVars = ' . ini_get('max_input_vars') . ';'; + echo "if ($.datepicker) {\n"; /* l10n: Display text for calendar close link */ PMA_printJsValue("$.datepicker.regional['']['closeText']", __('Done'));