phusion / juvia

A commenting server similar to Disqus and IntenseDebate.
http://phusion.github.io/juvia/
GNU Affero General Public License v3.0
1.03k stars 94 forks source link

importing of comments from Wordpress fails when there is a "Pages menu" #24

Open Krastanov opened 11 years ago

Krastanov commented 11 years ago

On trying to import I get the following error page:

The change you wanted was rejected.

Maybe you tried to change something you didn't have access to.

The console reports this:

Started POST "/admin/comments/import" for 140.***.***.*** at 2013-03-12 19:47:14 +0000
  Processing by Admin::CommentsController#import as HTML
  Parameters: {"utf8"=>"✓", "authenticity_token"=>"54eY6xe8t1gZUhyKCeH9IQ81aPetyjwieLmau2EeYXU=", "site_id"=>"1", "import_type"=>"Word Press", "database_host"=>"localhost", "database_name"=>"wordpress", "database_user"=>"root", "database_password"=>"[FILTERED]", "commit"=>"Import"}
Completed 422 Unprocessable Entity in 119ms

ActiveRecord::RecordInvalid (Validation failed: Title can't be blank):
  app/models/topic.rb:31:in `lookup_or_create'
  lib/juvia/migrators/word_press.rb:140:in `process_post'
  lib/juvia/migrators/word_press.rb:120:in `block in process'
  lib/juvia/migrators/word_press.rb:119:in `process'
  lib/juvia/migrators.rb:13:in `process'
  app/controllers/admin/comments_controller.rb:68:in `import'

cache: [POST /admin/comments/import] invalidate, pass

The first 11 comments are nonetheless successfully imported. I trashed them in wordpress and tried again. The same failure, and no new comments transfered. Then I trashed the rest of the comments one by one in wordpress. The same failure. Even when I have no more comments in wordpress (i.e. all of them are in the trash folder) I get the same error.

I can provide a wordpress xml dump for testing.

Any suggestions?

EDIT: see below for a workaround.

JangoSteve commented 11 years ago

It sounds like you're trying to import a comment for a post which doesn't have a title, which is invalid in Juvia (and I'm not sure how it's valid in WordPress).

Krastanov commented 11 years ago

I suspected something like this, so I removed all drafts without titles (only drafts were like this and they did not contain any comments obviously), however it continues to fail in the same way with the same error message.

Krastanov commented 11 years ago

For some reason, completely unknown to me, removing all nav_bar_items from wp_posts made it work. They definitely have title though...

Krastanov commented 11 years ago

So here is my workaround.

In Wordpress' control panel: Appearance->Menus: remove the "Pages" menu. This removes all post_type=nav_bar_item from wp_posts. Now the import should work.

I do not know why this happens, but I believe a fix for this would be to blacklist nav_bar_item from def self.process_post(post, db, options) in lib/juvia/migrators/word_press.rb.

Krastanov commented 11 years ago

By the way the workaround does not remove these pages (i.e. topics), just the references to them for the navbar. And at least some of these pages do not contain comments at all, but when in the navbar still cause problems.