WordPress/WooCommerce: Dealing with PHP Post length issue

The problem of WooCommerce variants or lengthy posts ar not getting saved.

The limitation with the values set by default by PHP configuration values can be problematic with WordPress sometimes. For example, you may face problems while saving lengthy post data because of those limitations.
Making things more worst, if you are using WooCommerce plugin with a large number of variation products, it will prevent from saving the data throwing no appropriate errors.

Create info.php.

The code should be as simple as this.

<?php phpinfo(); ?>

Copy it to the wp-admin folder using FTP. Ensure 644 permission set.php_post_length

Now, if you access weburl/wp-admin/info.php, the php configuration values including php version will be visible.

You can override few key values to increase the bandwidth to deal with issues related to post length limitations.

Edit php.ini

The configuration file (php.ini) is read when PHP starts up. For the server module versions of PHP, this happens only once when the web server is started.
Most of the hosting service provider won’t allow editing php.ini file out of the box. You can make it happen by overriding php.ini values in your public_html folder.

Increase the limits by adding these values in your custom php.ini placed in public_html.

memory_limit=256M
upload_max_filesize=10M
post_max_size=10M
max_execution_time=900
max_file_uploads=100
max_input_vars = 2000

As an alternative solution, .htaccess (allows for decentralized management of web server configuration) can be updated to enforce the config value changes in case of shared servers where there can be restrictions to update php.ini.

php_value post_max_size 10M
php_value upload_max_filesize 10M

Configuring Suhosin

If enabled, Suhosin may need to be configured to increase its data submission limits. Some hosts allow you to change settings via php.in, suhosin.ini, or .htaccess
You can find more information on this by referring this WordPress post.
The Key values to be changed are

suhosin.get.max_vars 1024
suhosin.post.max_vars 1024
suhosin.request.max_vars 1024

Mod_security can also prevent data saving; you may experience error 503’s if this is the case. As with the above issues, you may want to contact your host to help resolve this.

Check out our WooCommerce plugins store.

Leave a Reply