Merge branch '4.0'

* 4.0:
  fixed tests
  [Finder] Remove duplicate slashes in filenames
  [VarDumper] Skip some tests on custom xdebug.file_link_format
  [WebProfilerBundle][HttpKernel] Make FileLinkFormatter URL format generation lazy
  bumped Symfony version to 4.0.8
  updated VERSION for 4.0.7
  updated CHANGELOG for 4.0.7
  bumped Symfony version to 3.4.8
  updated VERSION for 3.4.7
  updated CHANGELOG for 3.4.7
This commit is contained in:
Fabien Potencier 2018-04-04 07:11:41 +02:00
commit 54268f1266
9 changed files with 136 additions and 25 deletions

View File

@ -7,6 +7,49 @@ in 4.0 minor versions.
To get the diff for a specific change, go to https://github.com/symfony/symfony/commit/XXX where XXX is the change hash
To get the diff between two versions, go to https://github.com/symfony/symfony/compare/v4.0.0...v4.0.1
* 4.0.7 (2018-04-03)
* bug #26387 [Yaml] Fix regression when trying to parse multiline (antograssiot)
* bug #26749 Add PHPDbg support to HTTP components (hkdobrev)
* bug #26609 [Console] Fix check of color support on Windows (mlocati)
* bug #26727 [HttpCache] Unlink tmp file on error (Chansig)
* bug #26675 [HttpKernel] DumpDataCollector: do not flush when a dumper is provided (ogizanagi)
* bug #26663 [TwigBridge] Fix rendering of currency by MoneyType (ro0NL)
* bug #26595 [DI] Do not suggest writing an implementation when multiple exist (chalasr)
* bug #26662 [DI] Fix hardcoded cache dir for warmups (nicolas-grekas)
* bug #26677 Support phpdbg SAPI in Debug::enable() (hkdobrev)
* bug #26600 [Routing] Fixed the importing of files using glob patterns that match multiple resources (skalpa)
* bug #26589 [Ldap] cast to string when checking empty passwords (ismail1432)
* bug #26626 [WebProfilerBundle] use the router to resolve file links (nicolas-grekas)
* bug #26634 [DI] Cleanup remainings from autoregistration (nicolas-grekas)
* bug #26635 [DI] Dont tell about autoregistration in strict autowiring mode (nicolas-grekas)
* bug #26621 [Form] no type errors with invalid submitted data types (xabbuh)
* bug #26612 [PHPunit] suite variable should be used (prisis)
* bug #26337 [Finder] Fixed leading/trailing / in filename (lyrixx)
* bug #26584 [TwigBridge] allow html5 compatible rendering of forms with null names (systemist)
* bug #24401 [Form] Change datetime to datetime-local for HTML5 datetime input (pierredup)
* bug #26513 [FrameworkBundle] Respect debug mode when warm up annotations (Strate)
* bug #26370 [Security] added userChecker to SimpleAuthenticationProvider (i3or1s)
* bug #26569 [BrowserKit] Fix cookie path handling when $domain is null (dunglas)
* bug #26273 [Security][Profiler] Display the original expression in 'Access decision log' (lyrixx)
* bug #26427 [DependencyInjection] fix regression when extending the Container class without a constructor (lsmith77)
* bug #26562 [Bridge\PhpUnit] Cannot autoload class "\Symfony\Bridge\PhpUnit\SymfonyTestsListener" (Jake Bishop)
* bug #26598 Fixes #26563 (open_basedir restriction in effect) (temperatur)
* bug #26568 [Debug] Reset previous exception handler earlier to prevent infinite loop (nicolas-grekas)
* bug #26590 Make sure form errors is valid HTML (Nyholm)
* bug #26567 [DoctrineBridge] Don't rely on ClassMetadataInfo->hasField in DoctrineOrmTypeGuesser anymore (fancyweb)
* feature #26408 Readd 'form_label_errors' block to disable errors on form labels (birkof)
* bug #26591 [TwigBridge] Make sure we always render errors. Eventhough labels are disabled (Nyholm)
* bug #26356 [FrameworkBundle] HttpCache is not longer abstract (lyrixx)
* bug #26548 [DomCrawler] Change bad wording in ChoiceFormField::untick (dunglas)
* bug #26482 [PhpUnitBridge] Ability to use different composer.json file (amcastror)
* bug #26443 [Fix][HttpFoundation] Fix the updating of timestamp in the MemcachedSessionHandler (Alessandro Loffredo)
* bug #26400 [Config] ReflectionClassResource check abstract class (andrey1s)
* bug #26433 [DomCrawler] extract(): fix a bug when the attribute list is empty (dunglas)
* bug #26041 Display the Welcome Page when there is no homepage defined (javiereguiluz)
* bug #26452 [Intl] Load locale aliases to support alias fallbacks (jakzal)
* bug #26450 [CssSelector] Fix CSS identifiers parsing - they can start with dash (jakubkulhan)
* 4.0.6 (2018-03-05)
* bug #26393 [DI] Skip resource tracking if disabled (chalasr)

View File

@ -11,10 +11,13 @@
namespace Symfony\Bundle\WebProfilerBundle\DependencyInjection;
use Symfony\Component\DependencyInjection\Argument\ServiceClosureArgument;
use Symfony\Component\DependencyInjection\Extension\Extension;
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\HttpKernel\Kernel;
use Symfony\Bundle\WebProfilerBundle\EventListener\WebDebugToolbarListener;
/**
@ -51,6 +54,11 @@ class WebProfilerExtension extends Extension
$container->setParameter('web_profiler.debug_toolbar.intercept_redirects', $config['intercept_redirects']);
$container->setParameter('web_profiler.debug_toolbar.mode', $config['toolbar'] ? WebDebugToolbarListener::ENABLED : WebDebugToolbarListener::DISABLED);
}
if (Kernel::VERSION_ID >= 30408 || Kernel::VERSION_ID >= 40008) {
$container->getDefinition('debug.file_link_formatter')
->replaceArgument(3, new ServiceClosureArgument(new Reference('debug.file_link_formatter.url_format')));
}
}
/**

View File

@ -55,20 +55,14 @@
<argument>%debug.file_link_format%</argument>
<argument type="service" id="request_stack" on-invalid="ignore" />
<argument>%kernel.project_dir%</argument>
<argument type="service">
<service class="string">
<factory function="implode" />
<argument type="collection">
<argument type="service">
<service class="string">
<factory service="router" method="generate" />
<argument>_profiler_open_file</argument>
</service>
</argument>
<argument>?file=%%f&amp;line=%%l#line%%l</argument>
</argument>
</service>
</argument>
<argument>/_profiler/open?file=%%f&amp;line=%%l#line%%l</argument>
</service>
<service id="debug.file_link_formatter.url_format" class="string">
<factory class="Symfony\Component\HttpKernel\Debug\FileLinkFormatter" method="generateUrlFormat" />
<argument type="service" id="router" />
<argument>_profiler_open_file</argument>
<argument>?file=%%f&amp;line=%%l#line%%l</argument>
</service>
</services>
</container>

View File

@ -540,9 +540,9 @@ class Finder implements \IteratorAggregate, \Countable
foreach ((array) $dirs as $dir) {
if (is_dir($dir)) {
$resolvedDirs[] = $dir;
$resolvedDirs[] = $this->normalizeDir($dir);
} elseif ($glob = glob($dir, (defined('GLOB_BRACE') ? GLOB_BRACE : 0) | GLOB_ONLYDIR)) {
$resolvedDirs = array_merge($resolvedDirs, $glob);
$resolvedDirs = array_merge($resolvedDirs, array_map(array($this, 'normalizeDir'), $glob));
} else {
throw new \InvalidArgumentException(sprintf('The "%s" directory does not exist.', $dir));
}
@ -723,4 +723,16 @@ class Finder implements \IteratorAggregate, \Countable
return $iterator;
}
/**
* Normalizes given directory names by removing trailing slashes.
*
* @param string $dir
*
* @return string
*/
private function normalizeDir($dir)
{
return rtrim($dir, '/'.\DIRECTORY_SEPARATOR);
}
}

View File

@ -28,7 +28,7 @@ class SplFileInfo extends \SplFileInfo
*/
public function __construct(string $file, string $relativePath, string $relativePathname)
{
parent::__construct(realpath($file) ?: $file);
parent::__construct($file);
$this->relativePath = $relativePath;
$this->relativePathname = $relativePathname;
}

View File

@ -48,15 +48,40 @@ class FinderTest extends Iterator\RealIteratorTestCase
public function testRemoveTrailingSlash()
{
if ('\\' === \DIRECTORY_SEPARATOR) {
$this->markTestSkipped('This test cannot be run on Windows.');
$finder = $this->buildFinder();
$expected = $this->toAbsolute(array('foo/bar.tmp', 'test.php', 'test.py', 'foo bar'));
$in = self::$tmpDir.'//';
$this->assertIterator($expected, $finder->in($in)->files()->getIterator());
}
public function testSymlinksNotResolved()
{
if ('\\' === DIRECTORY_SEPARATOR) {
$this->markTestSkipped('symlinks are not supported on Windows');
}
$finder = $this->buildFinder();
$expected = $this->toAbsolute(array('foo/bar.tmp', 'test.php', 'test.py', 'foo bar'));
$in = '//'.realpath(self::$tmpDir).'//';
symlink($this->toAbsolute('foo'), $this->toAbsolute('baz'));
$expected = $this->toAbsolute(array('baz/bar.tmp'));
$in = self::$tmpDir.'/baz/';
try {
$this->assertIterator($expected, $finder->in($in)->files()->getIterator());
unlink($this->toAbsolute('baz'));
} catch (\Exception $e) {
unlink($this->toAbsolute('baz'));
throw $e;
}
}
public function testBackPathNotNormalized()
{
$finder = $this->buildFinder();
$expected = $this->toAbsolute(array('foo/../foo/bar.tmp'));
$in = self::$tmpDir.'/foo/../foo/';
$this->assertIterator($expected, $finder->in($in)->files()->getIterator());
}
@ -275,7 +300,7 @@ class FinderTest extends Iterator\RealIteratorTestCase
public function testInWithGlob()
{
$finder = $this->buildFinder();
$finder->in(array(__DIR__.'/Fixtures/*/B/C', __DIR__.'/Fixtures/*/*/B/C'))->getIterator();
$finder->in(array(__DIR__.'/Fixtures/*/B/C/', __DIR__.'/Fixtures/*/*/B/C/'))->getIterator();
$this->assertIterator($this->toAbsoluteFixtures(array('A/B/C/abc.dat', 'copy/A/B/C/abc.dat.copy')), $finder);
}
@ -528,8 +553,8 @@ class FinderTest extends Iterator\RealIteratorTestCase
$finder->in($locations)->depth('< 10')->name('*.neon');
$expected = array(
__DIR__.DIRECTORY_SEPARATOR.'Fixtures'.DIRECTORY_SEPARATOR.'one'.DIRECTORY_SEPARATOR.'b'.DIRECTORY_SEPARATOR.'c.neon',
__DIR__.DIRECTORY_SEPARATOR.'Fixtures'.DIRECTORY_SEPARATOR.'one'.DIRECTORY_SEPARATOR.'b'.DIRECTORY_SEPARATOR.'d.neon',
__DIR__.'/Fixtures/one'.DIRECTORY_SEPARATOR.'b'.DIRECTORY_SEPARATOR.'c.neon',
__DIR__.'/Fixtures/one'.DIRECTORY_SEPARATOR.'b'.DIRECTORY_SEPARATOR.'d.neon',
);
$this->assertIterator($expected, $finder);

View File

@ -13,6 +13,8 @@ namespace Symfony\Component\HttpKernel\Debug;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\Routing\Exception\ExceptionInterface;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
/**
* Formats debug file links.
@ -26,7 +28,10 @@ class FileLinkFormatter implements \Serializable
private $baseDir;
private $urlFormat;
public function __construct($fileLinkFormat = null, RequestStack $requestStack = null, string $baseDir = null, string $urlFormat = null)
/**
* @param string|\Closure $urlFormat the URL format, or a closure that returns it on-demand
*/
public function __construct($fileLinkFormat = null, RequestStack $requestStack = null, string $baseDir = null, $urlFormat = null)
{
$fileLinkFormat = $fileLinkFormat ?: ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format');
if ($fileLinkFormat && !is_array($fileLinkFormat)) {
@ -66,6 +71,18 @@ class FileLinkFormatter implements \Serializable
$this->fileLinkFormat = unserialize($serialized, array('allowed_classes' => false));
}
/**
* @internal
*/
public static function generateUrlFormat(UrlGeneratorInterface $router, $routeName, $queryString)
{
try {
return $router->generate($routeName).$queryString;
} catch (ExceptionInterface $e) {
return null;
}
}
private function getFileLinkFormat()
{
if ($this->fileLinkFormat) {
@ -74,6 +91,10 @@ class FileLinkFormatter implements \Serializable
if ($this->requestStack && $this->baseDir && $this->urlFormat) {
$request = $this->requestStack->getMasterRequest();
if ($request instanceof Request) {
if ($this->urlFormat instanceof \Closure && !$this->urlFormat = \call_user_func($this->urlFormat)) {
return;
}
return array(
$request->getSchemeAndHttpHost().$request->getBaseUrl().$this->urlFormat,
$this->baseDir.DIRECTORY_SEPARATOR, '',

View File

@ -126,6 +126,10 @@ EODUMP;
public function testHtmlDump()
{
if (ini_get('xdebug.file_link_format') || get_cfg_var('xdebug.file_link_format')) {
$this->markTestSkipped('A custom file_link_format is defined.');
}
$e = $this->getTestException(1);
ExceptionCaster::$srcContext = -1;

View File

@ -22,6 +22,10 @@ class HtmlDumperTest extends TestCase
{
public function testGet()
{
if (ini_get('xdebug.file_link_format') || get_cfg_var('xdebug.file_link_format')) {
$this->markTestSkipped('A custom file_link_format is defined.');
}
require __DIR__.'/../Fixtures/dumb-var.php';
$dumper = new HtmlDumper('php://output');