How to Fix WordPress Export, Disqus Import Comments Errors

By 17-08-2012   BloggingTutorialsWordPress

Want to fix WordPress export comments errors, and problems in Disqus import? Are you unable to replace Disqus Comments with your WordPress comments? We switched WordPress Comments to Disqus comments, which are live right now and would like to share with you some errors which we fixed along the way. The purpose of this post is that if you have experienced similar errors, these tips should help you fix it.

First you need to install the Disqus Plugin. You need to simply export your WordPress comments to Disqus comments, and it will sync automatically later between the two commenting systems.

WordPress Comments Export Errors

disqus export error

I understood that maybe the error was because the comment export file would be very huge as we intended to export nearly 30,000 comments! Maybe there was a better and more reliable way to export comments to Disqus.

WXR File Export Errors

The next best way to export comments from your WordPress blog to Disqus comments was to use the WordPress export feature to create a WordPress eXtended RSS or WXR file, which could then be uploaded to Disqus. Go to WordPress Admin> Tools> Export. Choose to export all posts easily.

WXR export file

But the WordPress export feature did not work as smoothly as expected. We downloaded the file and uploaded it to Disqus import, but the file would simply not import stating that it had errors. We checked at the bottom of exported file and found the following error

PHP execution time

The file creation timed out before the full file was created at 18MB. We checked that WordPress only allowed maximum file execution time for 30 seconds everytime. There was a need to increase the PHP script execution time that WordPress would allow to let us create the WordPress export WXR file.

So we added the following code to the wp-config.php file in the WordPress installation folder. This increased the execution time for generation of this WordPress export file to 60 seconds. You can increase the time further if your scripts are still timing out.
ini_set("max_execution_time", 60);

This is a very important file which contains your important database information and passwords. Now the script was able to completely execute and we were able to successfully create the WordPress export file at over 40MB.

WXR file code errors

Now you need to upload this WXR file in the Disqus comment import system.

discuss import comments

Though the comments file uploaded successfully, Disqus was still unable to process the file pending some errors. The file showed the following XML syntax errors this time

XML error

After 24 hours when Disqus was still unable to process the file be contacted Disqus support, and advised that the error occurs due to XML-invalid UTF-8 characters in the file. After fixing these errors, users are advised to re-import the files.

Specifically, it is the first character (i.e., the first byte) in that list of four bytes that is the culprit. Although this character is a valid UTF-8 character, it is XML-invalid. In other words it cannot be used in XML files.

How to find the invalid characters?

Disqus support gave some very useful advice without which it was not possible to fix this file anyway. We had uploaded this file onto our server, and we logged on using Putty to run the grep code on this xml file. grep is a command-line utility for searching data for matching a regular expression.

grep --color='auto' -P -n "[x00-x08]" file.xml
grep --color='auto' -P -n "[x10-x1f]" file.xml

And we were able to find the offending error which was causing the problem.

error comment

So we searched for the comment on WordPress, deleted the comment (someone had used short code in the comment), and re-exported the WordPress comment file and this time it should upload successfully and get processed hopefully.

 Imported comments error

Though the file uploaded successfully, the panel stated that the comment file processing time was around 24 hours. In a few hours the comments started going online and we enabled the Disqus comments from the WordPress admin panel, which automatically replaced our previous WordPress comments system. However, some comments errors still persisted …

comments error

… and Disqus was able to to provide a detailed report on all the comments that failed to be imported. We searched for those comments in WordPress and deleted them as the all contained form of strange code.

I hope that if you are experiencing similar errors in your Disqus commends installation, you would be able to fix them easily now.  Now you can try out the Disqus comment system live on the site right now. There is no doubt that Disqus provides an amazing commenting  system to increased interaction of your website community.

4 comments on “How to Fix WordPress Export, Disqus Import Comments Errors

  1. Make a form says:

    Web forms are quite easy to explain through tutorial. But, Whenever you going through the whole details then its quite tough challenge for you as well.

  2. Awais says:

    I also got error using wordpress export tool. Please tell me is this tool is fix in latest wordpress version.

  3. stalyn says:

    I will try to do this. Hopefully it will work for me.

  4. Shruti says:

    Hey ! I just installed Disqus on my WordPress site; but i’m fairly disappointed to see that Disqus doesn’t recognize my old comments : all my older comments are marked as posted by a guest. Did I miss a step ? Is there a way to have my old comments linked to my Disqus profile ? (my Disqus user mail is the exact same as my wordpress admin-user email, I would have thought it would have been automaticly recognized).

Leave a Reply

Your email address will not be published. Required fields are marked *

*