Environment - max input vars
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 ). 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