Roland Ulbricht

Problems with large forms / Drupal's permissions-page doesn't save

2012-10-07

I recently ran into a problem with a Drupal 6 site: Saving the /admin/user/permissions admin page was not working anymore. The problem was the size of the form. Several settings had to be changed. I am not an expert at Apache / PHP configuration, but it seems that this problem appears quite frequently and couldn’t find a site that describes all the steps necessary to fix it, that’s why I decided to share the information here.

Let’s start at the beginning. After clicking “save changes” on my permissions page I would just return to the unaltered page. First, I suspected a problem with Drupal, I checked the drupal logs, searched the Drupal manual and forums, made sure the database was not damaged and Drupal was up-to-date. However, the problem was not there.

After that I was able to narrow the problem to the size of the submitted form. In case you don’t know Drupal: The permissions settings page is a table of all permission-settings of all installed modules in the rows and all user roles in the columns. So if you have 10 modules with 3 permissions each and 3 user roles you end up with 1033=90 checkboxes. I looked at the source of the generated form on my page and found out it contained 3712 checkboxes. Apparently this is a problem for some server configurations.

Unfortunately, I used a shared hosting, so I was not able to check server logs or edit the main config files directly. Using phpinfo(); I was able to read out all the settings.

I read many different pages on the issue which all suggested different solutions and found that the following changes solved my problem.

PCRE

In the php-code I added the following lines concerning the PCRE configuration, in case of Drupal the best place for this was the settings.php which is run at the beginning of page load:

ini_set('pcre.backtrack_limit', 10000000);  
ini_set('pcre.recursion_limit', 500000);

PHP runtime configuration

In the .htaccess file I added the following lines concerning the PHP runtime configuration:

php_value max_input_vars 5000  
php_value max_input_time 120 

suhosin

This still did not help, but I soon discovered that also the suhosin-configuration blocks large submissions, therefore I added the following code the the .htaccess file as well:

php_value suhosin.post.max_array_index_length 512  
php_value suhosin.post.max_name_length 512  
php_value suhosin.post.max_vars 5000  
php_value suhosin.request.max_array_index_length 512  
php_value suhosin.request.max_vars 5000

Conclusion

After all these changes, my form worked again.

Again, as I am using shared hosting, I cannot check the logs to make sure which of the lines really did the trick, but the combination of all these helped.

I hope that this description can be of help to others experiencing the same issue.

Disclaimer: The steps described above helped solve my problem in exactly my configuration. Your problem and configutaion might be different. Use this at your own risk, please make sure you know what you are doing, make backups before changing anything and read the manual!

Further References

Posted: 2012-10-07; Tags: IT, webserver, drupal