PHP's max_input_vars setting - doh!

Author: Jennifer Hodgdon
Date Written: 11 September, 2012
Type: News/Blog
Subject: Web Development

Today I ran into an interesting problem. I was having trouble with PHP form processing. When I tried submitting a form with a lot of data in it (geographical points), the input my browser sent was being cut off before it got to the Routes plugin for processing. So even though the points were all there in the browser after I uploaded a GPX trace of the bike trail, after subsequently saving the post, the trail was being truncated down to 115 points. I was certain that this was working the last time I edited a trail with a GPX import (I definitely have several on the site with way more than 115 points), but it certainly wasn't working today. To make a long story short, it turns out that there is a php.ini directive called "max_input_vars", which (at least at my web hosting company) was set to 1000. This meant that the PHP $_POST was limited to having 1000 individual variable entries in it, and since each point along the route has 8 fields (latitude, longitude, elevation, text tag, address, city, state, and an integer for point ordering), that didn't leave room for very many GPS points. Luckily, it was easy to fix -- I just added:
php_value max_input_vars 10000
to my .htaccess file, and now all is well, at least until I try to import a really dense GPX trace!