From 27c046a2a0d129bf87821549c65eb48353aeb9cc Mon Sep 17 00:00:00 2001 From: ischommer Date: Thu, 19 Nov 2009 19:45:12 +0000 Subject: [PATCH] BUGFIX #4356 Removed string checking of PHP version and replaced with version_compare() in SS installer (from r81646) git-svn-id: svn://svn.silverstripe.com/silverstripe/open/phpinstaller/trunk@92248 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- install.php | 47 ++++++++++++++++++++++++++++------------------- 1 file changed, 28 insertions(+), 19 deletions(-) diff --git a/install.php b/install.php index f0db09e..4b00199 100644 --- a/install.php +++ b/install.php @@ -332,33 +332,42 @@ class InstallRequirements { else return true; } + function requireNoClasses($classNames, $testDetails) { + $this->testing($testDetails); + $badClasses = array(); + foreach($classNames as $className) { + if(class_exists($className)) $badClasses[] = $className; + } + if($badClasses) { + $testDetails[2] .= ". The following classes are at fault: " . implode(', ', $badClasses); + $this->error($testDetails); + } + else return true; + } + function requirePHPVersion($recommendedVersion, $requiredVersion, $testDetails) { $this->testing($testDetails); - list($recA, $recB, $recC) = explode('.', $recommendedVersion); - list($reqA, $reqB, $reqC) = explode('.', $requiredVersion); - list($a, $b, $c) = explode('.', phpversion()); - $c = ereg_replace('-.*$','',$c); + $installedVersion = phpversion(); - if($a > $recA || ($a == $recA && $b > $recB) || ($a == $reqA && $b == $reqB && $c >= $reqC)) { - $testDetails[2] = "SilverStripe recommends PHP version $recommendedVersion or later, only $a.$b.$c is installed. While SilverStripe should run, you may run into issues, and future versions of SilverStripe may require a later version. Upgrading PHP is recommended."; + if(version_compare($installedVersion, $requiredVersion, '<')) { + $testDetails[2] = "SilverStripe requires PHP version $requiredVersion or later.\n + PHP version $installedVersion is currently installed.\n + While SilverStripe requires at least PHP version $requiredVersion, upgrading to $recommendedVersion or later is recommended.\n + If you are installing SilverStripe on a shared web server, please ask your web hosting provider to upgrade PHP for you."; + $this->error($testDetails); + return; + } + + if(version_compare($installedVersion, $recommendedVersion, '<')) { + $testDetails[2] = "PHP version $installedVersion is currently installed.\n + Upgrading to at least PHP version $recommendedVersion is recommended.\n + SilverStripe should run, but you may run into issues. Future releases may require a later version of PHP.\n"; $this->warning($testDetails); return; } - if($a > $reqA) return true; - if($a == $reqA && $b > $reqB) return true; - if($a == $reqA && $b == $reqB && $c >= $reqC) return true; - - if(!$testDetails[2]) { - if($a < $reqA) { - $testDetails[2] = "You need PHP version $version or later, only $a.$b.$c is installed. Unfortunately PHP$a and PHP$reqA have some incompatabilities, so if you are on a your web-host may need to move you to a different server. Some software doesn't work with PHP5 and so upgrading a shared server could be problematic."; - } else { - $testDetails[2] = "You need PHP version $requiredVersion or later, only $a.$b.$c is installed. Please upgrade your server, or ask your web-host to do so."; - } - } - - $this->error($testDetails); + return true; } function requireFile($filename, $testDetails) {