If you are planning to upgrade to PHP 5.3 from PHP 5.2.x then you must think twice before you really do it. There are few things you should take care of. Recently last week I tried upgrading one of the web-server to PHP 5.3 from PHP 5.2.9 and it was not a good idea which I came to know later on.
It is not only about deprecated functions which are creating Warnings or Notices but TCPDF library for generating PDF has created some wired problems due to which I have to roll back to the older version, as it was one of the crucial functionality of the application. It was not a planned version upgrade but it was a server migration and on the fly I tried upgrading PHP version also.
There are many functions and some of php.ini parameters which are deprecated, for complete list please refer http://www.php.net/manual/de/migration53.deprecated.php.
You can’t pass parameter while overriding “magic methods”; so if you ever had your __toString() method overridden with __toString($device = ‘SCREEN’) then it won’t work with PHP5.3. Other than that date_default_timezone() or similar timezone setup function also had some problems.
// This won't work with PHP5.3 and will work with 5.x public function __tostring($device = "SCREEN") { ... } // This will work with PHP5.3 and 5.x public function __tostring() { ... }
So crux is if your applications are not ready for PHP5.3 it is not wise decision to upgrade and if you have to upgrade we should make sure to test whole application and all functionalities as with large development teams sometimes you never know who has used what all the time.
Pingback: Upgrading to bPHP/b 5.3..! - are you sure?you | BLOGS@DiGiTSS
#1 by Giorgio Sironi on September 29, 2009 - 11:59 pm
Quote
Of course you should test extensively your application before kumping on 5.3. If you have an automated test suite in place this will be easy.
Pingback: BiGiTSS Blog: Upgrading to PHP 5.3..! ‘” are you sure? | Webs Developer
#2 by Andrew Thompson on October 1, 2009 - 4:45 am
Quote
I can't see having deprecated warnings as being a negative factor. You can disable the logging of them, and you shouldn't be displaying errors at all on a live site.
As for the datetime problem, that can be solved by setting the datetime.timezone setting.
Overriding magic methods with parameters is also not a good idea, you aren't using them properly if you think you should add parameters. As for your your example, you should have used a toString function which calls __toString if having default arguments.
However, yes, other than that there is one issue I've found with upgrading to php 5.3. the use of references and call_user_func*. This is a big problem in some Drupal 6 modules, which use references a lot in its hooks. They are trying to keep it working for the very outdated PHP 4 still as well.
#3 by Jonathan on October 1, 2009 - 7:37 pm
Quote
Well that's just a bad experience you had , does not mean you shouldn't consider upgrading to 5.3.
For starters it is not true that "magic methods" do not accept arguments , it is merely the _toString() magic method which I do not see having a real need for arguments , should you choose to pass an argument to symbolize a certain format the _toString() should operate on you can set that prior to calling the function with a class variable.
I believe that upgrading to 5.3 is mainly important when developing new applications since you would mainly use new features suggested like advanced OOP techniques and name spacing , should you choose to upgrade your application from 5.2.9 to 5.3 consider upgrading your code to use more advanced techniques and not just standing in compliance with the new 5.3 changes , though I admit that 5.3 brings many changes that break existing code in most cases I still see it as a vital stage in application development , PHP is taking a new direction and it would be wise to follow it
Most problems could be solved by going through:
http://www.php.net/manual/de/migration53.php
alas regarding external extensions like that one for PDF I have nothing to offer.
Put in the extra effort , it is important to stay with the curve and utilize as much as you can from what 5.3 has to offer!
#4 by Dharmavirsinh Jhala on October 10, 2009 - 4:34 pm
Quote
Yes @Andrew I understand that deprecated warnings are not a negative factor but it's just an indication that future versions won't support this; so must be taken care now. I understand that Productions will be having display_error turned Off, but it always keeps bugging while you see them during development, so we better fix them.
Another thing is I understand that overriding magic methods like __toString is not a good idea and right way but PHP has some openness which has allowed us as programmers go the non-standard way and it's now good that going ahead we are stopping some of this bad practices by letting this go.
@Jonathan thanks for updates.
#5 by Michael Brown on November 1, 2009 - 10:59 pm
Quote
In next spring will come two very important distro: RHEL 6 and Ubuntu 10.04. Both are LTS enabled.
This PHP new version is singularity. Where is PHP 5.3.1 ?
Bad syncronisation…
Pingback: Is it worth upgrading PHP 5.2 to 5.3? - Quora