Fixed  problems importing from smf over vb

principia

Well-known member
i try to import a smf forum over vb to xf.
the converting to vb has gone, but when i try to import to xf i get an error:

server_error.webp

while importing thread and posts.

error details:
preg_match_all() [<a href='function.preg-match-all'>function.preg-match-all</a>]: Compilation failed: unrecognized character after (?&lt; at offset 17 - library/XenForo/Importer/vBulletin.php:1943

#0 /home/www/web197/html/forum/library/XenForo/Importer/vBulletin.php(1943): XenForo_Application::handlePhpError('/\
("|'|)...' said:
Antw:08-Buil...', NULL, 2) #1 /home/www/web197/html/forum/library/XenForo/Importer/Abstract.php(77): XenForo_Importer_vBulletin->stepThreads(43, Array) #2 /home/www/web197/html/forum/library/XenForo/ControllerAdmin/Import.php(166): XenForo_Importer_Abstract->runStep(Object(XenForo_ControllerAdmin_Import), Object(XenForo_ImportSession), 'threads', 43, Array) #3 /home/www/web197/html/forum/library/XenForo/ControllerAdmin/Import.php(118): XenForo_ControllerAdmin_Import->_runStep(Object(XenForo_Importer_vBulletin), Object(XenForo_ImportSession), 'threads', 43, Array) #4 /home/www/web197/html/forum/library/XenForo/FrontController.php(310): XenForo_ControllerAdmin_Import->actionImport() #5 /home/www/web197/html/forum/library/XenForo/FrontController.php(132): XenForo_FrontController->dispatch(Object(XenForo_RouteMatch)) #6 /home/www/web197/html/forum/admin.php(13): XenForo_FrontController->run() #7 {main}

any tips?
 
Line 1943 is:

Code:
if (preg_match_all('/\[quote=("|\'|)(?<username>[^;]*);\s*(?<postid>\d+)\s*\1\]/siU', $post['pagetext'], $quotes, PREG_SET_ORDER))

I am not a regex guru, but I did some searching and found a possible explanation and a possible fix. I recommend waiting for Mike to respond to this thread before you try anything, but here is what I found:

1) I found a possible explanation:

http://www.rockettheme.com/forum/index.php?f=211&t=80945&rb_v=viewtopic

I've found that some versions of PHP only supports the (?P<name>) syntax for named subpatterns

What version of PHP are you running? Make sure your server meets the requirements by running this test script:

http://xenforo.com/xenforo-requirements-test.zip

2) And I found a possible fix (add the P extension to the code):

http://www.vbprogarage.com/forums/showthread.php/1056-function.preg-match-all-Compilation-failed
http://www.rockettheme.com/forum/index.php?f=211&t=80945&rb_v=viewtopic

Edit this file:

library/XenForo/Importer/vBulletin.php

Replace this:

Code:
if (preg_match_all('/\[quote=("|\'|)(?<username>[^;]*);\s*(?<postid>\d+)\s*\1\]/siU', $post['pagetext'], $quotes, PREG_SET_ORDER))

with this:

Code:
if (preg_match_all('/\[quote=("|\'|)(?P<username>[^;]*);\s*(?P<postid>\d+)\s*\1\]/siU', $post['pagetext'], $quotes, PREG_SET_ORDER))

This is untested. Like I said, wait for Mike to respond. He's the regex guy.
 
Here is all the stuff I found:

http://www.vbprogarage.com/forums/showthread.php/1056-function.preg-match-all-Compilation-failed

Re: [function.preg-match-all]: Compilation failed

A few lines above that one you will see

Code:

$pattern = '#(?<browser>' . join('|', $known) . ')[/ ]+(?<version>[0-9]+(?:\.[0-9]+)?)#';

try replacing it with

Code:

$pattern = '#(?P<browser>' . join('|', $known) . ')[/ ]+(?P<version>[0-9]+(?:\.[0-9]+)?)#';

I think that's how it was fixed before

http://www.rockettheme.com/forum/index.php?f=211&t=80945&rb_v=viewtopic

As scott W suggested this seems to be a PHP issue. I've found that some versions of PHP only supports the (?P<name>) syntax for named subpatterns which I think RokGZip is using in this line:

Line number On/Off | Expand/Contract | Select all

1.
2. $standalones_pattern = '/<!--\[if.*\]>(?<content>.*)<!\[endif\]-->/isU';
3.



I changed that line to to add the missing P, so it's now:

Line number On/Off | Expand/Contract | Select all

1.
2. $standalones_pattern = '/<!--\[if.*\]>(?P<content>.*)<!\[endif\]-->/isU';
3.



Now, I don't get the compilation warning when compiling the reg expression. However, my template still breaks :(

My server info is:

Joomla 1.5.14
RokGZipper 1.7
PHP: 5.1.2
Template: Solar Sentinel

What worries me is that this seems to be an issue since some time ago, users has been posting their configurations but we haven't seen any comment from the developer team.

I hope what I have found helps us to solve the problem but at this stage we need some help from the developers ...

http://docs.python.org/library/re.html

(?...)
This is an extension notation (a '?' following a '(' is not meaningful otherwise). The first character after the '?' determines what the meaning and further syntax of the construct is. Extensions usually do not create a new group; (?P<name>...) is the only exception to this rule. Following are the currently supported extensions.

...

(?P<name>...)

Similar to regular parentheses, but the substring matched by the group is accessible within the rest of the regular expression via the symbolic group name name. Group names must be valid Python identifiers, and each group name must be defined only once within a regular expression. A symbolic group is also a numbered group, just as if the group were not named. So the group named id in the example below can also be referenced as the numbered group 1.

For example, if the pattern is (?P<id>[a-zA-Z_]\w*), the group can be referenced by its name in arguments to methods of match objects, such as m.group('id') or m.end('id'), and also by name in the regular expression itself (using (?P=id)) and replacement text given to .sub() (using \g<id>).

...
 
thanks very much. i will look at it tomorrow.

my server is ok with xf and meet the requirements. xf is still running there with no problems.
only the import doesnt work.

intersting is, that importing from smf to vb runs without any error. all threads and posts are there.
 
Jake is likely right - it might be a particular PCRE version. I'll move this to bugs for more investigation.
 
His vB import is strange.

his imported quotes look like:
Code:
[quote author=strwd link=topic=1015.msg44321#msg44321 date=1292790913]
Gruß[/quote]
instead of the normal vB quote:
Code:
[QUOTE=Username;PostId]foo[/quote]

thats why preg_match_all fails and throws an error

so you would only need to change the preg_match_all pattern and try to run the import
 
thats why preg_match_all fails and throws an error

so you would only need to change the preg_match_all pattern and try to run the import

The error is for the regex itself. It's saying the regex is invalid before it even tries to pattern match. That's the problem.
 
But it will still not work, because his smf => vB IMport didn't work correct

that's his quote
Code:
[quote author=strwd link=topic=1015.msg44321#msg44321 date=1292790913]
instead of the normal vb quote.
 
Well yeah. It won't match the regex so it won't do any replacement. But it shouldn't be generating this error message. The format of his quote tags has nothing to do with the error. He would still get this error if his forum used standard quote tags.
 
Did you convert SMF over ImpEx to vBulletin 3 or 4 ?
I always use 3, and SMF hasn't given me these issues yet.

Upon convert from SMF to vB to fix the quote stuff, you could use Kier his 'find/replace' plugin to make it 'vBulletin friendly'.
 
I have testet the fix from Jake (post #3) and -
IT works!!!!!!
freu.gif
Yippi.


So some things to do and i will convert to XF on Saturday next week.

Thanks to all helpful hands.
Thread can be closed.
 
Top Bottom