It so happened that we tried to transfer some projects to 5.3 during the relocation of our collocated hosting, as a result a funny incompatibility was found at the level of bugs between 5.2 and 5.3.
The problem arose in the depths of our CMS, and, as it turned out, it has an amusing history.
')
So, there was a certain abstract class AbstractController. And he had several properties declared as private, as well as an implementation for supporting dynamic properties, in particular the
__get() method.
If you omit all the details, the situation can be described as:
abstract class AbstractController { private $layout = 'layout'; public function __get($property) { if (property_exists($this, $property)) return $this->$property; else throw new Exception("Missing property: $property"); } } class RealController { protected $action = 'action'; }
The
__get method in this case implements read-only access to individual fields.
Once, a programmer needed to read the
layout field for an instance of a derived class. Despite being private, he called
$controller->layout , and everything worked out! Not bad, the programmer thought, and such a wonderful feature. It was in version 5.2
That is, __get implemented in the parent class, was able to gain access to a private field, being called for an instance of the derived class.
We write:
$a = new RealController(); print $a->layout; print "\n"; print $a->action; print "\n";
Run in 5.2.10:
Result:
layout action
Technical progress stepped forward and the application was transferred to 5.3. We start and get (in 5.3.2):
action PHP Fatal error: Uncaught exception 'Exception' with message 'Missing property: layout' in /home/max/test.php:9 Stack trace: #0 /home/max/a.php(20): AbstractController->__get('layout') #1 {main} thrown in /home/max/test.php on line 9
That is, repaired.
UPDATE: the opposite is true! They did not fix it, but on the contrary broke it, namely the property_exists () function. Many thanks to the user LighteR for the corresponding comment. Screwed up, heat, brains melt.There are two morals here:
don’t go anywhere and write unit tests :)
I wonder how many shared-hosting support is now 5.3, and when the transition to this version will be massive.