Merge pull request #282 from halkyon/php52_references

Removed checks for versions less than PHP 5.3
This commit is contained in:
Ingo Schommer 2012-04-04 07:47:04 -07:00
commit af80ab5ab7
7 changed files with 23 additions and 41 deletions

View File

@ -42,8 +42,6 @@ Director::addRules(20, array(
Object::useCustomClass('SSDatetime', 'SS_Datetime', true); Object::useCustomClass('SSDatetime', 'SS_Datetime', true);
Object::useCustomClass('Datetime', 'SS_Datetime', true); Object::useCustomClass('Datetime', 'SS_Datetime', true);
/** /**
* The root directory of TinyMCE * The root directory of TinyMCE
*/ */

View File

@ -21,22 +21,17 @@ class Cookie {
* @param string $path See http://php.net/set_session * @param string $path See http://php.net/set_session
* @param string $domain See http://php.net/set_session * @param string $domain See http://php.net/set_session
* @param boolean $secure See http://php.net/set_session * @param boolean $secure See http://php.net/set_session
* @param boolean $httpOnly See http://php.net/set_session (PHP 5.2+ only) * @param boolean $httpOnly See http://php.net/set_session
*/ */
static function set($name, $value, $expiry = 90, $path = null, $domain = null, $secure = false, $httpOnly = false) { static function set($name, $value, $expiry = 90, $path = null, $domain = null, $secure = false, $httpOnly = false) {
if(!headers_sent($file, $line)) { if(!headers_sent($file, $line)) {
$expiry = $expiry > 0 ? time()+(86400*$expiry) : $expiry; $expiry = $expiry > 0 ? time()+(86400*$expiry) : $expiry;
$path = ($path) ? $path : Director::baseURL(); $path = ($path) ? $path : Director::baseURL();
setcookie($name, $value, $expiry, $path, $domain, $secure, $httpOnly);
// Versions of PHP prior to 5.2 do not support the $httpOnly value
if(version_compare(phpversion(), 5.2, '<')) {
setcookie($name, $value, $expiry, $path, $domain, $secure);
} else {
setcookie($name, $value, $expiry, $path, $domain, $secure, $httpOnly);
}
} else { } else {
if(self::$report_errors) if(self::$report_errors) {
user_error("Cookie '$name' can't be set. The site started outputting was content at line $line in $file", E_USER_WARNING); user_error("Cookie '$name' can't be set. The site started outputting was content at line $line in $file", E_USER_WARNING);
}
} }
} }

View File

@ -1,26 +1,25 @@
<?php <?php
/************************************************************************************ /************************************************************************************
************************************************************************************ ************************************************************************************
** ** ** **
** If you can read this text in your browser then you don't have PHP installed. ** ** If you can read this text in your browser then you don't have PHP installed. **
** Please install PHP 5.2 or higher, preferably PHP 5.3. ** ** Please install PHP 5.3 or higher. **
** ** ** **
************************************************************************************ ************************************************************************************
************************************************************************************/ ************************************************************************************/
/** /**
* PHP version check. Make sure we've got at least PHP 5.2 in the most friendly way possible * PHP version check. Make sure we've got at least PHP 5.3 in the most friendly way possible
*/ */
$majorVersion = strtok(phpversion(),'.'); $majorVersion = strtok(phpversion(),'.');
$minorVersion = strtok('.'); $minorVersion = strtok('.');
if($majorVersion < 5 || ($majorVersion == 5 && $minorVersion < 2)) { if($majorVersion < 5 || ($majorVersion == 5 && $minorVersion < 3)) {
header("HTTP/1.1 500 Server Error"); header("HTTP/1.1 500 Server Error");
echo str_replace('$PHPVersion', phpversion(), file_get_contents("sapphire/dev/install/php5-required.html")); echo str_replace('$PHPVersion', phpversion(), file_get_contents("sapphire/dev/install/php5-required.html"));
die(); die();
} }
include('sapphire/dev/install/install.php5'); include('sapphire/dev/install/install.php5');

View File

@ -4,7 +4,7 @@
************************************************************************************ ************************************************************************************
** ** ** **
** If you can read this text in your browser then you don't have PHP installed. ** ** If you can read this text in your browser then you don't have PHP installed. **
** Please install PHP 5.2 or higher, preferably PHP 5.3. ** ** Please install PHP 5.3 or higher. **
** ** ** **
************************************************************************************ ************************************************************************************
************************************************************************************/ ************************************************************************************/

View File

@ -11,7 +11,6 @@
<div id="Container"> <div id="Container">
<div id="Header"> <div id="Header">
<h1>SilverStripe CMS Installation</h1> <h1>SilverStripe CMS Installation</h1>
</div> </div>
<div id="Navigation">&nbsp;</div> <div id="Navigation">&nbsp;</div>
@ -20,10 +19,10 @@
<div id="Layout"> <div id="Layout">
<div class="typography"> <div class="typography">
<h1>PHP 5 required</h1> <h1>PHP 5 required</h1>
<h2>To run SilverStripe, please install PHP 5.2 or greater.</h2> <h2>To run SilverStripe, please install PHP 5.3 or greater.</h2>
<p>We have detected that you are running PHP version <b>$PHPVersion</b>. In order to run SilverStripe, <p>We have detected that you are running PHP version <b>$PHPVersion</b>. In order to run SilverStripe,
you must have PHP version 5.2 or greater, and for best results we recommend PHP 5.3 or greater.</p> you must have PHP version 5.3 or greater.</p>
<p>If you are running on a shared host, you may need to ask your hosting provider how to do this.</p> <p>If you are running on a shared host, you may need to ask your hosting provider how to do this.</p>
</div> </div>
@ -37,4 +36,4 @@
</div> </div>
</div> </div>
</body> </body>
</html> </html>

View File

@ -1,9 +1,10 @@
<?php <?php
/************************************************************************************ /************************************************************************************
************************************************************************************ ************************************************************************************
** ** ** **
** If you can read this text in your browser then you don't have PHP installed. ** ** If you can read this text in your browser then you don't have PHP installed. **
** Please install PHP 5.0 or higher, preferably PHP 5.2 or 5.3. ** ** Please install PHP 5.3 or higher. **
** ** ** **
************************************************************************************ ************************************************************************************
************************************************************************************/ ************************************************************************************/
@ -12,8 +13,10 @@
* @package sapphire * @package sapphire
* @subpackage core * @subpackage core
*/ */
$majorVersion = strtok(phpversion(),'.');
$minorVersion = strtok('.');
if(version_compare(phpversion(), 5, '<')) { if($majorVersion < 5 || ($majorVersion == 5 && $minorVersion < 3)) {
header("HTTP/1.1 500 Server Error"); header("HTTP/1.1 500 Server Error");
echo str_replace('$PHPVersion', phpversion(), file_get_contents("dev/install/php5-required.html")); echo str_replace('$PHPVersion', phpversion(), file_get_contents("dev/install/php5-required.html"));
die(); die();

View File

@ -6,31 +6,19 @@
class DateTest extends SapphireTest { class DateTest extends SapphireTest {
protected $originalTZ; protected $originalTZ;
function setUp() { function setUp() {
// Set timezone to support timestamp->date conversion. // Set timezone to support timestamp->date conversion.
// We can't use date_default_timezone_set() as its not supported prior to PHP 5.2 $this->originalTZ = date_default_timezone_get();
date_default_timezone_set('Pacific/Auckland');
if (version_compare(PHP_VERSION, '5.2.0', '<')) {
$this->originalTZ = ini_get('date.timezone');
ini_set('date.timezone', 'Pacific/Auckland');
} else {
$this->originalTZ = date_default_timezone_get();
date_default_timezone_set('Pacific/Auckland');
}
parent::setUp(); parent::setUp();
} }
function tearDown() { function tearDown() {
if(version_compare(PHP_VERSION, '5.2.0', '<') ){ date_default_timezone_set($this->originalTZ);
ini_set('date.timezone',$this->originalTZ);
} else {
date_default_timezone_set($this->originalTZ);
}
parent::tearDown(); parent::tearDown();
} }
function testNiceDate() { function testNiceDate() {
$this->assertEquals('31/03/2008', DBField::create('Date', 1206968400)->Nice(), $this->assertEquals('31/03/2008', DBField::create('Date', 1206968400)->Nice(),
"Date->Nice() works with timestamp integers" "Date->Nice() works with timestamp integers"