PDA

View Full Version : BBCode error after Impex transition


FrozenBlast13317
07 Apr 2017, 13:37
Hello I'm having issues with a migration. I recently moved from phpbb 3.0 to vBulletin 4.2.3.

The BBCodes from phpbb seem to be in the phpbb format. For example, I see [center:jfheidne] in many posts and such.

Would it be possible to prune these bbcodes or replace them with valid vBulletin bbcodes? Ideally I want to replace.

Dave
08 Apr 2017, 17:12
So in your example [center:jfheidne], jfheidne is the text that has to be centered?

FrozenBlast13317
08 Apr 2017, 18:41
For example,

Bbcodes would show with random letters after them. These letters vary each post even if its the same bbcode.

One code would show [s:kfbskdn]texthere[/s:kfbskdn] where is should be iust an S for strike. The issue here is that there are random letters after the bbcode value that were not here before.

I contacted vBulletin and they said I have to replace these values with vBulletin values.

Heres a post example (in phpbb 3.0 these were centered, but now the center bbcode in vBulletin shows as this:

[center:2lh05fwg]Hey everyone![/center:2lh05fwg][center:2lh05fwg]texthere[/center:2lh05fwg]

The only issue is the :randomcharacters. Anyway to mass remove these?

Looking for the right SQL query to execute, I think.

Dave
08 Apr 2017, 18:51
It's not going to be possible in a SQL query since MySQL doesn't have a regex replace function built-in but a PHP script is possible.

Create a PHP file in the root of your forum with the contents below and then visit it in the browser or execute it through the command line interface.

I recommend executing it against a test database first since I didn't test it.
Also if you have a very big database, it may timeout so you have to run it multiple times after the 360 seconds.
If there are more tags to fix that have the same formatting, change the $tagtofix variable in the script below.

<?php

require("./global.php");
set_time_limit(360);
$tagtofix = 'center';

$q = $vbulletin->db->query_read("SELECT postid, pagetext FROM " . TABLE_PREFIX ."post WHERE pagetext like '%" . $tagtofix . ":%'");

while($row = $vbulletin->db->fetch_assoc($q)){
$vbulletin->db->query_write("
UPDATE " . TABLE_PREFIX . "post
SET pagetext = '" . $vbulletin->db->escape_string(preg_replace("/" . $tagtofix . "\:(.+?)\]/im", $tagtofix . "]", $row['pagetext'])) . "'
WHERE postid = " . $row['postid']);
}

FrozenBlast13317
09 Apr 2017, 16:40
Hey Dave thanks for your reply. I tried executing your php theough browser and through command line, and it didn't have any effect (it did nothing apparently?).

Any ideas? Thanks, it's really appreciated as this is the last issue we have after our impex transfer.

MarkFL
09 Apr 2017, 16:45
Hey Dave.

Thanks for your reply. I tried executing your php theough browser and through command line, and it didn't have any effect (it did nothing apparently?).

Any ideas? Thanks, it's really appreciated as this is the last issue we have after our impex transfer.

Try editing one of the posts that doesn't appear to have been fixed...does the post appear to be fixed in the editor? If so, then this is a post caching issue.

FrozenBlast13317
09 Apr 2017, 17:32
Try editing one of the posts that doesn't appear to have been fixed...does the post appear to be fixed in the editor? If so, then this is a post caching issue.

Hey!

I tried editing one of the posts and the tag looks broken as it was before. I tried clearing post cache but that didn't work unfortunately. Thank you for posting.

--------------- Added 1491784121 at 1491784121 ---------------

Just wanted to update you Dave. It gives me a 500 server error when trying to run the code.

--------------- Added 1491786299 at 1491786299 ---------------

And here was the error code I received

PHP Strict Standards: Only variables should be passed by reference

--------------- Added 1491795338 at 1491795338 ---------------

And this has been solved. Thanks.

Dave
10 Apr 2017, 16:42
Glad you got it working, what was the mistake?

FrozenBlast13317
12 Apr 2017, 05:04
I fiddled with your code a bit but just couldn't seem to get it working. I'm not positive as to what the issue was - however, I managed to find the right replacement code to slap onto the cleaner tool in the impex system. Took a bit of digging. Thanks for all of your help guys.