Pregunta

I am looking to upgrade a large PHP website from 5.2 to 5.3 and potentially beyond afterwards.

The inherited codebase I am working on is very large, 800,000+ lines of code, and for the most part looking at the backwards incompatible changes list (http://php.net/manual/en/migration53.incompatible.php) most of these issues can be easily searched for using string searches of the code but others (such as the by-reference and the API changes ones) are harder to search for. I have used codesniffer to try an identify broken areas of code but codesniffer does not seem to find everything (such as the by-reference and API issues are not found for example).

Essentially, what I am after is a way to easily identify affected code which codesniffer may have missed without having to run all of the code or read all of the code. Is there a tool which can essentially scan the code and tell me the problem areas and save me weeks/months of time?

Any ideas? I forgot to mention that we use IIS/Windows if this matters.

¿Fue útil?

Solución

Most of the explicitly backward-incompatible issues (as listed on the page you linked) are fairly easy to find, by hunting for the specific functions mentioned on that page. It's a relatively short list, and the changes are all fairly specific. It's not hard to navigate through them, even in a big code-base, and most of the changes listed are edge cases anyway, so hopefully you won't have too much to worry about from that list.

The bigger problem is with the list of features that was deprecated in 5.3. This includes the pass-by-reference feature you mentioned in the question.

Some of these features are difficult to find just by hunting through code, especially for a large code base, and if the code has been around for a while, the odds are very high that you'll fall foul of at least some of them.

The good news is that you can safely run your code in 5.3 without touching the deprecated features. The features are deprecated; that means they've been marked as being bad, but they haven't actually been removed from the language yet (that comes in 5.4 for most of them), so with regards to these features your software will still run exactly as it did before, except that it will throw warning messages.

So the best way to find all these things in your code is simply to upgrade to 5.3, run your code, and catch all the warnings that come out in your error log.

Obviously, you'll need to run fairly exhaustive tests in order to be sure you've found everything, but that's not necessarily a bad thing - in fact frankly, you'd be a fool not to do that anyway if you're upgrading the language version for a system of that size. Perhaps you could use this as an opportunity to start writing those test scripts that you've not managed to get around to yet.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top