1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

XF 1.5 Importing Orphaned Attachments

Discussion in 'Installation, Upgrade, and Import Support' started by adamsmasher, Sep 8, 2015.

  1. adamsmasher

    adamsmasher Active Member

    Is there a way to import orphaned attachments from vBulletin 4? We have images that are included using the URL of the attached image in posts other than the one they were originally uploaded to. vBulletin doesn't care that these were deleted from the original post, but they're lost on import because they have no post ID so are broken in XF.

    Or at least that's what I think is happening. :p

    I thought about giving any attachment with no post ID a post ID and seeing what happens on a fresh import, but I was wondering if there's a way to import these separately.

    Thanks for any insight!
     
  2. Mike

    Mike XenForo Developer Staff Member

    If the attachment is actually orphaned, there wouldn't be a way to import them; conceptually, attachments have to be connected to content as they inherit permissions from the content. I can't see an obvious way of working around this.
     
  3. adamsmasher

    adamsmasher Active Member

    To be honest, I'm assuming that it's orphaned since there's no attachment by the same ID in XF that was in vb (I kept IDs the same on import). I might be misunderstanding what orphaned means in this case.

    I considered making a post in a protected forum to get a post ID, then adding that to any image in the vb attachment table that lacks a post ID. I'm not sure if that would matter though.
     
  4. Mike

    Mike XenForo Developer Staff Member

    Aside from the attached content not being found, the only other reason for an attachment to not be imported is if the file wasn't found. That doesn't seem totally likely, but it's possible. Orphaning seems more likely, but I'm not sure.

    If you did attach them to a post in a private forum, that wouldn't strictly solve the problem as they would still respect the permissions from that forum (so you'd have to make it viewable at least).
     
  5. adamsmasher

    adamsmasher Active Member

    That makes sense. They're in this state because of changes I made; basically the posts the images are on used to be "articles" in vb4's CMS system, and we turned that off and moved them into other forums. The reduced screen area of forum posts vs articles meant that many of the post layouts didn't work so well, so I made a custom BBCode tag to give us more control where xxx is an integer specifying width:

    Code:
    [ATTACHIMG=xxx]http://www.tonymacx86.com/attachment.php?attachmentid=xxxxxx[/ATTACHIMG]
    Basically the allowed me to do a find/replace of the raw code of the post and change instances of [ attach ] xxxxxx [ /attach] to the format above, then tweak values for each so everything looked good.

    In XF I made a custom BBCode with PHP callback to change the URL format to match XF attachment structure, and that works fine. This is also fortunately limited to a set of official site posts and not user posts, since I didn't add an icon to CKEditor and it was really only used for the posts mentioned above. Not that I know exactly which posts at this point, lol. :oops::LOL:
     
  6. adamsmasher

    adamsmasher Active Member

    A bit of followup...

    As it turned out, the attachments weren't orphaned- or at least not in vB. In vB, the attachments all had a contentid of 24 (articles), whereas everything that was imported had a contentid of 1 (posts). This made sense since while we might have moved the posts out of the original forum used for articles, they were still originally created as such. It also made sense why they weren't imported because they weren't recognized as post attachments, or at least that's my theory and I'm going to run with that. :p

    Anyway, I nuked the test db and did a fresh import, only this time I installed this add-on beforehand:

    https://xenforo.com/community/resources/vbulletin-4-cms-importer-by-waindigo.2889/

    It's not maintained, though it worked fine for importing all of the article attachments separately after posts and attachments had been imported by native XF. Success!
     
    Last edited: Sep 11, 2015

Share This Page