XF 1.4 Importing vBulletin post thanks to XenForo likes

danger@

Member
Hello,

we have gone through a conversion (not direct) from vB 3.7 to phpBB and lately we have moved to XenForo. The thing is that when we were on vB, we had installed an addon 'post thanks' which allowed users to give thanks to a post if they liked it. We didn't have a similar feature when we were on phpBB, however XF has 'likes'. Since we have our vB database still around, I decided to import the 'thanks' into XF likes system. I wrote a simple script that added all the data to xf_liked_content table. Unfortunately, adding the data to this table does not seem to be sufficient, because a) the user info 'likes received' doesn't seem to reflect the new count, and also the posts does not seem to reflect the info about likes received. I suspect it's cached somewhere somehow... Do I need to update some other fields, during the import? Or should I rebuild some caches? Thanks!
 
@Brogan yes I have seen some importer addons, but they only work during the actual import is being done. I couldn't fine anything sufficient, since we have imported from phpBB and we actually want to import the older thanks data form vB.
 
https://xenforo.com/community/resources/*******-post-thanks-importer.2852/

Does that not do it?

If not, look at the code to see what tables are involved and that will give you some guidance.
 
If anyone would ever be interested in my import code, here it is (note I am not a PHP coder):

PHP:
<?php

$DBServer = ''; // e.g 'localhost' or '192.168.1.100'
$DBUser   = '';
$DBPass   = '';
$DBName_xf= ''; // XenForo database name
$DBName_vb= ''; // vBulletin database name

$conn = new mysqli($DBServer, $DBUser, $DBPass, $DBName_vb);

if ($conn->connect_error) {
  exit('Database connection failed: '  . $conn->connect_error, E_USER_ERROR);
}

$sql='SELECT pt.*, post.userid as content_userid, post.title as title, post.pagetext as text
        FROM post_thanks AS pt
        LEFT JOIN post AS post USING (postid)
        ORDER BY pt.id';
$rs=$conn->query($sql);
if($rs === false) {
     exit('Wrong SQL: ' . $sql . ' Error: ' . $conn->error, E_USER_ERROR);
}

$rows_returned = $rs->num_rows;
print "vbulletin rows: $rows_returned\n";

$post_thanks = $rs->fetch_all(MYSQLI_ASSOC);
$rs->free();

/*
foreach($post_thanks as $row) {
   echo "userid: {$row['userid']} - date: {$row['date']} - postid: {$row['postid']} - content_userid: {$row['content_userid']} - title: {$row['title']}\n";
}
*/

$conn->select_db($DBName_xf);

/*
$sql='SELECT * FROM xf_liked_content';

$rs=$conn->query($sql);

if($rs === false) {
        exit('Wrong SQL: ' . $sql . ' Error: ' . $conn->error, E_USER_ERROR);
}

$rows_returned = $rs->num_rows;
print "xenforo rows: $rows_returned\n";

$likes = $rs->fetch_all(MYSQLI_ASSOC);
$rs->free();

foreach($likes as $row) {
      echo "content_type: {$row['content_type']} - content_id: {$row['content_id']} - like_user_id: {$row['like_user_id']} - date: {$row['like_date']}\n";
}
*/

$sql='INSERT INTO xf_liked_content (content_type, content_id, like_user_id, like_date, content_user_id) VALUES (?,?,?,?,?)';
$stmt = $conn->prepare($sql);
if($stmt === false) {
     exit('Wrong SQL: ' . $sql . ' Error: ' . $conn->error, E_USER_ERROR);
}

$content_type = 'post';
foreach($post_thanks as $row) {
   /* Bind parameters. TYpes: s = string, i = integer, d = double,  b = blob */
   $stmt->bind_param('siiii', $content_type, $row['postid'], $row['userid'], $row['date'], $row['content_userid']);
   $stmt->execute();
   echo "insert_id: {$stmt->insert_id}, affected_rows: {$stmt->affected_rows}\n";
}
$stmt->close();

echo "finished.\n";
$conn->close();

?>

Copy it to the server and run it from your terminal. Then run the script quoted above.
 
Top Bottom