I have quite an interesting issue. As you can see in the code below, I send 2 POST variables to my PHP page. One of the variables is a JSON array. If unsyncedContacts.length
is < 71, it works as intended. As soon as we get over 71 items in the array, the PHP page will only recognize the first 71. I've watched the timeline in chrome as this is happening and the data is under a MB.
Any advice or help would be greatly appreciated as I am at a loss. There are no errors being thrown, and the 71 records that do manage to be sent between the pages are executed properly.
$.ajax({
url: 'ajax/upsert_contacts.php',
type: 'POST',
dataType: 'json',
data: {
"contacts": unsyncedContacts,//JSON array
"userInfo": localStorage.userInfo
}
})
.done(function(data) {
//do stuff here. i don't think its part of my issue
});
set_time_limit(0);//set the time limit for each contact to prevent breaking.
//POST DATA
$currentUsersName = json_decode($_POST['userInfo']['usersName']);
$contacts = $_POST['contacts'];
$aCount = count($contacts);//returns 71 at MOST
I've tried stepping through the PHP with xdebugger and $aCount always returned 71 at most. As I said before, if it were say 50 items in $contacts, it'd work great. Once it hits 72, it gets weird
Edit: Someone asked in the comments, but deleted it: "Whats your server's max_input_vars set to?".
max_input_vars 1000
Turns out it was the max_input_vars
.
I had xdebug enabled in my dev environment and for some reason it did not show the PHP warning stating that I had exceeded the 1000 (the array i was passing was a JSON object with 14 properties).
14*71 = 994, meaning the next array item would go over the 1000 limit that I had set. To remedy this I created a .htaccess file with php_value max_input_vars 20000
to ensure my code wont break again