-
Notifications
You must be signed in to change notification settings - Fork 181
Cannot save more than a certain amount of UI Builder setting.
This was copied directly from https://github.com/valendesigns/option-tree/issues/39. The user has since been deleted, so I can't contribute it to them unfortunately.
Here is the solution to this critical bug:
It comes from the max_input_vars
PHP limit, according to the documentation this is the total amount of variables that can be posted, and the default limit is 1000.
The simplest way to fix this issue is to increase the max_input_vars
to anything higher like 2000 or even 10000 to be sure, if you have access to the php.ini
file then change it there, if not then you can add the following to an .htaccess
file in the "option-tree" directory:
php_value max_input_vars 10000
Or you can alternatively add the following to your functions.php
file:
ini_set('max_input_vars', 10000);
But I'm not sure if this one will work.... didn't try.
The PHP documentation states that an E_WARNING should be issued in case this limit is reached, you might need to set WP_DEBUG
to true
in your wp-config.php
file in order to see it.
This issue should be renamed from "Options not getting saved" to "Options erasing other options when getting saved" or eventually to "Cannot save more than X options". This bug is not related to database, nor related to the max execution time or max post size, it's only because of the max_input_vars
setting which is limited to 1000 by default.
More about the max_input_vars
: http://stackoverflow.com/questions/10303714/php-max-input-vars
and: http://stackoverflow.com/questions/8710185/new-limit-within-php-1000-fields-per-post-does-someone-know-if-the-number-can
This bug might not occur in all cases depending on the PHP version installed, I've encountered this issue on a PHP 5.4 installation, according to the guys at stackoverflow max_input_vars
was introduced in PHP 5.3, however I didn't verify this so it might affect more people than we think.
Lastly, 1000 variables posted can seem a lot, but it is really not, especially as each OT option has as many variables as available choices, plus the class field, plus the label, ID, row, type, taxonomy, description fields and so on... You shouldn't be surprised that the 1000 input vars limit is being reached as each single option requires at least a dozen input vars already, minimum! (it's 13 input vars actually for one checkbox option with one choice).