Merge pull request #339 from ajoneil/remove-pre-53-support

Remove pre 5.3 support
This commit is contained in:
Sean Harvey 2012-04-17 16:19:23 -07:00
commit 7d84aff01e
7 changed files with 9 additions and 31 deletions

View File

@ -264,7 +264,6 @@ abstract class DataFormatter extends Object {
// add default required fields // add default required fields
$dbFields = array_merge($dbFields, array('ID'=>'Int')); $dbFields = array_merge($dbFields, array('ID'=>'Int'));
// @todo Requires PHP 5.1+
if(is_array($this->removeFields)) { if(is_array($this->removeFields)) {
$dbFields = array_diff_key($dbFields, array_combine($this->removeFields,$this->removeFields)); $dbFields = array_diff_key($dbFields, array_combine($this->removeFields,$this->removeFields));
} }

View File

@ -331,18 +331,15 @@ class SS_ClassManifest {
if (!$classes) { if (!$classes) {
$tokens = token_get_all($file); $tokens = token_get_all($file);
if(version_compare(PHP_VERSION, '5.3', '>=')) {
$classes = self::get_namespaced_class_parser()->findAll($tokens); $classes = self::get_namespaced_class_parser()->findAll($tokens);
$namespace = self::get_namespace_parser()->findAll($tokens); $namespace = self::get_namespace_parser()->findAll($tokens);
if($namespace) { if($namespace) {
$namespace = implode('', $namespace[0]['namespaceName']) . '\\'; $namespace = implode('', $namespace[0]['namespaceName']) . '\\';
} else {
$namespace = '';
}
} else { } else {
$classes = self::get_class_parser()->findAll($tokens);
$namespace = ''; $namespace = '';
} }
$interfaces = self::get_interface_parser()->findAll($tokens); $interfaces = self::get_interface_parser()->findAll($tokens);
$cache = array('classes' => $classes, 'interfaces' => $interfaces, 'namespace' => $namespace); $cache = array('classes' => $classes, 'interfaces' => $interfaces, 'namespace' => $namespace);

View File

@ -17,8 +17,6 @@
* Usage through URL (module-specific): http://localhost/dev/tasks/i18nTextCollectorTask/?module=mymodule * Usage through URL (module-specific): http://localhost/dev/tasks/i18nTextCollectorTask/?module=mymodule
* Usage on CLI: sake dev/tasks/i18nTextCollectorTask * Usage on CLI: sake dev/tasks/i18nTextCollectorTask
* Usage on CLI (module-specific): sake dev/tasks/i18nTextCollectorTask module=mymodule * Usage on CLI (module-specific): sake dev/tasks/i18nTextCollectorTask module=mymodule
*
* Requires PHP 5.1+ due to class_implements() limitations
* *
* @author Bernat Foj Capell <bernat@silverstripe.com> * @author Bernat Foj Capell <bernat@silverstripe.com>
* @author Ingo Schommer <FIRSTNAME@silverstripe.com> * @author Ingo Schommer <FIRSTNAME@silverstripe.com>

View File

@ -2160,10 +2160,7 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
* @return bool * @return bool
*/ */
public static function has_own_table($dataClass) { public static function has_own_table($dataClass) {
if(!is_subclass_of($dataClass,'DataObject')) return false;
// 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(!isset(DataObject::$cache_has_own_table[$dataClass])) { if(!isset(DataObject::$cache_has_own_table[$dataClass])) {
if(get_parent_class($dataClass) == 'DataObject') { if(get_parent_class($dataClass) == 'DataObject') {

View File

@ -21,11 +21,8 @@ class RandomGenerator {
// TODO Fails with "Could not gather sufficient random data" on IIS, temporarily disabled on windows // TODO Fails with "Could not gather sufficient random data" on IIS, temporarily disabled on windows
if(!$isWin) { if(!$isWin) {
// mcrypt with urandom is only available on PHP 5.3 or newer $e = mcrypt_create_iv(64, MCRYPT_DEV_URANDOM);
if(version_compare(PHP_VERSION, '5.3.0', '>=') && function_exists('mcrypt_create_iv')) { 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 // Fall back to SSL methods - may slow down execution by a few ms

View File

@ -13,10 +13,6 @@ class NamespacedClassManifestTest extends SapphireTest {
public function setUp() { public function setUp() {
parent::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->base = dirname(__FILE__) . '/fixtures/namespaced_classmanifest';
$this->manifest = new SS_ClassManifest($this->base, false, true, false); $this->manifest = new SS_ClassManifest($this->base, false, true, false);
} }

View File

@ -122,9 +122,6 @@ PHP
} }
function testNamesapcedClassDefParser() { function testNamesapcedClassDefParser() {
if(version_compare(PHP_VERSION, '5.3', '<')) {
return;
}
$parser = SS_ClassManifest::get_namespaced_class_parser(); $parser = SS_ClassManifest::get_namespaced_class_parser();
$tokens = $this->getNamespaceTokens(); $tokens = $this->getNamespaceTokens();
@ -167,9 +164,6 @@ PHP
} }
function testNamespaceDefParser() { function testNamespaceDefParser() {
if(version_compare(PHP_VERSION, '5.3', '<')) {
return;
}
$parser = SS_ClassManifest::get_namespace_parser(); $parser = SS_ClassManifest::get_namespace_parser();
$namespacedTokens = $this->getNamespaceTokens(); $namespacedTokens = $this->getNamespaceTokens();