News:

Wondering if this will always be free?  See why free is better.

Main Menu

Error when invoking converter from CLI

Started by Amedee, September 19, 2008, 04:42:07 AM

Previous topic - Next topic

Amedee

Hello!

I am working on a migration of a 350 000 posts board, and this is no secret, the bigger the board is the worse is the performance.

Since I am re-doing the migration on a regular basis for user-acceptance, I was looking for some speed improvement and I discovered in this section that we now have a CLI enabled converter, which is very convenient as it can be run as script directly on the server.

So far so good...
... except that my conversion isn't running anymore as it should through the CLI  :'(

After some time, some headache and a lot of coffee, I eventually discovered a flawn in the converter (I am using the converter dowloaded here)

927                 else
928                 {
929                     if (eval($current_data) === false && !$command_line)
930                         echo '
931             <b>Error in convert script ', $_SESSION['convert_script'], ' on line ', $line_number, '!</b><br />';
932                     elseif (eval($current_data) === false && $command_line)
933                         print_line('Error in convert script ' . $_SESSION['convert_script'] . ' on line ' . $line_number . $endl);
934                 }


This is basically wrong: the 'eval' should not be in the CLI test, because the code is evaluated 2 times in the case of the CLI.
(This part of the code handles the '---{ / ---}' scripts so you end up in running migration steps 2 times)

A correct approach could be:
if (eval($current_data) === false)
    if (!$command_line)
        echo 'html stuff';
    else
        echo 'text stuff';



Regards

SleePy

#1
Well reversing the checks would actually be better since its just an and check if the first one is wrong it won't do the second.

I will change that in svn, which means it will be updated on the next release of SMF or the convert file (if that is needed).

The good news is with the 2.0 converter I am working on removing this need by doing some html removal checks and such. This should hopefully remove the need for both outputs.

Edit, I made the changes using a regex in my php editor :D Simple and fast.
Jeremy D ~ Site Team / SMF Developer ~ GitHub Profile ~ Join us on IRC @ Libera.chat/#smf ~ Support the SMF Support team!

Advertisement: