Home » Database » DB_DataObject » Bug #3201
get* and set* no longer work on private, public and protected class variables
Details
| Submitted | 2005-01-14 15:30 UTC |
|---|---|
| From | bigtree at 29a dot nl |
| Assigned | alan_k |
| Status | Closed |
| Package | DB_DataObject |
| PHP Version | 5.0.3 |
| OS | irrelevant |
| Roadmaps | (Not assigned) |
Comments
[2005-01-14 15:30 UTC] bigtree at 29a dot nl
Description:
------------
As of php 5.0.3, the function get_class_vars() was changed so that it doesn't return private, protected (and maybe also public) class variables. This function is used by the DB_DataObject's _call method to determine whether the requested field actually exists.
If one uses protected variables in an extended class of DB_DataObject (private wouldn't work because of the extension) and only use get* and set* to insure data integrity, this will stop working.
Reproduce code:
---------------
<?php
class Person Extends DB_DataObject {
public $__table = 'persontable';
protected $id;
}
$myPerson = new Person();
echo $myPerson->setid(1) ? 'ok' : 'not ok';
?>
Using PHP 5 (up to 5.0.2), this would work, but in order for it to work as of 5.0.3, I recommend changing line 3142 of DataObject (1.7.2) from:
<?php
$array = array_keys(get_class_vars($class));
?>
to
<?php
$array = array_keys(get_object_vars($this));
?>