Php setting max_input_vars must be at least 5000 moodle

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

Installing and upgrading help

Installation Error on php max_input_vars

  • ◄ Error driver database problem detected
  • Moodle Messages problem after upgrading to 3.9 ►

Hi, I have installed moode to Ubuntu server 16. while trying to install moodle it shows to set the php input vars to 5000. I have already set it to 10000. After changing the values I have restarted the Apache2 server. the error keeps on showing. then I have checked the php-info.. It shows the max_input_vars is 10000.

Apart from this what should I do. I have also tried .htaccess file creation.

Php setting max_input_vars must be at least 5000 moodle

Php setting max_input_vars must be at least 5000 moodle

max_input_vars is a DB config/tweak (for mysql/mariadb my.cnf file).

Restart your DB service - catch 22 = shared hosting?

'SoS', Ken

Hello Ken,

I have restarted mysql service. I have hosted this in aws. I have even tried restarting the instance too. nothing worked.

Dang!  My 'bad' ... true it is a php setting - having 'senior moments' today!

Is DB service localhost (on same machine as code) or is it remote (another server)?   Check config.php for DB server.  Not long ago I was helping someone hosting with AWS and the DB server could be accessed only by Amazon's internal fully qualified domain name.

'SoS', Ken

I do think that it is odd that noorul says php.info shows 10000. So, I don't know?

Ken, max_input_vars is a php.ini setting, as far as I know.

noorul, perhaps you didn't make this change in the correct php.ini file. If you had the ability to go into your Moodle, admin/Server/php info, you would see the information from your php.ini file. If max_input_vars is not what you set it to, then you either edited the wrong file or have a typo in your php.ini file.

Another technique, without Moodle working, is to create a simple info.php file and put it on your server. It will show the same information that Moodle shows you. I'll attach this file.

Make sure the environment.xml file in code/admin/ is of the moodle version you are trying to install.

In a search of all moodle3x/admin/environment.xml directories/files for 'max_input_vars' (acquired via git) shows that only 3.5 had an optional in check for max_input_vars

fgrep 'max_input_vars' ./moodle3?/admin/environment.xml

./moodle35/admin/environment.xml:     

Search of versions 3.10 and 3.11 code/admin/environment.xml didn't show any check on max_input_vars:

Kens-MBP-2:MDLGITTEST kentask$ fgrep 'max_input_vars' ./moodle310/admin/environment.xml
Kens-MBP-2:MDLGITTEST kentask$ fgrep 'max_input_vars' ./moodle311/admin/environment.xml

'SoS', Ken

Hi ken,

It shows max input vars = optional

What version of Moodle are you trying to install?

Since server is Linux (Ubuntu) you should have php-cli installed and can access to it via ssh.  One can install a moodle via command line:

first check you do have php-cli installed:

php -v

should show that.

Then

cd /path/to/moodlecode/admin/cli/

php install.php

You will be prompted for all the same things the GUI would have prompted for.

'SoS', Ken

Hi Ken,

I’m trying to install Moodle 3.11 and I have php -cli installed. And I can see php - cli is installed.

I can access the install.php file. Is there any changes I should make ? and I don’t use guy version.

pls help me with this.

I am trying to help ... but .. help is only as good as answers to questions ... and those answers include what was shown to you!

What did you see when you issued: php -v

Ubuntu doesn't have a '16' ... there is a 1.6 ... when it comes to installing moodle, details (versions) are important.

Please see:

http://www.syndrega.ch/blog/#php-and-dbms-compatibility-of-major-moodle-releases

to make sure you have minimal versions required for 3.11 installed.

Ok 3.11 is the version you are attempting to install ... please verify that by looking at the version.php file in code root.  Show me what it shows you!

Have never seen that max_input_vars check ... but then again, I install via command line.   Maybe, just maybe, one can 'get by' this issue by installing via command line.

Before you try, however, do an environment check from command line:

cd /path/to/moodlecode/admin/cli/

php checks.php

If ALL is ok, that script will show:

OK: All 'status' checks OK

Let's see if command line install by passes your issue.

'SoS', Ken

Hi Ken,

As you said, I tried php checks.php. it shows the below errors.

Php setting max_input_vars must be at least 5000 moodle

Ken: You might need to do a git pull because that line is in 3.10.4 and 3.11.

Duh!  Begin ... red in face ...

Yep ... you are correct ...

./moodle310/version.php:$release  = '3.10.3 (Build: 20210325)';// Human-friendly version name
./moodle311/version.php:$release  = '3.11dev (Build: 20201224)';// Human-friendly version name

prior to git pull
not there
fgrep 'max_input_vars' ./moodle31?/admin/environment.xml renders nada.

git pull on 310:
admin/environment.xml  |   4 +-

on 311 which (red in face) was a dev release (double red in face):
admin/environment.xml  |   187 +

check for the check

fgrep 'max_input_vars' ./moodle310/admin/environment.xml
present and optional

fgrep 'max_input_vars' ./moodle311/admin/environment.xml
present and optional

one more reason to use git!

Thanks, Leon.

Let's hope OP having issue might consider git install.

'SoS', Ken

Related follow up and a high recommendation to use git for installs and updates/upgrades ...

Moodle code now has a checks.php that does an environment check from CLI.   That's great ... now my up and upgrade scripts will run checks.php and pause.   If I (red in face) wasn't aware of a new check 'making it's way into required, doing the check before the pull means I haven't touched the code files nor have I altered the DB and tables!

Can cancel my up/upgrade ... fix ... then run again - which is a time saver!!! (don't have to restore site from backup).

Softac and other one click wonders at present don't run checks.  One more reason to stay away from them!

Anyhoo ... an additional 5 cents!

'SoS', Ken

Noorul: Your screenshot of the PHP setting:

max_input_vars => 10000 => 10000

Is from the command line (php -i) but the error is from the web interface (GUI). So maybe you need to restart the web server service to read the new max_input_vars setting from the PHP .ini file. The service you need to restart might be apache2 or php-fpm.

If you're still getting this error then you can see max_input_vars for the web server by creating a file called phpinfo.php in the Moodle source code folder containing two lines:

phpinfo();

Then go to /phpinfo.php at your site's web address and search for max_input_vars:

Php setting max_input_vars must be at least 5000 moodle

Delete this phpinfo.php file afterwards.

The check for max_input_vars ≥ 5000 is a mandatory check with PHP 8.0 but is an optional check with PHP 7.x.

Hi Leaon,

I tried creating phpinfo.php in /var/www/html/moodle/admin/cli, and tried accessing phpinfo.php in my site. It shows max_input_vars is 1000.

Php setting max_input_vars must be at least 5000 moodle

But for confirmation I have searched for php.ini files

Php setting max_input_vars must be at least 5000 moodle

the I opened the file in etc/php/8.0/apache2/php.ini in that the max_input_vars is set to 10000. 

Php setting max_input_vars must be at least 5000 moodle

Hey !!!!! Thanks you ken & Leon.

Once again I edited php.ini file and saved it. now its working !!!

Thanks a lot !!!!

Congrats on solving!

Comment: sort of unusual to see only PHP 7.0 and PHP 8.x.  That find command helped you locate the correct php.ini to edit ... phpinfo should have shown a line showing what php.ini your web service was using.

Suggest removing those backups of older versions of PHP ... keep your server 'clean of stuff' not using.  Reduces confusion.

'SoS', Ken

  • ◄ Error driver database problem detected
  • Moodle Messages problem after upgrading to 3.9 ►

What is max_input_vars in PHP INI?

max_input_vars is a setting managed through the PHP setting file (php. ini) which limits the number of inputs you can set when posting forms. The Jomres Micromanage and Standard tariff editing modes allow you to have precise control over the price of each and every day in your property, for each room type.

How do I change the PHP input vars limit in WordPress?

1 Method: edit the PHP..
Locate your PHP. ini file. ... .
If you find your existing PHP. ini, open the file and locate the following line of code (xx represents a number): max_input_vars = xx ; And set it to your desired limit. ... .
If you created your own PHP. ... .
Save your changes, and reboot your local host or your server..

Where do I change PHP max input variables?

By default, the maximum number of input variables allowed for PHP scripts is set to 1000. You can change this amount by setting the max_input_vars directive in a php. ini file. To verify the current value of the max_input_vars directive and other directives, you can use the phpinfo() function.

How increase PHP max input variables cPanel?

How to increase the max_input_vars limit in cPanel.
1) Log into cPanel..
2) Look for the SOFTWARE section and click on Select PHP version..
3) In the new window click on the Switch To PHP Options button..
4) Here you can locate the max_input_vars and enter the value that you require..