Click here to get back home

Migration to PHP5: Update PHP4 code: Recognizer or similar available?

 HomeNewsGroups | Search

comp.lang.php - PHP programming language discussions 

get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
Migration to PHP5: Update PHP4 code: Recognizer or similar available? Daniela Waranie 05-11-2009
Posted by Daniela Waranie on May 11, 2009, 4:55 am
Please log in for more thread options
Hi all,

i have to update a web application (100.000 code lines), that was not
developed by me (!) to make it run on PHP5.

Is there a script / recognizer available that search all the folders /
files for 'no longer available' pieces:
a) variables (e.g. HTTP_GET_VARS, etc.)
b) functions (e.g. ibase_fmtdate())
c) multiple includes (e.g. include, etc.)
d) changed behaviours (e.g. other parameters for array_merge, etc.)
e) changed return / case sensitive (e.g. sttrtolower(), __CLASS__,
ip2long(), etc.)
f) new reserved words
h) do i forgot something?

and replace (where possible) with a PHP5-equivalant and give me a 'to do
list' for the rest.

There are no unit tests available to ensure continuing behavior - worse
luck!

Please give me all hints that could help me to get fast and good results.

Thanks in advance
Best regards
Daniela Waranie

Posted by =?ISO-8859-1?Q?=22j=2Eke=DFler on May 11, 2009, 8:48 am
Please log in for more thread options
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Daniela Waranie wrote:
show/hide quoted text
Hello there,

this is already a nice list.

But you can't do this automatically. Eg run some search replace over it.
Ok in some cases you can do but not for all.
Some global replace could and will destroy the code on some places.

So you must really be carefull and do it step by step and by hand. You can't
avoid testing the whole stuff step by step to make sure it is working as it
should.

also increase the error reporting level to catch all the errors and fix the
errors as they come.


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkoIHocACgkQE++2Zdc7EtdRqQCggWIIF0Fv2CkbkzHsuYBhZwDI
ccgAn1b4abE7sK5M0EEfiSyNlDIYtQt5
=JNGq
-----END PGP SIGNATURE-----

Posted by Jerry Stuckle on May 11, 2009, 11:08 am
Please log in for more thread options
Daniela Waranie wrote:
show/hide quoted text

In addition, I would highly recommend you install a versioning control
system (I use Subversion). It will help you immensely when you make a
mistake and want to go back to a previous version of the code.

When I do something like this, I first version the original code. Then
I take one parameter (i.e. $HTTP_GET_VARS) and search all of the files
for it (I use Crimson Editor on Windows, vim and grep on Linux).
Replace as necessary (I agree - do it manually, not a global
search/replace and check the code as you go) and go to the next one.

Your biggest problem is likely to be if register_globals and/or
magic_quotes_gpc was/were enabled on the old system (common in older
code). This will take some work.

Also, if register_globals is enabled, you will probably have some
problems with session variables also. Use the newer $_SESSION array
instead of the old session_register() call.

Of course, if the code was well-written for PHP 4.1 or later, these
problems may not occur - in which case I would suspect your conversion
will be quick and easy.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

Posted by "lvaro G. Vic on May 11, 2009, 11:34 am
Please log in for more thread options
Daniela Waranie escribió:
show/hide quoted text

There's a PEAR package that can scan your code and provide you with a
preliminary list:

http://pear.php.net/package/PHP_CompatInfo

You can use its command line tools or write a little script.

However, it can't really detect important stuff like dependence on
register_globals and the like.



--
-- http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
-- Mi sitio sobre programación web: http://borrame.com
-- Mi web de humor satinado: http://www.demogracia.com
--

Similar ThreadsPosted
function similar to filter_var() in php4.3 ? May 12, 2007, 2:36 am
Using PHP4 or PHP5 October 2, 2004, 2:12 pm
PHP4 Dom XML to PHP5 XML August 3, 2005, 11:27 pm
PHP4 Dom XML to PHP5 XML August 11, 2005, 3:14 pm
PHP4 to PHP5 July 19, 2008, 4:41 pm
XML package for PHP4 and PHP5 September 16, 2004, 1:47 am
PHP4 PHP5 under Apache 2.0 December 29, 2004, 2:38 pm
PHP4 + PHP5 + ZendStudio January 16, 2005, 1:29 pm
mail() different php4 <-> php5 May 31, 2005, 10:35 am
PHP4+PHP5+Apache 1 July 13, 2005, 7:07 am

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Driving a better car - Fuelzilla.com

Cabling site for homeowners and pros alike - Cabling-Design.com

Friends:

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap
Privacy Policy