# vBulletin 导入失败，导入 topics 时出错

**URL:** <https://meta.discourse.org/t/vbulletin-import-fails-on-import-topics/34683>\
**Category:** Migration\
**Tags:** vbulletin\
**Created:** [2015年十月19日 18:01 UTC](https://meta.discourse.org/t/vbulletin-import-fails-on-import-topics/34683 "2015-10-19T18:01:08Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mike\_Nielsen](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mike_nielsen/32/116911_2.png) [@Mike\_Nielsen](https://meta.discourse.org/u/Mike_Nielsen)\
**Post date:** [2015年十月19日 18:01 UTC](https://meta.discourse.org/t/vbulletin-import-fails-on-import-topics/34683/1 "2015-10-19T18:01:08Z")

</div>

Hey!

We are currently testing migration from vBulletin to Discourse and we’re moving our site which has over a decade of posts.

All users and groups have been migrated, but when the script hits “import\_topics”, this error fires:

```
importing topics...
vbulletin.rb:213:in `block (2 levels) in import_topics': undefined local variable or method `topic' for #<ImportScripts::VBulletin:0x007f6b33cc1e88> (NameError)
from /var/www/discourse/vendor/bundle/ruby/2.0.0/gems/rack-mini-profiler-0.9.7/lib/patches/db/mysql2.rb:6:in `each'
from /var/www/discourse/vendor/bundle/ruby/2.0.0/gems/rack-mini-profiler-0.9.7/lib/patches/db/mysql2.rb:6:in `each'
from vbulletin.rb:213:in `map'
from vbulletin.rb:213:in `block in import_topics'
from /var/www/discourse/script/import_scripts/base.rb:676:in `block in batches'
from /var/www/discourse/script/import_scripts/base.rb:675:in `loop'
from /var/www/discourse/script/import_scripts/base.rb:675:in `batches'
from vbulletin.rb:201:in `import_topics'
from vbulletin.rb:33:in `execute'
from /var/www/discourse/script/import_scripts/base.rb:45:in `perform'
from vbulletin.rb:563:in `<main>'

```

I’m not super familiar with Ruby, so I’m not even sure where it gets the ‘topic’ variable from as it does not seem to be defined anywhere but referenced in several places.

Thanks for your help 😄

---

<div class="post-metadata">

**Author:** ![gerhard](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gerhard/32/119479_2.png) [@gerhard](https://meta.discourse.org/u/gerhard)\
**Post date:** [2015年十月19日 18:08 UTC](https://meta.discourse.org/t/vbulletin-import-fails-on-import-topics/34683/2 "2015-10-19T18:08:32Z")

</div>

Looks like the importer needs some love. 😉

Change line 213 in `script/import_scripts/vbulletin.rb` to:

```ruby
next if all_records_exist? :posts, topics.map {|t| "thread-#{t["threadid"]}" }

```

---

<div class="post-metadata">

**Author:** ![JammyDodger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jammydodger/32/254611_2.png) [@JammyDodger](https://meta.discourse.org/u/JammyDodger)\
**Post date:** [2024年六月8日 12:45 UTC](https://meta.discourse.org/t/vbulletin-import-fails-on-import-topics/34683/3 "2024-06-08T12:45:57Z")

</div>

此主题已在 3154 天后自动关闭。不再允许回复。
