cms icon indicating copy to clipboard operation
cms copied to clipboard

Can't save new matrix block type in Craft 3.4.1

Open ryanmwc opened this issue 5 years ago • 16 comments

Description

I had created a matrix field earlier in the week with several block types while in version 3.3.x and then updated to version 3.4.1 yesterday. Sometime after the update, I created a new block type, added a field, and saved it, then I got an error. From the logs:

2020-01-31 01:18:17 [-][1][op4ovmv6f9nluvrgh8poqhbdat [error][yii\base\ErrorException:1] yii\base\ErrorException: Unknown: Input variables exceeded 1000. To increase the limit change max_input_vars in php.ini. in /Users/me/Sites/MWC/vendor/yiisoft/yii2/base/ErrorException.php:43
Stack trace:
#0 /Users/me/Sites/MWC/vendor/craftcms/cms/bootstrap/web.php(51): ::unknown()
#1 /Users/me/Sites/MWC/web/index.php(20): ::unknown()
#2 {main}
2020-01-31 01:18:15 [-][1][op4ovmv6f9nluvrgh8poqhbdat][info][application] $_GET = [
    'p' => 'mwclogin/settings/fields/edit/37'
]

I had googled around searching for Input variables exceeded 1000. To increase the limit change max_input_vars in php.ini but a few SO responses said that increasing the limit was not the right thing to do, that it's a solution to the wrong problem.

Steps to reproduce

  1. Create a matrix field in version 3.3.x
  2. Update to 3.4.1
  3. Add a new block type to existing matrix field
  4. Add a text field
  5. Save the field
  6. See the error

Here's a gif:

matrix-block-bug

Just to be clear what's going on in the gif, I'm scrolling down to create a new block type in my existing matrix field called "Test", I create a new plain text field called "Test", and I save the field and see the error.

Additional info

  • Craft version: 3.4.1
  • PHP version: 7.3.9
  • Database driver & version: MySQL 5.6.21

ryanmwc avatar Jan 31 '20 00:01 ryanmwc

This error is pretty common (regardless of craft 3.4) if your matrix is getting big (e.g. with supertables inside your matrix and lots of linkfield fields). I'm pretty sure you will need to up the max_input_vars variable in your php settings. At least until craft finds a better way to save field-settings data. Any ETA on this @brandonkelly? Craft 4?

nettum avatar Jan 31 '20 11:01 nettum

That error was added in 21d13d4b053bd45e25082ac0e10baba4ea39c9a0, per #876. It actually gives you an opportunity to increase max_input_vars, and then reload the browser window, which will resubmit all of your changes exactly as they were initially submitted, this time hopefully without hitting the same server limitation.

We do plan to fix this in the long run by making the form post JSON data rather than serialized form data, so the max_input_vars will stop applying.

brandonkelly avatar Jan 31 '20 19:01 brandonkelly

Not sure if this issue should be closed. It's a pretty serious issue and needs a fix. I'm guessing it might get lost in the closed list.

JoppeDC avatar Mar 25 '20 13:03 JoppeDC

Agreed, this should be left open. Having this issue today.

JayBox325 avatar Oct 20 '20 10:10 JayBox325

Was wondering if there's an update for this issue! I'm currently facing the same problem as well - where Craft doesn't allow me to save adding new matrix blocks, most likely due to large number of nested blocks within.

withoutwax avatar Apr 23 '21 09:04 withoutwax

Now with Craft 4 released, any update on this issue? We are currently facing this problem as well, where Craft doesn't allow us to save adding new matrix blocks.

smunusamy avatar Sep 08 '22 15:09 smunusamy

We weren’t able to fix this in Craft 4, however there’s another possible fix we’re going to look into for Craft 5.

In the meantime you can still work around it by increasing PHP’s max_input_vars.

brandonkelly avatar Sep 08 '22 16:09 brandonkelly

I have increasing php's max_input_vars to 7000 but I have the same problem

Abbe91 avatar Jan 18 '23 13:01 Abbe91

@Abbe91 & @rspilhaus just to confirm, is the error you're getting also an "Input variables exceeded ... " error? Or are you getting a different error?

brianjhanson avatar Feb 01 '23 22:02 brianjhanson

We're currently experiencing this issue at my organisation too, we've upped the default max_input_vars value to 2000 (doubling it) and this hasn't had the desired effect.

Running v3.7.26 of Craft CMS so due an update for sure but as I understand it this doesn't have a fix yet in any later version.

Is there an official workaround that can be applied? Or a recommended value to apply to that property in php.ini?

sam-netlogix avatar Mar 14 '23 02:03 sam-netlogix

@sam-netlogix If you’re getting the same exact error message (Input variables exceeded 1000), then the max_input_vars change wasn’t made correctly, or the web server needs to be restarted for it to apply.

brandonkelly avatar Mar 14 '23 12:03 brandonkelly

@sam-netlogix If you’re getting the same exact error message (Input variables exceeded 1000), then the max_input_vars change wasn’t made correctly, or the web server needs to be restarted for it to apply.

The change is actually reflected in the PHP Info section under Utilities, and the error message now shows "Input variables exceeded 2000" instead of 1000, web server was restarted after we applied the change. I think the change was applied successfully.

sam-netlogix avatar Mar 14 '23 20:03 sam-netlogix

@sam-netlogix Can you try going all the way to 10000 and see if that helps?

brandonkelly avatar Mar 15 '23 21:03 brandonkelly

@brandonkelly this seems to have resolved our issue for now 👍

Is a permanent fix for this planned for a future release?

sam-netlogix avatar Mar 19 '23 23:03 sam-netlogix

@sam-netlogix Glad to hear. We had hoped to solve in 4.0 but it didn’t make the cut, so we’ll see if we can get this resolved for 5.0. (The fix would be a breaking change, so can’t happen mid-release cycle.)

brandonkelly avatar Mar 20 '23 18:03 brandonkelly

A little warning in the System Report would be nice. Similar to the Memory Limit or Max Execution Time warnings. Probably it's hard to define a minimum, but it seems 1'000 is too low for many projects.

~~I just checked the settings from different projects, which are hosted on cheap shared hostings. The standard max_input_vars settings are between 1'000 to 200'000...~~

Oh sorry, this is only an issue during development, so changing the max_input_vars should never be a problem.

martin-coded avatar Sep 16 '23 10:09 martin-coded