8000 Merge branch '4.0' · symfony/symfony@54268f1 · GitHub
[go: up one dir, main page]

Skip to content

Commit 54268f1

Browse files
committed
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
2 parents cffd97a + f76624a commit 54268f1

File tree

9 files changed

+136
-25
lines changed

9 files changed

+136
-25
lines changed

CHANGELOG-4.0.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,49 @@ in 4.0 minor versions.
77
To get the diff for a specific change, go to https://github.com/symfony/symfony/commit/XXX where XXX is the change hash
88
To get the diff between two versions, go to https://github.com/symfony/symfony/compare/v4.0.0...v4.0.1
99

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

1255
* bug #26393 [DI] Skip resource tracking if disabled (chalasr)

src/Symfony/Bundle/WebProfilerBundle/DependencyInjection/WebProfilerExtension.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,13 @@
1111

1212
namespace Symfony\Bundle\WebProfilerBundle\DependencyInjection;
1313

14+
use Symfony\Component\DependencyInjection\Argument\ServiceClosureArgument;
1415
use Symfony\Component\DependencyInjection\Extension\Extension;
1516
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
1617
use Symfony\Component\DependencyInjection\ContainerBuilder;
18+
use Symfony\Component\DependencyInjection\Reference;
1719
use Symfony\Component\Config\FileLocator;
20+
use Symfony\Component\HttpKernel\Kernel;
1821
use Symfony\Bundle\WebProfilerBundle\EventListener\WebDebugToolbarListener;
1922

2023
/**
@@ -51,6 +54,11 @@ public function load(array $configs, ContainerBuilder $container)
5154
$container->setParameter('web_profiler.debug_toolbar.intercept_redirects', $config['intercept_redirects']);
5255
$container->setParameter('web_profiler.debug_toolbar.mode', $config['toolbar'] ? WebDebugToolbarListener::ENABLED : WebDebugToolbarListener::DISABLED);
5356
}
57+
58+
if (Kernel::VERSION_ID >= 30408 || Kernel::VERSION_ID >= 40008) {
59+
$container->getDefinition('debug.file_link_formatter')
60+
->replaceArgument(3, new ServiceClosureArgument(new Reference('debug.file_link_formatter.url_format')));
61+
}
5462
}
5563

5664
/**

src/Symfony/Bundle/WebProfilerBundle/Resources/config/profiler.xml

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -55,20 +55,14 @@
5555
<argument>%debug.file_link_format%</argument>
5656
<argument type="service" id="request_stack" on-invalid="ignore" />
5757
<argument>%kernel.project_dir%</argument>
58-
<argument type="service">
59-
<service class="string">
60-
<factory function="implode" />
61-
<argument type="collection">
62-
<argument type="service">
63-
<service class="string">
64-
<factory service="router" method="generate" />
65-
<argument>_profiler_open_file</argument>
66-
</service>
67-
</argument>
68-
<argument>?file=%%f&amp;line=%%l#line%%l</argument>
69-
</argument>
70-
</service>
71-
</argument>
58+
<argument>/_profiler/open?file=%%f&amp;line=%%l#line%%l</argument>
59+
</service>
60+
61+
<service id="debug.file_link_formatter.url_format" class="string">
62+
<factory class="Symfony\Component\HttpKernel\Debug\FileLinkFormatter" method="generateUrlFormat" />
63+
<argument type="service" id="router" />
64+
<argument>_profiler_open_file</argument>
65+
<argument>?file=%%f&amp;line=%%l#line%%l</argument>
7266
</service>
7367
</services>
7468
</container>

src/Symfony/Component/Finder/Finder.php

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -540,9 +540,9 @@ public function in($dirs)
540540

541541
foreach ((array) $dirs as $dir) {
542542
if (is_dir($dir)) {
543-
$resolvedDirs[] = $dir;
543+
$resolvedDirs[] = $this->normalizeDir($dir);
544544
} elseif ($glob = glob($dir, (defined('GLOB_BRACE') ? GLOB_BRACE : 0) | GLOB_ONLYDIR)) {
545-
$resolvedDirs = array_merge($resolvedDirs, $glob);
545+
$resolvedDirs = array_merge($resolvedDirs, array_map(array($this, 'normalizeDir'), $glob));
546546
} else {
547547
throw new \InvalidArgumentException(sprintf('The "%s" directory does not exist.', $dir));
548548
}
@@ -723,4 +723,16 @@ private function searchInDirectory(string $dir): \Iterator
723723

724724
return $iterator;
725725
}
726+
727+
/**
728+
* Normalizes given directory names by removing trailing slashes.
729+
*
730+
* @param string $dir
731+
*
732+
* @return string
733+
*/
734+
private function normalizeDir($dir)
735+
{
736+
return rtrim($dir, '/'.\DIRECTORY_SEPARATOR);
737+
}
726738
}

src/Symfony/Component/Finder/SplFileInfo.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class SplFileInfo extends \SplFileInfo
2828
*/
2929
public function __construct(string $file, string $relativePath, string $relativePathname)
3030
{
31-
parent::__construct(realpath($file) ?: $file);
31+
parent::__construct($file);
3232
$this->relativePath = $relativePath;
3333
$this->relativePathname = $relativePathname;
3434
}

src/Symfony/Component/Finder/Tests/FinderTest.php

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,40 @@ public function testFiles()
4848

4949
public function testRemoveTrailingSlash()
5050
{
51-
if ('\\' === \DIRECTORY_SEPARATOR) {
52-
$this->markTestSkipped('This test cannot be run on Windows.');
51+
$finder = $this->buildFinder();
52+
53+
$expected = $this->toAbsolute(array('foo/bar.tmp', 'test.php', 'test.py', 'foo bar'));
54+
$in = self::$tmpDir.'//';
55+
56+
$this->assertIterator($expected, $finder->in($in)->files()->getIterator());
57+
}
58+
59+
public function testSymlinksNotResolved()
60+
{
61+
if ('\\' === DIRECTORY_SEPARATOR) {
62+
$this->markTestSkipped('symlinks are not supported on Windows');
5363
}
5464

5565
$finder = $this->buildFinder();
5666

57-
$expected = $this->toAbsolute(array('foo/bar.tmp', 'test.php', 'test.py', 'foo bar'));
58-
$in = '//'.realpath(self::$tmpDir).'//';
67+
symlink($this->toAbsolute('foo'), $this->toAbsolute('baz'));
68+
$expected = $this->toAbsolute(array('baz/bar.tmp'));
69+
$in = self::$tmpDir.'/baz/';
70+
try {
71+
$this->assertIterator($expected, $finder->in($in)->files()->getIterator());
72+
unlink($this->toAbsolute('baz'));
73+
} catch (\Exception $e) {
74+
unlink($this->toAbsolute('baz'));
75+
throw $e;
76+
}
77+
}
78+
79+
public function testBackPathNotNormalized()
80+
{
81+
$finder = $this->buildFinder();
5982

83+
$expected = $this->toAbsolute(array('foo/../foo/bar.tmp'));
84+
$in = self::$tmpDir.'/foo/../foo/';
6085
$this->assertIterator($expected, $finder->in($in)->files()->getIterator());
6186
}
6287

@@ -275,7 +300,7 @@ public function testInWithNonExistentDirectory()
275300
public function testInWithGlob()
276301
{
277302
$finder = $this->buildFinder();
278-
$finder->in(array(__DIR__.'/Fixtures/*/B/C', __DIR__.'/Fixtures/*/*/B/C'))->getIterator();
303+
$finder->in(array(__DIR__.'/Fixtures/*/B/C/', __DIR__.'/Fixtures/*/*/B/C/'))->getIterator();
279304

280305
$this->assertIterator($this->toAbsoluteFixtures(array('A/B/C/abc.dat', 'copy/A/B/C/abc.dat.copy')), $finder);
281306
}
@@ -528,8 +553,8 @@ public function testMultipleLocationsWithSubDirectories()
528553
$finder->in($locations)->depth('< 10')->name('*.neon');
529554

530555
$expected = array(
531-
__DIR__.DIRECTORY_SEPARATOR.'Fixtures'.DIRECTORY_SEPARATOR.'one'.DIRECTORY_SEPARATOR.'b'.DIRECTORY_SEPARATOR.'c.neon',
532-
__DIR__.DIRECTORY_SEPARATOR.'Fixtures'.DIRECTORY_SEPARATOR.'one'.DIRECTORY_SEPARATOR.'b'.DIRECTORY_SEPARATOR.'d.neon',
556+
__DIR__.'/Fixtures/one'.DIRECTORY_SEPARATOR.'b'.DIRECTORY_SEPARATOR.'c.neon',
557+
__DIR__.'/Fixtures/one'.DIRECTORY_SEPARATOR.'b'.DIRECTORY_SEPARATOR.'d.neon',
533558
);
534559

535560
$this->assertIterator($expected, $finder);

src/Symfony/Component/HttpKernel/Debug/FileLinkFormatter.php

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313

1414
use Symfony\Component\HttpFoundation\Request;
1515
use Symfony\Component\HttpFoundation\RequestStack;
16+
use Symfony\Component\Routing\Exception\ExceptionInterface;
17+
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
1618

1719
/**
1820
* Formats debug file links.
@@ -26,7 +28,10 @@ class FileLinkFormatter implements \Serializable
2628
private $baseDir;
2729
private $urlFormat;
2830

29-
public function __construct($fileLinkFormat = null, RequestStack $requestStack = null, string $baseDir = null, string $urlFormat = null)
31+
/**
32+
* @param string|\Closure $urlFormat the URL format, or a closure that returns it on-demand
33+
*/
34+
public function __construct($fileLinkFormat = null, RequestStack $requestStack = null, string $baseDir = null, $urlFormat = null)
3035
{
3136
$fileLinkFormat = $fileLinkFormat ?: ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format');
3237
if ($fileLinkFormat && !is_array($fileLinkFormat)) {
@@ -66,6 +71,18 @@ public function unserialize($serialized)
6671
$this->fileLinkFormat = unserialize($serialized, array('allowed_classes' => false));
6772
}
6873

74+
/**
75+
* @internal
76+
*/
77+
public static function generateUrlFormat(UrlGeneratorInterface $router, $routeName, $queryString)
78+
{
79+
try {
80+
return $router->generate($routeName).$queryString;
81+
} catch (ExceptionInterface $e) {
82+
return null;
83+
}
84+
}
85+
6986
private function getFileLinkFormat()
7087
{
7188
if ($this->fileLinkFormat) {
@@ -74,6 +91,10 @@ private function getFileLinkFormat()
7491
if ($this->requestStack && $this->baseDir && $this->urlFormat) {
7592
$request = $this->requestStack->getMasterRequest();
7693
if ($request instanceof Request) {
94+
if ($this->urlFormat instanceof \Closure && !$this->urlFormat = \call_user_func($this->urlFormat)) {
95+
return;
96+
}
97+
7798
return array(
7899
$request->getSchemeAndHttpHost().$request->getBaseUrl().$this->urlFormat,
79100
$this->baseDir.DIRECTORY_SEPARATOR, '',

src/Symfony/Component/VarDumper/Tests/Caster/ExceptionCasterTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,10 @@ public function testNoSrcContext()
126126

127127
public function testHtmlDump()
128128
{
129+
if (ini_get('xdebug.file_link_format') || get_cfg_var('xdebug.file_link_format')) {
130+
$this->markTestSkipped('A custom file_link_format is defined.');
131+
}
132+
129133
$e = $this->getTestException(1);
130134
ExceptionCaster::$srcContext = -1;
131135

src/Symfony/Component/VarDumper/Tests/Dumper/HtmlDumperTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ class HtmlDumperTest extends TestCase
2222
{
2323
public function testGet()
2424
{
25+
if (ini_get('xdebug.file_link_format') || get_cfg_var('xdebug.file_link_format')) {
26+
$this->markTestSkipped('A custom file_link_format is defined.');
27+
}
28+
2529
require __DIR__.'/../Fixtures/dumb-var.php';
2630

2731
$dumper = new HtmlDumper('php://output');

0 commit comments

Comments
 (0)
0