Merge branch '2.2'

* 2.2: (30 commits)
  [HttpFoundation] Added support for partial ranges in the BinaryFileResponse.
  [HttpFoundation] Fixed byte ranges in the BinaryFileResponse.
  updated required versions when depending on the HttpFoundation component
  updated required versions when depending on the HttpKernel component
  updated required versions when depending on the Config component
  updated required versions when depending on the Form component
  updated required versions when depending on the DependencyInjection component
  updated required versions when depending on the Validator component
  updated required versions when depending on the Translation component
  updated required versions when depending on the Routing component
  updated required versions when depending on the EventDispatcher component
  updated required versions when depending on the OptionsResolver component
  updated required versions when depending on the PropertyAccess component
  updated required versions when depending on the Security component
  updated required versions when depending on the Templating component
  updated required versions when depending on the Stopwatch component
  updated required versions when depending on the Process component
  updated required versions when depending on the Finder component
  updated required versions when depending on the Dom Crawler component
  use ~2.0 when depending on the Dom Crawler component
  ...
This commit is contained in:
Fabien Potencier 2013-02-11 11:09:44 +01:00
commit c97be281c0
31 changed files with 168 additions and 108 deletions

View File

@ -1,6 +1,23 @@
UPGRADE FROM 2.x to 3.0
=======================
### ClassLoader
* The `UniversalClassLoader` class has been removed in favor of `ClassLoader`. The only difference is that some method
names are different:
* `registerNamespaces()` -> `addPrefixes()`
* `registerPrefixes()` -> `addPrefixes()`
* `registerNamespaces()` -> `addPrefix()`
* `registerPrefixes()` -> `addPrefix()`
* `getNamespaces()` -> `getPrefixes()`
* `getNamespaceFallbacks()` -> `getFallbackDirs()`
* `getPrefixFallbacks()` -> `getFallbackDirs()`
* The `DebugUniversalClassLoader` class has been removed in favor of
`DebugClassLoader`. The difference is that the constructor now takes a
loader to wrap.
### HttpKernel
* The `Symfony\Component\HttpKernel\Log\LoggerInterface` has been removed in

View File

@ -18,7 +18,7 @@ class DbalLoggerTest extends \PHPUnit_Framework_TestCase
*/
public function testLog($sql, $params, $logParams)
{
$logger = $this->getMock('Symfony\\Component\\HttpKernel\\Log\\LoggerInterface');
$logger = $this->getMock('Psr\\Log\\LoggerInterface');
$dbalLogger = $this
->getMockBuilder('Symfony\\Bridge\\Doctrine\\Logger\\DbalLogger')
@ -47,7 +47,7 @@ class DbalLoggerTest extends \PHPUnit_Framework_TestCase
public function testLogNonUtf8()
{
$logger = $this->getMock('Symfony\\Component\\HttpKernel\\Log\\LoggerInterface');
$logger = $this->getMock('Psr\\Log\\LoggerInterface');
$dbalLogger = $this
->getMockBuilder('Symfony\\Bridge\\Doctrine\\Logger\\DbalLogger')

View File

@ -20,12 +20,12 @@
"doctrine/common": "~2.2"
},
"require-dev": {
"symfony/stopwatch": "2.2.*",
"symfony/dependency-injection": "2.2.*",
"symfony/form": "2.2.*",
"symfony/http-kernel": "2.2.*",
"symfony/security": "2.2.*",
"symfony/validator": "2.2.*",
"symfony/stopwatch": ">=2.2,<2.3-dev",
"symfony/dependency-injection": "~2.0",
"symfony/form": ">=2.2,<2.3-dev",
"symfony/http-kernel": ">=2.2,<2.3-dev",
"symfony/security": ">=2.2,<2.3-dev",
"symfony/validator": ">=2.2,<2.3-dev",
"doctrine/data-fixtures": "1.0.*",
"doctrine/dbal": "~2.2",
"doctrine/orm": "~2.2,>=2.2.3"

View File

@ -17,7 +17,7 @@
],
"require": {
"php": ">=5.3.3",
"symfony/http-kernel": "2.2.*",
"symfony/http-kernel": ">=2.2,<2.3-dev",
"monolog/monolog": "~1.3"
},
"autoload": {

View File

@ -17,13 +17,13 @@
],
"require": {
"php": ">=5.3.3",
"symfony/http-foundation": "2.2.*",
"symfony/http-kernel": "2.2.*",
"symfony/form": "2.2.*",
"symfony/http-foundation": "~2.0",
"symfony/http-kernel": "~2.0",
"symfony/form": ">=2.2,<2.3-dev",
"propel/propel1": "1.6.*"
},
"require-dev": {
"symfony/stopwatch": "2.2.*"
"symfony/stopwatch": ">=2.2,<2.3-dev"
},
"autoload": {
"psr-0": { "Symfony\\Bridge\\Propel1\\": "" }

View File

@ -21,12 +21,12 @@
},
"require-dev": {
"symfony/form": "2.2.*",
"symfony/http-kernel": "2.2.*",
"symfony/routing": "2.2.*",
"symfony/templating": "2.2.*",
"symfony/translation": "2.2.*",
"symfony/yaml": "2.2.*",
"symfony/security": "2.2.*"
"symfony/http-kernel": ">=2.2,<2.3-dev",
"symfony/routing": ">=2.2,<2.3-dev",
"symfony/templating": "~2.1",
"symfony/translation": ">=2.0,<2.3-dev",
"symfony/yaml": "~2.0",
"symfony/security": ">=2.0,<2.3-dev"
},
"suggest": {
"symfony/form": "2.2.*",

View File

@ -13,7 +13,7 @@ namespace Symfony\Bundle\FrameworkBundle\Tests\Controller;
use Symfony\Bundle\FrameworkBundle\Tests\TestCase;
use Symfony\Bundle\FrameworkBundle\Controller\ControllerNameParser;
use Symfony\Component\ClassLoader\UniversalClassLoader;
use Symfony\Component\ClassLoader\ClassLoader;
class ControllerNameParserTest extends TestCase
{
@ -21,8 +21,8 @@ class ControllerNameParserTest extends TestCase
protected function setUp()
{
$this->loader = new UniversalClassLoader();
$this->loader->registerNamespaces(array(
$this->loader = new ClassLoader();
$this->loader->addPrefixes(array(
'TestBundle' => __DIR__.'/../Fixtures',
'TestApplication' => __DIR__.'/../Fixtures',
));

View File

@ -17,20 +17,20 @@
],
"require": {
"php": ">=5.3.3",
"symfony/dependency-injection" : "2.2.*",
"symfony/config" : "2.2.*",
"symfony/event-dispatcher": "2.2.*",
"symfony/http-kernel": "2.2.*",
"symfony/filesystem": "2.2.*",
"symfony/routing": "2.2.*",
"symfony/stopwatch": "2.2.*",
"symfony/templating": "2.2.*",
"symfony/translation": "2.2.*",
"doctrine/common": "~2.2"
"symfony/dependency-injection" : "~2.0",
"symfony/config" : ">=2.2,<2.3-dev",
"symfony/event-dispatcher": "~2.1",
"symfony/http-kernel": ">=2.2,<2.3-dev",
"symfony/filesystem": ">=2.1,<2.3-dev",
"symfony/routing": ">=2.2,<2.3-dev",
"symfony/stopwatch": ">=2.2,<2.3-dev",
"symfony/templating": "~2.1",
"symfony/translation": ">=2.2,<2.3-dev",
"doctrine/common": ">=2.2,<2.4-dev"
},
"require-dev": {
"symfony/finder": "2.2.*",
"symfony/security": "2.2.*"
"symfony/finder": "~2.0",
"symfony/security": ">=2.2,<2.3-dev"
},
"suggest": {
"symfony/console": "2.2.*",

View File

@ -17,7 +17,7 @@
],
"require": {
"php": ">=5.3.3",
"symfony/security": "2.2.*"
"symfony/security": ">=2.2,<2.3-dev"
},
"autoload": {
"psr-0": { "Symfony\\Bundle\\SecurityBundle\\": "" }

View File

@ -20,7 +20,7 @@
"symfony/twig-bridge": "2.2.*"
},
"require-dev": {
"symfony/stopwatch": "2.2.*"
"symfony/stopwatch": ">=2.2,<2.3-dev"
},
"autoload": {
"psr-0": { "Symfony\\Bundle\\TwigBundle\\": "" }

View File

@ -39,6 +39,10 @@
bottom: 0;
border-top: 1px solid #bbb;
}
.sf-toolbarreset abbr {
border-bottom: 1px dotted #000000;
cursor: help;
}
.sf-toolbarreset span,
.sf-toolbarreset div {
font-size: 11px;
@ -320,11 +324,6 @@
background-image: -o-linear-gradient(180deg, #cbcbcb, #e8e8e8); !important;
background: linear-gradient(90deg, #cbcbcb, #e8e8e8); !important;
}
.sf-toolbarreset abbr {
border-bottom: 1px dotted #000000;
cursor: help;
}
{% endif %}
/***** Media query *****/

View File

@ -17,14 +17,14 @@
],
"require": {
"php": ">=5.3.3",
"symfony/http-kernel": "2.2.*",
"symfony/routing": "2.2.*",
"symfony/http-kernel": ">=2.2,<2.3-dev",
"symfony/routing": ">=2.2,<2.3-dev",
"symfony/twig-bridge": "2.2.*"
},
"require-dev": {
"symfony/config": "2.2.*",
"symfony/dependency-injection": "2.2.*",
"symfony/stopwatch": "2.2.*"
"symfony/config": ">=2.2,<2.3-dev",
"symfony/dependency-injection": "~2.0",
"symfony/stopwatch": ">=2.2,<2.3-dev"
},
"autoload": {
"psr-0": { "Symfony\\Bundle\\WebProfilerBundle\\": "" }

View File

@ -17,11 +17,11 @@
],
"require": {
"php": ">=5.3.3",
"symfony/dom-crawler": "2.2.*"
"symfony/dom-crawler": "~2.0"
},
"require-dev": {
"symfony/process": "2.2.*",
"symfony/css-selector": "2.2.*"
"symfony/process": "~2.0",
"symfony/css-selector": "~2.0"
},
"suggest": {
"symfony/process": "2.2.*"

View File

@ -20,7 +20,7 @@
"php": ">=5.3.3"
},
"require-dev": {
"symfony/finder": "2.2.*"
"symfony/finder": "~2.0"
},
"autoload": {
"psr-0": { "Symfony\\Component\\ClassLoader\\": "" }

View File

@ -19,8 +19,8 @@
"php": ">=5.3.3"
},
"require-dev": {
"symfony/yaml": "2.2.*",
"symfony/config": "2.2.*"
"symfony/yaml": "~2.0",
"symfony/config": ">=2.2.*,<2.3-dev"
},
"suggest": {
"symfony/yaml": "2.2.*",

View File

@ -19,7 +19,7 @@
"php": ">=5.3.3"
},
"require-dev": {
"symfony/css-selector": "2.2.*"
"symfony/css-selector": "~2.0"
},
"suggest": {
"symfony/css-selector": "2.2.*"

View File

@ -19,7 +19,7 @@
"php": ">=5.3.3"
},
"require-dev": {
"symfony/dependency-injection": "2.2.*"
"symfony/dependency-injection": "~2.0"
},
"suggest": {
"symfony/dependency-injection": "2.2.*",

View File

@ -17,14 +17,14 @@
],
"require": {
"php": ">=5.3.3",
"symfony/event-dispatcher": "2.2.*",
"symfony/locale": "2.2.*",
"symfony/options-resolver": "2.2.*",
"symfony/property-access": "2.2.*"
"symfony/event-dispatcher": "~2.1",
"symfony/locale": "~2.0",
"symfony/options-resolver": ">=2.1,<2.3-dev",
"symfony/property-access": ">=2.2,<2.3-dev"
},
"require-dev": {
"symfony/validator": "2.2.*",
"symfony/http-foundation": "2.2.*"
"symfony/validator": ">=2.2,<2.3-dev",
"symfony/http-foundation": ">=2.1,<2.3-dev"
},
"suggest": {
"symfony/validator": "2.2.*",

View File

@ -195,19 +195,27 @@ class BinaryFileResponse extends Response
// Process the range headers.
if (!$request->headers->has('If-Range') || $this->getEtag() == $request->headers->get('If-Range')) {
$range = $request->headers->get('Range');
$fileSize = $this->file->getSize();
list($start, $end) = array_map('intval', explode('-', substr($range, 6), 2)) + array(0);
list($start, $end) = explode('-', substr($range, 6), 2) + array(0);
if ('' !== $end) {
$this->maxlen = $end - $start;
$end = ('' === $end) ? $fileSize - 1 : (int) $end;
if ('' === $start) {
$start = $fileSize - $end;
$end = $fileSize - 1;
} else {
$end = $this->file->getSize() - 1;
$start = (int) $start;
}
$start = max($start, 0);
$end = min($end, $fileSize - 1);
$this->maxlen = $end < $fileSize ? $end - $start + 1 : -1;
$this->offset = $start;
$this->setStatusCode(206);
$this->headers->set('Content-Range', sprintf('bytes %s-%s/%s', $start, $end, $this->file->getSize()));
$this->headers->set('Content-Range', sprintf('bytes %s-%s/%s', $start, $end, $fileSize));
}
}

View File

@ -47,7 +47,10 @@ class BinaryFileResponseTest extends \PHPUnit_Framework_TestCase
$this->assertFalse($response->getContent());
}
public function testRequests()
/**
* @dataProvider provideRanges
*/
public function testRequests($requestRange, $offset, $length, $responseRange)
{
$response = BinaryFileResponse::create(__DIR__.'/File/Fixtures/test.gif')->setAutoEtag();
@ -59,14 +62,35 @@ class BinaryFileResponseTest extends \PHPUnit_Framework_TestCase
// prepare a request for a range of the testing file
$request = Request::create('/');
$request->headers->set('If-Range', $etag);
$request->headers->set('Range', 'bytes=1-4');
$request->headers->set('Range', $requestRange);
$this->expectOutputString('IF8');
$file = fopen(__DIR__.'/File/Fixtures/test.gif', 'r');
fseek($file, $offset);
$data = fread($file, $length);
fclose($file);
$this->expectOutputString($data);
$response = clone $response;
$response->prepare($request);
$response->sendContent();
$this->assertEquals(206, $response->getStatusCode());
$this->assertEquals('binary', $response->headers->get('Content-Transfer-Encoding'));
$this->assertEquals($responseRange, $response->headers->get('Content-Range'));
}
public function provideRanges()
{
return array(
array('bytes=1-4', 1, 4, 'bytes 1-4/35'),
array('bytes=-5', 30, 5, 'bytes 30-34/35'),
array('bytes=-35', 0, 35, 'bytes 0-34/35'),
array('bytes=-40', 0, 35, 'bytes 0-34/35'),
array('bytes=30-', 30, 5, 'bytes 30-34/35'),
array('bytes=30-30', 30, 1, 'bytes 30-30/35'),
array('bytes=30-34', 30, 5, 'bytes 30-34/35'),
array('bytes=30-40', 30, 5, 'bytes 30-34/35')
);
}
public function testXSendfile()

View File

@ -79,9 +79,8 @@ class Client extends BaseClient
$kernel = str_replace("'", "\\'", serialize($this->kernel));
$request = str_replace("'", "\\'", serialize($request));
$r = new \ReflectionClass('\\Symfony\\Component\\ClassLoader\\UniversalClassLoader');
$r = new \ReflectionClass('\\Symfony\\Component\\ClassLoader\\ClassLoader');
$requirePath = str_replace("'", "\\'", $r->getFileName());
$symfonyPath = str_replace("'", "\\'", realpath(__DIR__.'/../../..'));
return <<<EOF
@ -89,8 +88,8 @@ class Client extends BaseClient
require_once '$requirePath';
\$loader = new Symfony\Component\ClassLoader\UniversalClassLoader();
\$loader->registerNamespaces(array('Symfony' => '$symfonyPath'));
\$loader = new Symfony\Component\ClassLoader\ClassLoader();
\$loader->addPrefix('Symfony', '$symfonyPath');
\$loader->register();
\$kernel = unserialize('$kernel');

View File

@ -27,8 +27,8 @@ use Symfony\Component\EventDispatcher\EventSubscriberInterface;
*/
class ExceptionListener implements EventSubscriberInterface
{
private $controller;
private $logger;
protected $controller;
protected $logger;
public function __construct($controller, LoggerInterface $logger = null)
{

View File

@ -50,7 +50,7 @@ class ClientTest extends \PHPUnit_Framework_TestCase
$this->markTestSkipped('The "Process" component is not available');
}
if (!class_exists('Symfony\Component\ClassLoader\UniversalClassLoader')) {
if (!class_exists('Symfony\Component\ClassLoader\ClassLoader')) {
$this->markTestSkipped('The "ClassLoader" component is not available');
}

View File

@ -17,20 +17,20 @@
],
"require": {
"php": ">=5.3.3",
"symfony/event-dispatcher": "2.2.*",
"symfony/http-foundation": "2.2.*",
"symfony/event-dispatcher": "~2.1",
"symfony/http-foundation": ">=2.2,<2.3-dev",
"psr/log": "~1.0"
},
"require-dev": {
"symfony/browser-kit": "2.2.*",
"symfony/class-loader": "2.2.*",
"symfony/config": "2.2.*",
"symfony/class-loader": "~2.1",
"symfony/config": "~2.0",
"symfony/console": "2.2.*",
"symfony/dependency-injection": "2.2.*",
"symfony/finder": "2.2.*",
"symfony/process": "2.2.*",
"symfony/routing": "2.2.*",
"symfony/stopwatch": "2.2.*"
"symfony/dependency-injection": "~2.0",
"symfony/finder": "~2.0",
"symfony/process": "~2.0",
"symfony/routing": ">=2.2,<2.3-dev",
"symfony/stopwatch": ">=2.2,<2.3-dev"
},
"suggest": {
"symfony/browser-kit": "2.2.*",

View File

@ -70,6 +70,14 @@ class TraceableUrlMatcher extends UrlMatcher
continue;
}
// check host requirement
$hostMatches = array();
if ($compiledRoute->getHostRegex() && !preg_match($compiledRoute->getHostRegex(), $this->context->getHost(), $hostMatches)) {
$this->addTrace(sprintf('Host "%s" does not match the requirement ("%s")', $this->context->getHost(), $route->getHost()), self::ROUTE_ALMOST_MATCHES, $name, $route);
return true;
}
// check HTTP method requirement
if ($req = $route->getRequirement('_method')) {
// HEAD and GET are equivalent as per RFC

View File

@ -24,21 +24,27 @@ class TraceableUrlMatcherTest extends \PHPUnit_Framework_TestCase
$coll->add('foo', new Route('/foo', array(), array('_method' => 'POST')));
$coll->add('bar', new Route('/bar/{id}', array(), array('id' => '\d+')));
$coll->add('bar1', new Route('/bar/{name}', array(), array('id' => '\w+', '_method' => 'POST')));
$coll->add('bar2', new Route('/foo', array(), array(), array(), 'baz'));
$coll->add('bar3', new Route('/foo1', array(), array(), array(), 'baz'));
$context = new RequestContext();
$context->setHost('baz');
$matcher = new TraceableUrlMatcher($coll, $context);
$traces = $matcher->getTraces('/babar');
$this->assertEquals(array(0, 0, 0), $this->getLevels($traces));
$this->assertEquals(array(0, 0, 0, 0, 0), $this->getLevels($traces));
$traces = $matcher->getTraces('/foo');
$this->assertEquals(array(1, 0, 0), $this->getLevels($traces));
$this->assertEquals(array(1, 0, 0, 2), $this->getLevels($traces));
$traces = $matcher->getTraces('/bar/12');
$this->assertEquals(array(0, 2), $this->getLevels($traces));
$traces = $matcher->getTraces('/bar/dd');
$this->assertEquals(array(0, 1, 1), $this->getLevels($traces));
$this->assertEquals(array(0, 1, 1, 0, 0), $this->getLevels($traces));
$traces = $matcher->getTraces('/foo1');
$this->assertEquals(array(0, 0, 0, 0, 2), $this->getLevels($traces));
$context->setMethod('POST');
$traces = $matcher->getTraces('/foo');

View File

@ -19,9 +19,8 @@
"php": ">=5.3.3"
},
"require-dev": {
"symfony/config": "2.2.*",
"symfony/yaml": "2.2.*",
"symfony/http-kernel": "2.2.*",
"symfony/config": ">=2.2.*,<2.3-dev",
"symfony/yaml": "~2.0",
"doctrine/common": "~2.2",
"psr/log": "~1.0"
},

View File

@ -9,14 +9,14 @@
* file that was distributed with this source code.
*/
require_once __DIR__.'/../../../../ClassLoader/UniversalClassLoader.php';
require_once __DIR__.'/../../../../ClassLoader/ClassLoader.php';
use Symfony\Component\ClassLoader\UniversalClassLoader;
use Symfony\Component\ClassLoader\ClassLoader;
use Symfony\Component\Finder\Finder;
use Symfony\Component\Security\Acl\Dbal\Schema;
$loader = new UniversalClassLoader();
$loader->registerNamespaces(array(
$loader = new ClassLoader();
$loader->addPrefixes(array(
'Symfony' => __DIR__.'/../../../../../..',
'Doctrine\\Common' => __DIR__.'/../../../../../../../vendor/doctrine-common/lib',
'Doctrine\\DBAL\\Migrations' => __DIR__.'/../../../../../../../vendor/doctrine-migrations/lib',

View File

@ -17,15 +17,15 @@
],
"require": {
"php": ">=5.3.3",
"symfony/event-dispatcher": "2.2.*",
"symfony/http-foundation": "2.2.*",
"symfony/http-kernel": "2.2.*"
"symfony/event-dispatcher": "~2.1",
"symfony/http-foundation": ">=2.1,<2.3-dev",
"symfony/http-kernel": ">=2.1,<=2.3-dev"
},
"require-dev": {
"symfony/form": "2.2.*",
"symfony/routing": "2.2.*",
"symfony/validator": "2.2.*",
"doctrine/common": "~2.2",
"symfony/form": "~2.0",
"symfony/routing": ">=2.2,<2.3-dev",
"symfony/validator": ">=2.2,<2.3-dev",
"doctrine/common": ">=2.2,<2.4-dev",
"doctrine/dbal": "~2.2",
"psr/log": "~1.0"
},

View File

@ -19,8 +19,8 @@
"php": ">=5.3.3"
},
"require-dev": {
"symfony/config": "2.2.*",
"symfony/yaml": "2.2.*"
"symfony/config": ">=2.0,<2.3-dev",
"symfony/yaml": "~2.2"
},
"suggest": {
"symfony/config": "2.2.*",

View File

@ -17,13 +17,13 @@
],
"require": {
"php": ">=5.3.3",
"symfony/translation": "2.2.*"
"symfony/translation": "~2.0"
},
"require-dev": {
"symfony/http-foundation": "2.2.*",
"symfony/locale": "2.2.*",
"symfony/yaml": "2.2.*",
"symfony/config": "2.2.*"
"symfony/http-foundation": "~2.1",
"symfony/locale": "~2.0",
"symfony/yaml": "~2.0",
"symfony/config": ">=2.2,<2.3-dev"
},
"suggest": {
"doctrine/common": "~2.2",