mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Merge pull request #7246 from open-sausages/pulls/4.0/fix-iis
BUG Fix install issue with IIS
This commit is contained in:
commit
4dbc2a99e5
@ -142,24 +142,25 @@ class InstallRequirements
|
||||
*/
|
||||
public function isIIS($fromVersion = 7)
|
||||
{
|
||||
if (strpos($this->findWebserver(), 'IIS/') === false) {
|
||||
return false;
|
||||
$webserver = $this->findWebserver();
|
||||
if (preg_match('#.*IIS/(?<version>[.\\d]+)$#', $webserver, $matches)) {
|
||||
return version_compare($matches['version'], $fromVersion, '>=');
|
||||
}
|
||||
return substr(strstr($this->findWebserver(), '/'), -3, 1) >= $fromVersion;
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isApache()
|
||||
{
|
||||
if (strpos($this->findWebserver(), 'Apache') !== false) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return strpos($this->findWebserver(), 'Apache') !== false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Find the webserver software running on the PHP host.
|
||||
* @return string|boolean Server software or boolean FALSE
|
||||
*
|
||||
* @return string|false Server software or boolean FALSE
|
||||
*/
|
||||
public function findWebserver()
|
||||
{
|
||||
|
54
tests/php/Dev/Install/InstallRequirementsTest.php
Normal file
54
tests/php/Dev/Install/InstallRequirementsTest.php
Normal file
@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\Dev\Tests\Install;
|
||||
|
||||
use SilverStripe\Dev\Install\InstallRequirements;
|
||||
use SilverStripe\Dev\SapphireTest;
|
||||
|
||||
class InstallRequirementsTest extends SapphireTest
|
||||
{
|
||||
public function testIIS()
|
||||
{
|
||||
$requirements = new InstallRequirements();
|
||||
$_SERVER['SERVER_SIGNATURE'] = 'Microsoft-IIS/10.0';
|
||||
|
||||
// Test server
|
||||
$this->assertEquals('Microsoft-IIS/10.0', $requirements->findWebserver());
|
||||
|
||||
// True conditions
|
||||
$this->assertTrue($requirements->isIIS());
|
||||
$this->assertTrue($requirements->isIIS(10));
|
||||
$this->assertTrue($requirements->isIIS('10.0'));
|
||||
$this->assertTrue($requirements->isIIS(9));
|
||||
|
||||
// Negative - Based on number
|
||||
$this->assertFalse($requirements->isIIS(11));
|
||||
$_SERVER['SERVER_SIGNATURE'] = 'Microsoft-IIS/6.0';
|
||||
$this->assertFalse($requirements->isIIS());
|
||||
$_SERVER['SERVER_SIGNATURE'] = 'Microsoft-IIS/6.5';
|
||||
$this->assertFalse($requirements->isIIS());
|
||||
|
||||
// Negative - Based on string
|
||||
$_SERVER['SERVER_SOFTWARE'] = 'lighttpd/1.4.33';
|
||||
$this->assertFalse($requirements->isIIS());
|
||||
$_SERVER['SERVER_SOFTWARE'] = 'Apache/2.4.25 (Unix) PHP/5.6.30 LibreSSL/2.2.7';
|
||||
$this->assertFalse($requirements->isIIS());
|
||||
}
|
||||
|
||||
public function testApache()
|
||||
{
|
||||
$requirements = new InstallRequirements();
|
||||
$_SERVER['SERVER_SIGNATURE'] = '';
|
||||
$_SERVER['SERVER_SOFTWARE'] = 'Apache/2.4.25 (Unix) PHP/5.6.30 LibreSSL/2.2.7';
|
||||
|
||||
// Test server
|
||||
$this->assertEquals('Apache/2.4.25 (Unix) PHP/5.6.30 LibreSSL/2.2.7', $requirements->findWebserver());
|
||||
|
||||
// True conditions
|
||||
$this->assertTrue($requirements->isApache());
|
||||
|
||||
// False conditions
|
||||
$_SERVER['SERVER_SOFTWARE'] = 'lighttpd/1.4.33';
|
||||
$this->assertFalse($requirements->isApache());
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user