From f3d4cca46a1517fc2c0a7d19017e133cbc5167fd Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Tue, 27 Dec 2011 00:07:42 +0100 Subject: [PATCH] Fix: add function getStaticMember() for compatibility with PHP 5.2 --- htdocs/core/lib/functions.lib.php | 25 +++++++++++++++++++++++++ htdocs/install/fileconf.php | 4 ++-- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 5f1c193719e..bdaabfa0c2d 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -145,6 +145,31 @@ if (! function_exists('json_decode')) } } +/** + * Enter description here ... + * + * @param string $class + * @param string $member + * @return void + */ +function getStaticMember($class, $member) +{ + if (is_object($class)) $class = get_class($class); + $classObj = new ReflectionClass($class); + $result = null; + + foreach($classObj->getStaticProperties() as $prop => $value) + { + if($prop == $member) + { + $result = $value; + break; + } + } + + return $result; +} + /** * Return a DoliDB instance (database handler). diff --git a/htdocs/install/fileconf.php b/htdocs/install/fileconf.php index 9ac1f1eac7f..05f9a556d43 100644 --- a/htdocs/install/fileconf.php +++ b/htdocs/install/fileconf.php @@ -284,8 +284,8 @@ if (! empty($force_install_message)) include_once($dir."/".$file); // Version min of database - $versionbasemin=$class::$versionmin; - $note='('.$class::$label.' >= '.versiontostring($versionbasemin).')'; + $versionbasemin=getStaticMember($class, 'versionmin'); + $note='('.getStaticMember($class, 'label').' >= '.versiontostring($versionbasemin).')'; // Switch to mysql if mysqli is not present if ($defaultype=='mysqli' && !function_exists('mysqli_connect')) $defaultype = 'mysql';