Merge branch '2.1' into 2.2
* 2.1: [FrameworkBundle] Fix code status in dockblock Fixed test to use Reflection [Finder] fixed a potential issue on Solaris where INF value is wrong (refs #7269) Update RouteCompiler.php [FrameworkBundle] avoids cache:clear to break if new/old folders already exist [HttpKernel] Fixed possible profiler token collision (closes #7272, closes #7171) [ClassLoader] tweaked test [ClassLoader] made DebugClassLoader idempotent [DomCrawler] Fix relative path handling in links Conflicts: src/Symfony/Component/DomCrawler/Link.php src/Symfony/Component/Finder/Iterator/DepthRangeFilterIterator.php src/Symfony/Component/Routing/RouteCompiler.php
This commit is contained in:
commit
7c66dffa6b
@ -62,23 +62,32 @@ EOF
|
||||
throw new \RuntimeException(sprintf('Unable to write in the "%s" directory', $realCacheDir));
|
||||
}
|
||||
|
||||
$filesystem = $this->getContainer()->get('filesystem');
|
||||
$kernel = $this->getContainer()->get('kernel');
|
||||
$output->writeln(sprintf('Clearing the cache for the <info>%s</info> environment with debug <info>%s</info>', $kernel->getEnvironment(), var_export($kernel->isDebug(), true)));
|
||||
|
||||
$this->getContainer()->get('cache_clearer')->clear($realCacheDir);
|
||||
|
||||
if ($filesystem->exists($oldCacheDir)) {
|
||||
$filesystem->remove($oldCacheDir);
|
||||
}
|
||||
|
||||
if ($input->getOption('no-warmup')) {
|
||||
rename($realCacheDir, $oldCacheDir);
|
||||
$filesystem->rename($realCacheDir, $oldCacheDir);
|
||||
} else {
|
||||
$warmupDir = $realCacheDir.'_new';
|
||||
|
||||
if ($filesystem->exists($warmupDir)) {
|
||||
$filesystem->remove($warmupDir);
|
||||
}
|
||||
|
||||
$this->warmup($warmupDir, !$input->getOption('no-optional-warmers'));
|
||||
|
||||
rename($realCacheDir, $oldCacheDir);
|
||||
rename($warmupDir, $realCacheDir);
|
||||
$filesystem->rename($realCacheDir, $oldCacheDir);
|
||||
$filesystem->rename($warmupDir, $realCacheDir);
|
||||
}
|
||||
|
||||
$this->getContainer()->get('filesystem')->remove($oldCacheDir);
|
||||
$filesystem->remove($oldCacheDir);
|
||||
}
|
||||
|
||||
protected function warmup($warmupDir, $enableOptionalWarmers = true)
|
||||
|
@ -26,8 +26,8 @@ class RedirectController extends ContainerAware
|
||||
/**
|
||||
* Redirects to another route with the given name.
|
||||
*
|
||||
* The response status code is 301 if the permanent parameter is false (default),
|
||||
* and 302 if the redirection is permanent.
|
||||
* The response status code is 302 if the permanent parameter is false (default),
|
||||
* and 301 if the redirection is permanent.
|
||||
*
|
||||
* In case the route name is empty, the status code will be 404 when permanent is false
|
||||
* and 410 otherwise.
|
||||
@ -52,8 +52,8 @@ class RedirectController extends ContainerAware
|
||||
/**
|
||||
* Redirects to a URL.
|
||||
*
|
||||
* The response status code is 301 if the permanent parameter is false (default),
|
||||
* and 302 if the redirection is permanent.
|
||||
* The response status code is 302 if the permanent parameter is false (default),
|
||||
* and 301 if the redirection is permanent.
|
||||
*
|
||||
* In case the path is empty, the status code will be 404 when permanent is false
|
||||
* and 410 otherwise.
|
||||
|
@ -53,7 +53,7 @@ class DebugClassLoader
|
||||
}
|
||||
|
||||
foreach ($functions as $function) {
|
||||
if (is_array($function) && method_exists($function[0], 'findFile')) {
|
||||
if (is_array($function) && !$function[0] instanceof self && method_exists($function[0], 'findFile')) {
|
||||
$function = array(new static($function[0]), 'loadClass');
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\ClassLoader\Tests;
|
||||
|
||||
use Symfony\Component\ClassLoader\ClassLoader;
|
||||
use Symfony\Component\ClassLoader\DebugClassLoader;
|
||||
|
||||
class DebugClassLoaderTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
private $loader;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->loader = new ClassLoader();
|
||||
spl_autoload_register(array($this->loader, 'loadClass'));
|
||||
}
|
||||
|
||||
protected function tearDown()
|
||||
{
|
||||
spl_autoload_unregister(array($this->loader, 'loadClass'));
|
||||
}
|
||||
|
||||
public function testIdempotence()
|
||||
{
|
||||
DebugClassLoader::enable();
|
||||
DebugClassLoader::enable();
|
||||
|
||||
$functions = spl_autoload_functions();
|
||||
foreach ($functions as $function) {
|
||||
if (is_array($function) && $function[0] instanceof DebugClassLoader) {
|
||||
$reflClass = new \ReflectionClass($function[0]);
|
||||
$reflProp = $reflClass->getProperty('classFinder');
|
||||
$reflProp->setAccessible(true);
|
||||
|
||||
$this->assertNotInstanceOf('Symfony\Component\ClassLoader\DebugClassLoader', $reflProp->getValue($function[0]));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
throw new \Exception('DebugClassLoader did not register');
|
||||
}
|
||||
}
|
@ -120,13 +120,18 @@ class Link
|
||||
return $baseUri.$uri;
|
||||
}
|
||||
|
||||
$baseUri = preg_replace('#^(.*?//[^/]+)(?:\/.*)?$#', '$1', $this->currentUri);
|
||||
|
||||
// absolute path
|
||||
if ('/' === $uri[0]) {
|
||||
return preg_replace('#^(.*?//[^/]+)(?:\/.*)?$#', '$1', $this->currentUri).$uri;
|
||||
return $baseUri.$uri;
|
||||
}
|
||||
|
||||
// relative path
|
||||
return substr($this->currentUri, 0, strrpos($this->currentUri, '/') + 1).$uri;
|
||||
$path = parse_url(substr($this->currentUri, strlen($baseUri)), PHP_URL_PATH);
|
||||
$path = $this->canonicalizePath(substr($path, 0, strrpos($path, '/')).'/'.$uri);
|
||||
|
||||
return $baseUri.('' === $path || '/' !== $path[0] ? '/' : '').$path;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -139,6 +144,36 @@ class Link
|
||||
return $this->node->getAttribute('href');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the canonicalized URI path (see RFC 3986, section 5.2.4)
|
||||
*
|
||||
* @param string $path URI path
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function canonicalizePath($path)
|
||||
{
|
||||
if ('' === $path || '/' === $path) {
|
||||
return $path;
|
||||
}
|
||||
|
||||
if ('.' === substr($path, -1)) {
|
||||
$path = $path.'/';
|
||||
}
|
||||
|
||||
$output = array();
|
||||
|
||||
foreach (explode('/', $path) as $segment) {
|
||||
if ('..' === $segment) {
|
||||
array_pop($output);
|
||||
} elseif ('.' !== $segment) {
|
||||
array_push($output, $segment);
|
||||
}
|
||||
}
|
||||
|
||||
return implode('/', $output);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets current \DOMNode instance.
|
||||
*
|
||||
|
@ -101,6 +101,21 @@ class LinkTest extends \PHPUnit_Framework_TestCase
|
||||
array('?foo=2', 'http://localhost/bar?foo=1', 'http://localhost/bar?foo=2'),
|
||||
array('?foo=2', 'http://localhost/bar/?foo=1', 'http://localhost/bar/?foo=2'),
|
||||
array('?bar=2', 'http://localhost?foo=1', 'http://localhost?bar=2'),
|
||||
|
||||
array('.', 'http://localhost/foo/bar/baz', 'http://localhost/foo/bar/'),
|
||||
array('./', 'http://localhost/foo/bar/baz', 'http://localhost/foo/bar/'),
|
||||
array('./foo', 'http://localhost/foo/bar/baz', 'http://localhost/foo/bar/foo'),
|
||||
array('..', 'http://localhost/foo/bar/baz', 'http://localhost/foo/'),
|
||||
array('../', 'http://localhost/foo/bar/baz', 'http://localhost/foo/'),
|
||||
array('../foo', 'http://localhost/foo/bar/baz', 'http://localhost/foo/foo'),
|
||||
array('../..', 'http://localhost/foo/bar/baz', 'http://localhost/'),
|
||||
array('../../', 'http://localhost/foo/bar/baz', 'http://localhost/'),
|
||||
array('../../foo', 'http://localhost/foo/bar/baz', 'http://localhost/foo'),
|
||||
array('../../foo', 'http://localhost/bar/foo/', 'http://localhost/foo'),
|
||||
array('../bar/../../foo', 'http://localhost/bar/foo/', 'http://localhost/foo'),
|
||||
array('../bar/./../../foo', 'http://localhost/bar/foo/', 'http://localhost/foo'),
|
||||
array('../../', 'http://localhost/', 'http://localhost/'),
|
||||
array('../../', 'http://localhost', 'http://localhost/'),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ class DepthRangeFilterIterator extends FilterIterator
|
||||
public function __construct(\RecursiveIteratorIterator $iterator, $minDepth = 0, $maxDepth = INF)
|
||||
{
|
||||
$this->minDepth = $minDepth;
|
||||
$iterator->setMaxDepth(INF === $maxDepth ? -1 : $maxDepth);
|
||||
$iterator->setMaxDepth(PHP_INT_MAX === $maxDepth ? -1 : $maxDepth);
|
||||
|
||||
parent::__construct($iterator);
|
||||
}
|
||||
|
@ -204,7 +204,7 @@ class Profiler
|
||||
return;
|
||||
}
|
||||
|
||||
$profile = new Profile(uniqid());
|
||||
$profile = new Profile(sha1(uniqid(mt_rand(), true)));
|
||||
$profile->setTime(time());
|
||||
$profile->setUrl($request->getUri());
|
||||
$profile->setIp($request->getClientIp());
|
||||
|
@ -147,7 +147,7 @@ class RouteCompiler implements RouteCompilerInterface
|
||||
}
|
||||
|
||||
// find the first optional token
|
||||
$firstOptional = INF;
|
||||
$firstOptional = PHP_INT_MAX;
|
||||
if (!$isHost) {
|
||||
for ($i = count($tokens) - 1; $i >= 0; $i--) {
|
||||
$token = $tokens[$i];
|
||||
|
Reference in New Issue
Block a user