Merge branch '2.3' into 2.7

* 2.3:
  [ci] use hirak/prestissimo
  [Filesystem] Fix transient tests
  [HttpFoundation] Avoid warnings when checking malicious IPs
  [HttpFoundation] Set the Content-Range header if the requested Range is unsatisfied

Conflicts:
	appveyor.yml
	src/Symfony/Component/Filesystem/Tests/FilesystemTest.php
This commit is contained in:
Nicolas Grekas 2016-03-10 20:23:56 +01:00
commit def0176e1b
14 changed files with 103 additions and 8 deletions

6
.composer/composer.json Normal file
View File

@ -0,0 +1,6 @@
{
"require": {
"php": ">=5.3.7",
"hirak/prestissimo": "^0.1.15"
}
}

72
.composer/composer.lock generated Normal file
View File

@ -0,0 +1,72 @@
{
"_readme": [
"This file locks the dependencies of your project to a known state",
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
"hash": "aa7aa2d143fd85800595242996021ada",
"content-hash": "51e9161b78dda1fe149a9e9c106be90b",
"packages": [
{
"name": "hirak/prestissimo",
"version": "0.1.15",
"source": {
"type": "git",
"url": "https://github.com/hirak/prestissimo.git",
"reference": "f735c4f92061dae7829a6797d74bd543501d7d05"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/hirak/prestissimo/zipball/f735c4f92061dae7829a6797d74bd543501d7d05",
"reference": "f735c4f92061dae7829a6797d74bd543501d7d05",
"shasum": ""
},
"require": {
"composer-plugin-api": "~1.0.0-alpha10",
"ext-curl": "*",
"php": ">=5.3.2"
},
"require-dev": {
"composer/composer": "1.0.0-alpha10",
"phpunit/phpunit": "^4.8",
"squizlabs/php_codesniffer": "^2.5"
},
"type": "composer-plugin",
"extra": {
"class": "Hirak\\Prestissimo\\Plugin"
},
"autoload": {
"psr-4": {
"Hirak\\Prestissimo\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Hiraku NAKANO",
"email": "hiraku@tojiru.net"
}
],
"description": "composer parallel install plugin",
"keywords": [
"install",
"parallel",
"speedup"
],
"time": "2016-03-07 10:12:34"
}
],
"packages-dev": [],
"aliases": [],
"minimum-stability": "stable",
"stability-flags": [],
"prefer-stable": false,
"prefer-lowest": false,
"platform": {
"php": ">=5.3.7"
},
"platform-dev": []
}

View File

@ -49,8 +49,8 @@ before_install:
- if [[ $TRAVIS_PHP_VERSION = 5.* ]]; then pecl install -f memcached-2.1.0; fi;
- if [[ $TRAVIS_PHP_VERSION != hhvm ]]; then echo extension = ldap.so >> $INI_FILE; fi;
- if [[ $TRAVIS_PHP_VERSION != hhvm ]]; then phpenv config-rm xdebug.ini; fi;
- if [[ $TRAVIS_REPO_SLUG = symfony/symfony ]]; then cp .composer-auth.json ~/.composer/auth.json; fi;
- if [[ $deps != skip ]]; then composer self-update; fi;
- if [[ $deps != skip && $TRAVIS_REPO_SLUG = symfony/symfony ]]; then cp .composer/* ~/.composer/; composer global install --prefer-dist; fi;
- if [[ $deps != skip ]]; then ./phpunit install; fi;
- export PHPUNIT=$(readlink -f ./phpunit)

View File

@ -18,6 +18,7 @@ init:
install:
- IF EXIST c:\php (SET PHP=0) ELSE (mkdir c:\php)
- cd c:\php
- IF %PHP%==1 appveyor DownloadFile https://curl.haxx.se/ca/cacert.pem
- IF %PHP%==1 appveyor DownloadFile http://windows.php.net/downloads/releases/archives/php-5.3.11-nts-Win32-VC9-x86.zip
- IF %PHP%==1 7z x php-5.3.11-nts-Win32-VC9-x86.zip -y >nul
- IF %PHP%==1 appveyor DownloadFile http://nebm.ist.utl.pt/~glopes/misc/intl_win/ICU-51.2-dlls.zip
@ -38,6 +39,8 @@ install:
- IF %PHP%==1 echo date.timezone="UTC" >> php.ini-min
- IF %PHP%==1 echo extension_dir=ext >> php.ini-min
- IF %PHP%==1 echo extension=php_openssl.dll >> php.ini-min
- IF %PHP%==1 echo extension=php_curl.dll >> php.ini-min
- IF %PHP%==1 echo curl.cainfo=c:\php\cacert.pem >> php.ini-min
- IF %PHP%==1 copy /Y php.ini-min php.ini-max
- IF %PHP%==1 echo extension=php_apcu.dll >> php.ini-max
- IF %PHP%==1 echo apc.enable_cli=1 >> php.ini-max
@ -50,7 +53,8 @@ install:
- copy /Y php.ini-max php.ini
- cd c:\projects\symfony
- mkdir %APPDATA%\Composer
- IF %APPVEYOR_REPO_NAME%==symfony/symfony copy /Y .composer-auth.json %APPDATA%\Composer\auth.json
- IF %APPVEYOR_REPO_NAME%==symfony/symfony copy /Y .composer\* %APPDATA%\Composer\
- IF %APPVEYOR_REPO_NAME%==symfony/symfony composer global install --prefer-dist --no-progress --ansi || echo curl.cainfo needs PHP 5.3.7
- php phpunit install
- IF %APPVEYOR_REPO_BRANCH%==master (SET COMPOSER_ROOT_VERSION=dev-master) ELSE (SET COMPOSER_ROOT_VERSION=%APPVEYOR_REPO_BRANCH%.x-dev)
- composer update --prefer-dist --no-progress --ansi

View File

@ -22,7 +22,7 @@ class ClassMapGeneratorTest extends \PHPUnit_Framework_TestCase
public function prepare_workspace()
{
$this->workspace = rtrim(sys_get_temp_dir(), DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.time().mt_rand(0, 1000);
$this->workspace = sys_get_temp_dir().'/'.microtime(true).'.'.mt_rand();
mkdir($this->workspace, 0777, true);
$this->workspace = realpath($this->workspace);
}

View File

@ -46,7 +46,7 @@ class FilesystemTestCase extends \PHPUnit_Framework_TestCase
{
$this->umask = umask(0);
$this->filesystem = new Filesystem();
$this->workspace = rtrim(sys_get_temp_dir(), DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.time().mt_rand(0, 1000);
$this->workspace = sys_get_temp_dir().'/'.microtime(true).'.'.mt_rand();
mkdir($this->workspace, 0777, true);
$this->workspace = realpath($this->workspace);
}

View File

@ -253,6 +253,7 @@ class BinaryFileResponse extends Response
if ($start <= $end) {
if ($start < 0 || $end > $fileSize - 1) {
$this->setStatusCode(416);
$this->headers->set('Content-Range', sprintf('bytes */%s', $fileSize));
} elseif ($start !== 0 || $end !== $fileSize - 1) {
$this->maxlen = $end < $fileSize ? $end - $start + 1 : -1;
$this->offset = $start;

View File

@ -112,8 +112,12 @@ class IpUtils
$netmask = 128;
}
$bytesAddr = unpack('n*', inet_pton($address));
$bytesTest = unpack('n*', inet_pton($requestIp));
$bytesAddr = unpack('n*', @inet_pton($address));
$bytesTest = unpack('n*', @inet_pton($requestIp));
if (!$bytesAddr || !$bytesTest) {
return false;
}
for ($i = 1, $ceil = ceil($netmask / 16); $i <= $ceil; ++$i) {
$left = $netmask - 16 * ($i - 1);

View File

@ -824,6 +824,8 @@ class Request
if (!filter_var($clientIp, FILTER_VALIDATE_IP)) {
unset($clientIps[$key]);
continue;
}
if (IpUtils::checkIp($clientIp, self::$trustedProxies)) {

View File

@ -211,7 +211,7 @@ class BinaryFileResponseTest extends ResponseTestCase
$response->sendContent();
$this->assertEquals(416, $response->getStatusCode());
#$this->assertEquals('', $response->headers->get('Content-Range'));
$this->assertEquals('bytes */35', $response->headers->get('Content-Range'));
}
public function provideInvalidRanges()

View File

@ -63,6 +63,8 @@ class IpUtilsTest extends \PHPUnit_Framework_TestCase
array(true, '2a01:198:603:0:396e:4789:8e99:890f', array('::1', '2a01:198:603:0::/65')),
array(true, '2a01:198:603:0:396e:4789:8e99:890f', array('2a01:198:603:0::/65', '::1')),
array(false, '2a01:198:603:0:396e:4789:8e99:890f', array('::1', '1a01:198:603:0::/65')),
array(false, '}__test|O:21:&quot;JDatabaseDriverMysqli&quot;:3:{s:2', '::1'),
array(false, '2a01:198:603:0:396e:4789:8e99:890f', 'unknown'),
);
}

View File

@ -912,6 +912,7 @@ class RequestTest extends \PHPUnit_Framework_TestCase
// invalid forwarded IP is ignored
array(array('88.88.88.88'), '127.0.0.1', 'unknown,88.88.88.88', array('127.0.0.1')),
array(array('88.88.88.88'), '127.0.0.1', '}__test|O:21:&quot;JDatabaseDriverMysqli&quot;:3:{s:2,88.88.88.88', array('127.0.0.1')),
);
}

View File

@ -407,7 +407,10 @@ abstract class AbstractIntlDateFormatterTest extends \PHPUnit_Framework_TestCase
public function testFormatWithIntlTimeZone()
{
if (PHP_VERSION_ID < 50500 && !(extension_loaded('intl') && method_exists('IntlDateFormatter', 'setTimeZone'))) {
if (!extension_loaded('intl')) {
$this->markTestSkipped('Extension intl is required.');
}
if (PHP_VERSION_ID < 50500 && !method_exists('IntlDateFormatter', 'setTimeZone')) {
$this->markTestSkipped('Only in PHP 5.5+ IntlDateFormatter allows to use DateTimeZone objects.');
}