Fixing WordPress Importer Strict Standards Errors and Warnings
Content
Many WordPress developers and site administrators encounter a common set of warnings when using the WordPress Importer plugin with WP_DEBUG enabled. These warnings, while not typically breaking the core import functionality, can clutter the admin interface and sometimes lead to more severe "headers already sent" errors. This guide explains the cause of these errors and provides practical solutions.
Common Error Messages
Users consistently report two primary "Strict Standards" warnings appearing on the Tools → Import screen (wp-admin/import.php):
- Redefining already defined constructor for class WXR_Parser_Regex in
parsers.phpon line 408. - Declaration of WP_Import::bump_request_timeout() should be compatible with WP_Importer::bump_request_timeout($val) in
wordpress-importer.phpon line 38.
In some cases, these warnings can also trigger secondary errors like "Warning: Cannot modify header information - headers already sent," which can prevent the admin page from rendering correctly.
Why These Warnings Occur
These are not bugs that prevent import but rather code standards warnings triggered by specific PHP configurations:
- Outdated Plugin Code: The warnings stem from coding practices that were acceptable in older versions of PHP but now violate stricter standards enforced in PHP 5.4 and later.
- WP_DEBUG is Enabled: These messages are only visible when
WP_DEBUGis set totruein yourwp-config.phpfile, which is common on development and staging sites. - PHP Version: The warnings are more prominent on servers running PHP 5.4, 5.5, 5.6, and 7.x due to their stricter error reporting.
How to Resolve the Warnings
Solution 1: Update the Plugin (Recommended)
The ideal solution is to ensure you are using the latest version of the WordPress Importer plugin. The 'WordPress Importer' team has addressed these compatibility issues in more recent updates. Check your Plugins page in WordPress admin for an available update.
Solution 2: Apply a Temporary Code Patch (For Developers)
If an update is not available or does not resolve the issue, you can manually patch the plugin files. Warning: Editing plugin files directly is not recommended as changes will be lost when the plugin updates. This is a temporary development fix.
Fix for the first error in parsers.php:
Navigate to the wp-content/plugins/wordpress-importer/parsers.php file. Around line 404, you will find a PHP4-style constructor. Comment it out or remove it:
// function WXR_Parser_Regex() {
// $this->__construct();
// }
Fix for the second error in wordpress-importer.php:
Navigate to the wp-content/plugins/wordpress-importer/wordpress-importer.php file.
1. Ensure the WP_Import::bump_request_timeout method declaration includes the required $val parameter:
function bump_request_timeout($val) {
... // existing code
}
2. Also, check for and remove any deprecated PHP4-style constructor for the WP_Import class around line 66:
// function WP_Import() { /* nothing */ }
Solution 3: Disable WP_DEBUG on Production Sites
On a live production site, WP_DEBUG should be disabled for security and performance reasons. Setting define('WP_DEBUG', false); in your wp-config.php file will hide these warnings. They are intended for development environments only.
Conclusion
The Strict Standards warnings from the WordPress Importer are a known issue related to older code styles and modern PHP versions. While the import process often works correctly despite them, applying the recommended updates or the temporary code fixes outlined above will clean up your admin interface and ensure better compatibility with current PHP standards. For the most permanent and secure solution, always check for and install the latest version of the plugin.
Related Support Threads Support
-
Error in debug modhttps://wordpress.org/support/topic/error-in-debug-mod-5/
-
PHP warnings with WordPress 4.0https://wordpress.org/support/topic/php-warnings-with-wordpress-40/
-
Couple of BUGs after update WPhttps://wordpress.org/support/topic/couple-of-bugs-after-update-wp/
-
Strict standards errors in PHP 5.4https://wordpress.org/support/topic/strict-standards-errors-in-php-54/
-
Error in debug modhttps://wordpress.org/support/topic/error-in-debug-mod-1/
-
Lots of warnings on import pagehttps://wordpress.org/support/topic/lots-of-warnings-on-import-page/
-
Debug: Infohttps://wordpress.org/support/topic/debug-5/
-
full of errorshttps://wordpress.org/support/topic/full-of-errors-1/
-
WordPress Importer displays an error messagehttps://wordpress.org/support/topic/wordpress-importer-displays-an-error-message/
-
importer raises errors with WP_DEBUG mode onhttps://wordpress.org/support/topic/importer-raises-errors-with-wp_debug-mode-on/
-
Please Fix PHP Warninghttps://wordpress.org/support/topic/please-fix-php-warning/
-
Fails to import attachmentshttps://wordpress.org/support/topic/fails-to-import-attachments/
-
PHP 5.4 Strict Standardshttps://wordpress.org/support/topic/php-54-strict-standards/
-
Redefining already defined constructorhttps://wordpress.org/support/topic/redefining-already-defined-constructor-2/
-
Debug Error Noticeshttps://wordpress.org/support/topic/debug-error-notices/
-
Strict Standards errors with WP 3.6-beta3-24300https://wordpress.org/support/topic/strict-standards-errors-with-wp-36-beta3-24300/
-
Produces warnings when debugging is ONhttps://wordpress.org/support/topic/produces-warnings-when-debugging-is-on/
-
Strict Standards warning web debug turned on.https://wordpress.org/support/topic/strict-standards-warning-web-debug-turned-on/
-
Error – Strict Standards with WP_DEBUG enabledhttps://wordpress.org/support/topic/error-strict-standards-with-wp_debug-enabled/
-
WP 4.2-beta3 Strict Standards warningshttps://wordpress.org/support/topic/wp-42-beta3-strict-standards-warnings/
-
Error: Redefining already defined constructor for class WXR_Parser_Regexhttps://wordpress.org/support/topic/error-redefining-already-defined-constructor-for-class-wxr_parser_regex/
-
Strict Standards Noticehttps://wordpress.org/support/topic/strict-standards-notice-2/
-
WordPress 4.2.1 Strict Standards warningshttps://wordpress.org/support/topic/wordpress-421-strict-standards-warnings/
-
Error in import – please fix – client is upsethttps://wordpress.org/support/topic/error-in-import-please-fix-client-is-upset/
-
Error messagehttps://wordpress.org/support/topic/error-message-309/