mlanthaler: Bugfix: Fixed bug "Fatal error: Access to undeclared static property: Controller::$db in ../sapphire/core/Object.php(282) : eval()'d code on line 1". Could be implemented better if we require support for PHP 5.1 because then we can avoid the exception by calling ReflectionClass::hasProperty() respectively ReflectionClass::getStaticPropertyValue() (http://www.php.net/manual/en/language.oop5.reflection.php).

(merged from branches/gsoc)


git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@41972 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Ingo Schommer 2007-09-16 00:19:54 +00:00
parent 7be8460917
commit 9b75ec925a

View File

@ -304,7 +304,14 @@ class Object {
// Copy a built-in value into our own array cache. PHP's static variable support is shit.
if($builtIn) {
$val = $this->stat($name);
$val2 = eval("return " . get_parent_class($this) . "::\$$name;");
$val2 = null;
try {
$reflection = new ReflectionClass(get_parent_class($this));
$property = $reflection->getProperty($name);
$val2 = $property->getValue();
} catch(Exception $exc) {
// do nothing.. the property doesn't exists!
}
return ($val != $val2) ? $val : null;
}