WPML
Status
Resolved

Overview of the issue

Some websites may face the following JavaScript console error in the Translation Management Dashboard or Translation Management Jobs pages:

app.js?ver=5.0.4:1 Uncaught (in promise) SyntaxError: Unexpected token < in JSON at position 0

This error will also produce a series of PHP warnings like the following:

PHP Warning: Cannot modify header information - headers already sent in /app/public/wp-includes/rest-api/class-wp-rest-server.php on line 1258

PHP Stack trace:

PHP 1. {main}() /app/public/index.php:0

PHP 2. require() /app/public/index.php:17

PHP 3. wp() /app/public/wp-blog-header.php:16

PHP 4. WP->main() /app/public/wp-includes/functions.php:1105

PHP 5. WP->parse_request() /app/public/wp-includes/class-wp.php:737

PHP 6. do_action_ref_array() /app/public/wp-includes/class-wp.php:387

PHP 7. WP_Hook->do_action() /app/public/wp-includes/plugin.php:531

PHP 8. WP_Hook->apply_filters() /app/public/wp-includes/class-wp-hook.php:310

PHP 9. call_user_func_array:{/app/public/wp-includes/class-wp-hook.php:286}() /app/public/wp-includes/class-wp-hook.php:286

PHP 10. rest_api_loaded() /app/public/wp-includes/class-wp-hook.php:286

PHP 11. WP_REST_Server->serve_request() /app/public/wp-includes/rest-api.php:309

PHP 12. WP_REST_Server->send_header() /app/public/wp-includes/rest-api/class-wp-rest-server.php:224

PHP 13. header() /app/public/wp-includes/rest-api/class-wp-rest-server.php:1258

The error is specific to websites running PHP 5.6 and is caused by a deprecation warning triggered by PHP when the $HTTP_RAW_POST_DATA global variable is populated (even if it is not used), as explained here by the author of this change in PHP:

[…] the current way for triggering the deprecated message is a bit sub-optimal (we don’t show you the message when you try to access the $HTTP_RAW_POST_DATA variable, but when $HTTP_RAW_POST_DATA is populated.

The warning explains how to remove the deprecation notice.

Workaround

Editing the php.ini file


  1. Find and edit your server’s php.ini file.

  2. Look for a line containing the always_populate_raw_post_data string.

  3. If the line starts with a semicolon (;), it means it is commented out (and not being used). In this case, remove the semicolon.

  4. Check that the full line is always_populate_raw_post_data=-1 (it must end with “=-1”).

  5. Restart your server.

Upgrade PHP


Upgrading PHP to a more recent version (7.1 or greater) will remove the deprecation warning.

PHP 7.1 is much faster than PHP 5.6.

PHP 5.6 reached its end-of-life period on 1st of January 2019. This means that it is a “release that is no longer supported. Users of this release should upgrade as soon as possible, as they may be exposed to unpatched security vulnerabilities.” (source: https://www.php.net/supported-versions.php).

All known issues →