From 14c079661774ca5e3e0509952cf285350652ba9a Mon Sep 17 00:00:00 2001 From: Andrew O'Neil Date: Wed, 18 Apr 2012 10:38:09 +1200 Subject: [PATCH 1/2] MINOR: Remove checks for PHP < 5.3.2, as it's no longer supported --- core/manifest/ClassManifest.php | 15 ++++++--------- security/RandomGenerator.php | 7 ++----- .../core/manifest/NamespacedClassManifestTest.php | 4 ---- .../manifest/TokenisedRegularExpressionTest.php | 6 ------ 4 files changed, 8 insertions(+), 24 deletions(-) diff --git a/core/manifest/ClassManifest.php b/core/manifest/ClassManifest.php index 7421cced6..468fe66f0 100644 --- a/core/manifest/ClassManifest.php +++ b/core/manifest/ClassManifest.php @@ -331,18 +331,15 @@ class SS_ClassManifest { if (!$classes) { $tokens = token_get_all($file); - if(version_compare(PHP_VERSION, '5.3', '>=')) { - $classes = self::get_namespaced_class_parser()->findAll($tokens); - $namespace = self::get_namespace_parser()->findAll($tokens); - if($namespace) { - $namespace = implode('', $namespace[0]['namespaceName']) . '\\'; - } else { - $namespace = ''; - } + + $classes = self::get_namespaced_class_parser()->findAll($tokens); + $namespace = self::get_namespace_parser()->findAll($tokens); + if($namespace) { + $namespace = implode('', $namespace[0]['namespaceName']) . '\\'; } else { - $classes = self::get_class_parser()->findAll($tokens); $namespace = ''; } + $interfaces = self::get_interface_parser()->findAll($tokens); $cache = array('classes' => $classes, 'interfaces' => $interfaces, 'namespace' => $namespace); diff --git a/security/RandomGenerator.php b/security/RandomGenerator.php index 8c92ff23e..ca0bf271c 100644 --- a/security/RandomGenerator.php +++ b/security/RandomGenerator.php @@ -21,11 +21,8 @@ class RandomGenerator { // TODO Fails with "Could not gather sufficient random data" on IIS, temporarily disabled on windows if(!$isWin) { - // mcrypt with urandom is only available on PHP 5.3 or newer - if(version_compare(PHP_VERSION, '5.3.0', '>=') && function_exists('mcrypt_create_iv')) { - $e = mcrypt_create_iv(64, MCRYPT_DEV_URANDOM); - if($e !== false) return $e; - } + $e = mcrypt_create_iv(64, MCRYPT_DEV_URANDOM); + if($e !== false) return $e; } // Fall back to SSL methods - may slow down execution by a few ms diff --git a/tests/core/manifest/NamespacedClassManifestTest.php b/tests/core/manifest/NamespacedClassManifestTest.php index 66ec092d4..7170f3792 100644 --- a/tests/core/manifest/NamespacedClassManifestTest.php +++ b/tests/core/manifest/NamespacedClassManifestTest.php @@ -13,10 +13,6 @@ class NamespacedClassManifestTest extends SapphireTest { public function setUp() { parent::setUp(); - if(version_compare(PHP_VERSION, '5.3', '<')) { - $this->markTestSkipped('Namespaces are not supported before PHP 5.3'); - } - $this->base = dirname(__FILE__) . '/fixtures/namespaced_classmanifest'; $this->manifest = new SS_ClassManifest($this->base, false, true, false); } diff --git a/tests/core/manifest/TokenisedRegularExpressionTest.php b/tests/core/manifest/TokenisedRegularExpressionTest.php index c11e60634..e1d7cb713 100644 --- a/tests/core/manifest/TokenisedRegularExpressionTest.php +++ b/tests/core/manifest/TokenisedRegularExpressionTest.php @@ -122,9 +122,6 @@ PHP } function testNamesapcedClassDefParser() { - if(version_compare(PHP_VERSION, '5.3', '<')) { - return; - } $parser = SS_ClassManifest::get_namespaced_class_parser(); $tokens = $this->getNamespaceTokens(); @@ -167,9 +164,6 @@ PHP } function testNamespaceDefParser() { - if(version_compare(PHP_VERSION, '5.3', '<')) { - return; - } $parser = SS_ClassManifest::get_namespace_parser(); $namespacedTokens = $this->getNamespaceTokens(); From fb3b03f38b33233d575d2b826340e0c8ba6a118f Mon Sep 17 00:00:00 2001 From: Andrew O'Neil Date: Wed, 18 Apr 2012 11:01:03 +1200 Subject: [PATCH 2/2] MINOR: Remove support for PHP <5.3.2 --- api/DataFormatter.php | 1 - i18n/i18nTextCollector.php | 2 -- model/DataObject.php | 5 +---- 3 files changed, 1 insertion(+), 7 deletions(-) diff --git a/api/DataFormatter.php b/api/DataFormatter.php index 1f7f88ae9..721379248 100644 --- a/api/DataFormatter.php +++ b/api/DataFormatter.php @@ -264,7 +264,6 @@ abstract class DataFormatter extends Object { // add default required fields $dbFields = array_merge($dbFields, array('ID'=>'Int')); - // @todo Requires PHP 5.1+ if(is_array($this->removeFields)) { $dbFields = array_diff_key($dbFields, array_combine($this->removeFields,$this->removeFields)); } diff --git a/i18n/i18nTextCollector.php b/i18n/i18nTextCollector.php index 93de04415..db670c397 100644 --- a/i18n/i18nTextCollector.php +++ b/i18n/i18nTextCollector.php @@ -17,8 +17,6 @@ * Usage through URL (module-specific): http://localhost/dev/tasks/i18nTextCollectorTask/?module=mymodule * Usage on CLI: sake dev/tasks/i18nTextCollectorTask * Usage on CLI (module-specific): sake dev/tasks/i18nTextCollectorTask module=mymodule - * - * Requires PHP 5.1+ due to class_implements() limitations * * @author Bernat Foj Capell * @author Ingo Schommer diff --git a/model/DataObject.php b/model/DataObject.php index 852ca21fd..e047d262c 100644 --- a/model/DataObject.php +++ b/model/DataObject.php @@ -2158,10 +2158,7 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity * @return bool */ public static function has_own_table($dataClass) { - - // The condition below has the same effect as !is_subclass_of($dataClass,'DataObject'), - // which causes PHP < 5.3 to segfault in rare circumstances, see PHP bug #46753 - if($dataClass == 'DataObject' || !in_array('DataObject', ClassInfo::ancestry($dataClass))) return false; + if(!is_subclass_of($dataClass,'DataObject')) return false; if(!isset(DataObject::$cache_has_own_table[$dataClass])) { if(get_parent_class($dataClass) == 'DataObject') {