Forum Moderators: coopster

Message Too Old, No Replies

Upgrade php4 -> php5 :: no risks?

will all scripts run as expected after upgrade?

         

majjk

9:00 am on Aug 11, 2008 (gmt 0)

10+ Year Member



I'm thinking of moving to php5 as I need some of the new functionality... and anyway, I can't stay with php4 forever as my host will gradually be moving everything to php5 within the near future.

So my question is... will all scripts run with no issues after an upgrade, or is there a chance that things will stop working?

If not everything will run under php5, is there an "easy" way to check my files for outdated code? Some kind of program to run that will scan files for code that won't run as expected... I have tons of scripts, so doing a manual check is simply not possible from a practical point of view.

vincevincevince

9:05 am on Aug 11, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Your host is overly lax and should not have permitted you to be using PHP4 today. It is now out of support; the last ever 4.4 version has been you are now without protection from any new exploits. Believe me, you don't want the hassle of fighting off hackers AND upgrading to PHP5 at the same time.

If your scripts were written in the last couple of years you are likely to be fine; but if your scripts are legacy scripts which were patched from PHP3 to work with PHP4 then you will probably have serious problems.

Many years ago, back in the mists of time, all programmers were instructed not to make use of automatically registered global variables in PHP; despite this there is still a lot of code which 'requires register_globals to be on'. To see if that's the case for you; test it by turning register_globals to off in your PHP4 installation. If things break; you'll never survive PHP5.

Pico_Train

9:30 am on Aug 11, 2008 (gmt 0)

10+ Year Member



WE made the move to PHP5 from PHP4 a while ago. It all went smoothly but I can't guarantee yours will as posted above by vvv.

I would do it locally first and test to see if things break. Fix and then go for it.

majjk

9:43 am on Aug 11, 2008 (gmt 0)

10+ Year Member



...but is there no way of doing a proper scan/test, rather than just upgrade and see what happens? It basically would require me to make sure I try out every single functionality there is in the scripts, and then hope that I spot any problems. It just seems a rather primitive way of verifying things...

vincevincevince

10:40 am on Aug 11, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Unfortunately, I am not aware of an automated testing system. Very few things break in modern code. Most changes will have been warned of in documentation previously released, or in notices issued in the error log.

gcarn

5:25 pm on Aug 11, 2008 (gmt 0)

10+ Year Member



I had a few glitches when i upgraded to 5
the one example that took me some time, was when I used the following code to comment a shorthand echo.

<?=//$var."Something";?>

the comment right after a shorthand echo made things error out on me.. no big deal.. but everything had to be updated (Loves Find and Replace All) :D

pinterface

10:55 pm on Aug 11, 2008 (gmt 0)

10+ Year Member



The best anyone is going to be able to tell you is "maybe". It really depends on your scripts.

Due to the Halting Problem or Turing Completeness or some fancy computer terminology like that, it is impossible to scan your PHP files to determine if they will work to an absolute certainty. Your best bet, as has been mentioned, is to put your scripts on a PHP5 server and try them out.

Having made the move from PHP4 to PHP5 myself, I can point you to the problems I had:

    $this munging no longer works in PHP5
      That is, if you do anything such as:
      class y { ... }
      class x { function x() { $this = new y(); } }
      $x = new x();

      PHP5 will complain. (In PHP4, $x was an object of class y.) It's a rather unfortunate loss of functionality, but oh well.

    function f () { array_shift($args = func_get_args()); }
    f(a, b, c);

      In PHP4, $args was [b, c]. In PHP5 it's [a, b, c]. This, as you might imagine, is a pesky little bugger to track down.

    Object Copying

      $ob1 = new O(...);
      // some $ob1->foo = bar; initialization
      $ob2 = $ob1; // make a copy!
      $ob1->setSomething("x");
      $ob2->setSomething("y");

      In PHP4, $ob1 and $ob2 were separate objects. In PHP5, they're identical objects, so $ob2->setSomething() also affects $ob1. Can be fixed by using the PHP5-specific clone operator [us.php.net]. (Be warned: clone only works on objects, so if $x can be either an object or an integer, you're in for trouble.)

Your problems may be different, but you would be well-advised to expect something will go wrong. Murphy's Law and all that.