I'm working on a project using display suite. I've had a bug in the admin forever which took me a long time to track down. I'm writing this post mostly as a warning to others, as the problem most likely lies in Drupal AJAX core in D7...but perhaps there would be a way to change DS a little to avoid the problem.

Related core issues:
#1565704: Core interfaces can go over max_input_vars
#1517092: admin/structure/menu/manage/MENU_NAME cannot be submitted on PHP 5.3.9+ for large menus (>~1000 items)
#329056: Unable to save changes to menu

Problem

In Display Suite and Managing a display view for my node with 50+ fields, and change a field from one region to another, the admin interface gets an ajax error.

Uncaught TypeError: Cannot call method 'apply' of undefined
Uncaught TypeError: Object [object Object] has no method 'once'

Reason
The ajax request which is sent to /system/ajax has 2240 variables and is roughly 108kB. Both Suhosin patch and PHP > 5.3.9 limit post vars to 1000 by default.

This causes the ajax post to get truncated, most importantly the Drupal.settings.ajax_page_state[js] data, which Drupal uses in an AJAX request to determine which javascript files are already loaded on the site, and if the ajax request requires new JS to get loaded, it will send it along with the response. Because of the truncating of my post variables, /system/ajax was never being told that jquery.min.js was getting loaded, and it would re-send it, causing a conflict and the errors above.

Solution
Ideally the ajax system would get resolved, but this won't happen. To fix it, you'll need to bump up your PHP settings to allow for these mega ajax requests. DS suite might be able able to be changed, to avoid this problem.

My personal problem was suhosin blocking the requests. I resolved it with these two settings:

suhosin.post.max_vars = 3000
suhosin.request.max_vars = 3000

You should look at all the variables as some other suhosin.post.max_* variables like suhosin.post.max_array_index_length looks like they could also block Drupal ajax stuff.

The other major problem for me, was that suhosin's log goes to /var/log/syslog by default and I wasn't checking there for PHP errors, so this was very hard to track down. I would recommend setting it to log some where more useful. I'm going to try and get it logging into my error_log, but not sure if this is possible for vhosts yet.

For PHP > 5.3.9 you should also look at

max_input_vars = 3000

Please keep in mind, from what I've read while max_input_vars does show up in phpinfo() for PHPs previous to 5.3.9, setting it does nothing. It doesn't appear to be truncating the posts either.

Comments

j0rd’s picture

Issue tags: +max_input_vars

tagging

swentel’s picture

Hm, this should be better with the 2.x branch where I load less form input compared with the 1.x branch. Not sure whether I'll be able to backport that.

chilic’s picture

subscribe

swentel’s picture

Status: Active » Closed (works as designed)

So yeah, there isn't much I can do about this, the 7.x-2.x has been rewritten to make sure this doesn't happen.

Added this to the documentation over at https://drupal.org/node/1524800

swentel’s picture

Issue summary: View changes

added some core issues.