Environment - max input vars: Difference between revisions

From MoodleDocs
m (Added an example of the change made in php.ini on Ubuntu.)
 
Line 6: Line 6:
* Grading courses with big number of participants
* Grading courses with big number of participants
* Large quizzes and quiz settings
* Large quizzes and quiz settings
The default value for max_input_vars in PHP is '''1000''', this is not enough for many cases.
The default value for max_input_vars in PHP is '''1000''', this is not enough for many cases.


If you are using PHP 7 the recommended value for the '''max_input_vars''' in Moodle is '''5000''' but you can still use Moodle with the lower value. Moodle code has a workaround that allows to submit the forms even with bigger limit however this workaround is not perfect. It is much better to increase the setting.
If you are using PHP 7 the recommended value for the '''max_input_vars''' in Moodle is '''5000''' but you can still use Moodle with the lower value. Moodle code has a workaround that allows to submit the forms even with bigger limit however this workaround is not perfect. It is much better to increase the setting.


If you are using PHP 8 the minimum value of 5000 '''is required'''. By default PHP 8 sets to display startup errors (see [[https://php.watch/versions/8.0/startup-errors-enabled]]). This means that the warning about exceeding max_input_vars appears before the workaround even applied.
e.g. in Ubuntu 20.x, within /etc/php/7.4/apache2/php.ini, find this section and remove the comment (semi-colon) and edit the line to increase the size:
 
<nowiki>;</nowiki> How many GET/POST/COOKIE input variables may be accepted
 
<nowiki>;</nowiki>max_input_vars = 1000
 
'''max_input_vars = 5000'''
 
If you are using PHP 8 the minimum value of 5000 '''is required'''. By default PHP 8 sets to display startup errors (see [[https://php.watch/versions/8.0/startup-errors-enabled]]). This means that the warning about exceeding max_input_vars appears before the workaround even applied.


To change max_input_vars you can either set it in php.ini or modify it in runtime, for example for Apache you can create '''.htaccess''' file:
To change max_input_vars you can either set it in php.ini or modify it in runtime, for example for Apache you can create '''.htaccess''' file:
Line 17: Line 24:
php_value max_input_vars 5000
php_value max_input_vars 5000
</code>
</code>
[[Category:Environment|PHP]]
[[Category:Environment|PHP]]
[[es:admin/environment/custom check/max input vars]]
[[es:admin/environment/custom check/max input vars]]

Latest revision as of 08:08, 2 December 2021

The PHP setting max_input_vars determines how many input variables may be accepted (limit is applied to $_GET, $_POST and $_COOKIE superglobal separately). If there are more input variables than specified by this directive, an E_WARNING is issued, and further input variables are truncated from the request.

There are a lot of big or potentially big forms in Moodle, such as:

  • Site administration tree search
  • Editing roles
  • Grading courses with big number of participants
  • Large quizzes and quiz settings

The default value for max_input_vars in PHP is 1000, this is not enough for many cases.

If you are using PHP 7 the recommended value for the max_input_vars in Moodle is 5000 but you can still use Moodle with the lower value. Moodle code has a workaround that allows to submit the forms even with bigger limit however this workaround is not perfect. It is much better to increase the setting.

e.g. in Ubuntu 20.x, within /etc/php/7.4/apache2/php.ini, find this section and remove the comment (semi-colon) and edit the line to increase the size:

; How many GET/POST/COOKIE input variables may be accepted

;max_input_vars = 1000

max_input_vars = 5000

If you are using PHP 8 the minimum value of 5000 is required. By default PHP 8 sets to display startup errors (see [[1]]). This means that the warning about exceeding max_input_vars appears before the workaround even applied.

To change max_input_vars you can either set it in php.ini or modify it in runtime, for example for Apache you can create .htaccess file: php_value max_input_vars 5000