0

I have a large POST being made in PHP that can be of any size as it is Tasks on a PRoject Management app...

Here is a screenshot of the edit tasks page which is now cutting off data when I save

The biggest problem also is that it is a module that will be installed on other peoples servers, so I can't simply modify server settings, what is my best option here?

enter image description here

JasonDavis
  • 48,204
  • 100
  • 318
  • 537
  • 2
    AJAX and update individual row separately. – Ken Cheung Oct 14 '14 at 02:24
  • 2
    is it exceeding max_input_vars? If so, you can send everything with javascript into a single variable – nice ass Oct 14 '14 at 02:24
  • What's the value of `post_max_size`, `max_input_vars` and `max_input_nesting_level`; are you using any special modules, such as suhosin? – Ja͢ck Oct 14 '14 at 02:47
  • @Ja͢ck `post_max_size = 200M` `max_input_vars = 1000` `max_input_nesting_level = 64` – JasonDavis Oct 14 '14 at 02:53
  • The `max_input_vars` seems a bit low, could you increase that and see what happens? – Ja͢ck Oct 14 '14 at 02:54
  • Perhaps, there is like 216 task records on this page and it saves changes up until the 198ths one...any change after that one is not saved – JasonDavis Oct 14 '14 at 03:03
  • `php_value max_input_vars 3000` fixed the problem! thanks...I cannot set this for all the people that will use my module though, it;s a real shame there is no way to set this from PHP code – JasonDavis Oct 14 '14 at 03:26

1 Answers1

0

Any size? Doubtful. You can always set a reasonable limit... even if that limit is 2GB.

In any case, chances are it isn't the raw size that's biting you, but the de-serialization and size limits there. Try POSTing in a format, such as JSON, and decoding it yourself rather than dealing with PHP's own handling of the POST body.

Brad
  • 159,648
  • 54
  • 349
  • 530
  • I'm not sure exactly what you mean, could you maybe show a small demo of how this could potentially work? Also on this page there is a button to POST the data like a normal form and another button that saves using AJAX and keeps you on the page – JasonDavis Oct 14 '14 at 03:04
  • @jasondavis Jack is pointing you in the right direction with `max_input_vars` and `max_input_nesting_level`. If you're posting via AJAX, just post a JSON object (can't really explain how specifically since I don't know what you have going on client-side), but from there you can read from `php://input` and use `json_decode()`. http://stackoverflow.com/a/18867369/362536 – Brad Oct 14 '14 at 03:07
  • Setting `php_value max_input_vars 3000` fixed my problem! Thats great but as this is a module to be release, I can't set this file for everyone, unfortunately it seems you cannot set this from runtime with PHP – JasonDavis Oct 14 '14 at 03:25
  • @jasondavis Right, which is why you need to use something other than PHP's built-in parser of POST data. JSON is generally a good choice. – Brad Oct 14 '14 at 12:42
  • are you saying that I could switch to JSON which would in turn reduce the number of POST vars? – JasonDavis Oct 15 '14 at 01:22
  • @jasondavis If you switch to JSON, there are no `$_POST` vars, avoiding the problem completely. By switching to JSON, you handle the deserialization yourself. – Brad Oct 15 '14 at 01:27
  • Using this method, does it require me to use AJAX? Right now I have 2 save methods, one is a regular form POST and the other POST but using jqueries AJAX call – JasonDavis Oct 15 '14 at 01:29
  • @jasondavis It does. The POST that your browser makes will always be encoded like a query string. If you make a POST via AJAX instead, you can send whatever you'd like. You can always handle a form submit via JavaScript, serialize the whole form, and send it. – Brad Oct 15 '14 at 01:31