8000 Merge branch '6.2' into 6.3 · symfony/symfony@844b1d9 · GitHub
[go: up one dir, main page]

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 844b1d9

Browse files
Merge branch '6.2' into 6.3
* 6.2: [PhpUnitBridge] Kill the last concurrent process when it stales for more than 60s [Intl] fix test [Intl] Use VarExporter::export() in PhpBundleWriter Use triggering class to generate baseline for deprecation messages from DebugClassLoader [Security] Fix false-string handling in RememberMeAuthenticator [CssSelector] Tests on Xpath translator will always pass [Serializer] Fix Normalizer not utilizing converted name for index variadic param [DepdencyInjection] Fix costly logic when checking errored definitions Fix merge fix children cond [DoctrineBridge] Load refreshed user proxy [DependencyInjection] Don't ignore attributes on the actual decorator [FrameworkBundle] Prevent `cache:clear` to lose files on subsequent runs
2 parents e0b8655 + 6cb2647 commit 844b1d9

File tree

535 files changed

+58409
-58422
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

535 files changed

+58409
-58422
lines changed

src/Symfony/Bridge/Doctrine/Security/User/EntityUserProvider.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Doctrine\Persistence\Mapping\ClassMetadata;
1616
use Doctrine\Persistence\ObjectManager;
1717
use Doctrine\Persistence\ObjectRepository;
< 10000 code>18+
use Doctrine\Persistence\Proxy;
1819
use Symfony\Component\Security\Core\Exception\UnsupportedUserException;
1920
use Symfony\Component\Security\Core\Exception\UserNotFoundException;
2021
use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
@@ -97,6 +98,10 @@ public function refreshUser(UserInterface $user): UserInterface
9798
}
9899
}
99100

101+
if ($refreshedUser instanceof Proxy && !$refreshedUser->__isInitialized()) {
102+
$refreshedUser->__load();
103+
}
104+
100105
return $refreshedUser;
101106
}
102107

src/Symfony/Bridge/Doctrine/Tests/Security/User/EntityUserProviderTest.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use Doctrine\Persistence\ManagerRegistry;
1717
use Doctrine\Persistence\ObjectManager;
1818
use Doctrine\Persistence\ObjectRepository;
19+
use Doctrine\Persistence\Proxy;
1920
use PHPUnit\Framework\TestCase;
2021
use Symfony\Bridge\Doctrine\Security\User\EntityUserProvider;
2122
use Symfony\Bridge\Doctrine\Security\User\UserLoaderInterface;
@@ -197,6 +198,27 @@ public function testPasswordUpgrades()
197198
$provider->upgradePassword($user, 'foobar');
198199
}
199200

201+
public function testRefreshedUserProxyIsLoaded()
202+
{
203+
$em = DoctrineTestHelper::createTestEntityManager();
204+
$this->createSchema($em);
205+
206+
$user = new User(1, 1, 'user1');
207+
208+
$em->persist($user);
209+
$em->flush();
210+
$em->clear();
211+
212+
// store a proxy in the identity map
213+
$em->getReference(User::class, ['id1' => 1, 'id2' => 1]);
214+
215+
$provider = new EntityUserProvider($this->getManager($em), User::class);
216+
$refreshedUser = $provider->refreshUser($user);
217+
218+
$this->assertInstanceOf(Proxy::class, $refreshedUser);
219+
$this->assertTrue($refreshedUser->__isInitialized());
220+
}
221+
200222
private function getManager($em, $name = null)
201223
{
202224
$manager = $this->createMock(ManagerRegistry::class);

src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler/Configuration.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,9 @@ public function isBaselineDeprecation(Deprecation $deprecation): bool
230230
return false;
231231
}
232232

233-
if ($deprecation->originatesFromAnObject()) {
233+
if ($deprecation->originatesFromDebugClassLoader()) {
234+
$location = $deprecation->triggeringClass();
235+
} elseif ($deprecation->originatesFromAnObject()) {
234236
$location = $deprecation->originatingClass().'::'.$deprecation->originatingMethod();
235237
} else {
236238
$location = 'procedural code';

src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler/Deprecation.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ class Deprecation
4141
private $originClass;
4242
private $originMethod;
4343
private $triggeringFile;
44+
private $triggeringClass;
4445

4546
/** @var string[] Absolute paths to vendor directories */
4647
private static $vendors;
@@ -61,6 +62,10 @@ class Deprecation
6162
*/
6263
public function __construct($message, array $trace, $file, $languageDeprecation = false)
6364
{
65+
if (DebugClassLoader::class === ($trace[2]['class'] ?? '')) {
66+
$this->triggeringClass = $trace[2]['args'][0];
67+
}
68+
6469
switch ($trace[2]['function'] ?? '') {
6570
case 'trigger_deprecation':
6671
$file = $trace[2]['file'];
@@ -167,6 +172,26 @@ private function lineShouldBeSkipped(array $line)
167172
return 'ReflectionMethod' === $class || 0 === strpos($class, 'PHPUnit\\');
168173
}
169174

175+
/**
176+
* @return bool
177+
*/
178+
public function originatesFromDebugClassLoader()
179+
{
180+
return isset($this->triggeringClass);
181+
}
182+
183+
/**
184+
* @return string
185+
*/
186+
public function triggeringClass()
187+
{
188+
if (null === $this->triggeringClass) {
189+
throw new \LogicException('Check with originatesFromDebugClassLoader() before calling this method.');
190+
}
191+
192+
return $this->triggeringClass;
193+
}
194+
170195
/**
171196
* @return bool
172197
*/

src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/ConfigurationTest.php

Lines changed: 44 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Symfony\Bridge\PhpUnit\DeprecationErrorHandler\Configuration;
1616
use Symfony\Bridge\PhpUnit\DeprecationErrorHandler\Deprecation;
1717
use Symfony\Bridge\PhpUnit\DeprecationErrorHandler\DeprecationGroup;
18+
use Symfony\Component\ErrorHandler\DebugClassLoader;
1819

1920
class ConfigurationTest extends TestCase
2021
{
@@ -356,7 +357,7 @@ public function testBaselineGenerationEmptyFile()
356357
$this->assertTrue($configuration->isBaselineDeprecation(new Deprecation('Test message 1', $trace, '')));
357358
$configuration->writeBaseline();
358359
$this->assertEquals($filename, $configuration->getBaselineFile());
359-
$expected_baseline = [
360+
$expected = [
360361
[
361362
'location' => 'Symfony\Bridge\PhpUnit\Tests\DeprecationErrorHandler\ConfigurationTest::runTest',
362363
'message' => 'Test message 1',
@@ -368,7 +369,7 @@ public function testBaselineGenerationEmptyFile()
368369
'count' => 1,
369370
],
370371
];
371-
$this->assertEquals(json_encode($expected_baseline, \JSON_PRETTY_PRINT | \JSON_UNESCAPED_SLASHES), file_get_contents($filename));
372+
$this->assertEquals(json_encode($expected, \JSON_PRETTY_PRINT | \JSON_UNESCAPED_SLASHES), file_get_contents($filename));
372373
}
373374

374375
public function testBaselineGenerationNoFile()
@@ -383,7 +384,7 @@ public function testBaselineGenerationNoFile()
383384
$this->assertTrue($configuration->isBaselineDeprecation(new Deprecation('Test message 1', $trace, '')));
384385
$configuration->writeBaseline();
385386
$this->assertEquals($filename, $configuration->getBaselineFile());
386-
$expected_baseline = [
387+
$expected = [
387388
[
388389
'location' => 'Symfony\Bridge\PhpUnit\Tests\DeprecationErrorHandler\ConfigurationTest::runTest',
389390
'message' => 'Test message 1',
@@ -395,7 +396,7 @@ public function testBaselineGenerationNoFile()
395396
'count' => 2,
396397
],
397398
];
398-
$this->assertEquals(json_encode($expected_baseline, \JSON_PRETTY_PRINT | \JSON_UNESCAPED_SLASHES), file_get_contents($filename));
399+
$this->assertEquals(json_encode($expected, \JSON_PRETTY_PRINT | \JSON_UNESCAPED_SLASHES), file_get_contents($filename));
399400
}
400401

401402
public function testExistingBaseline()
@@ -447,7 +448,7 @@ public function testExistingBaselineAndGeneration()
447448
$this->assertTrue($configuration->isBaselineDeprecation(new Deprecation('Test message 3', $trace, '')));
448449
$configuration->writeBaseline();
449450
$this->assertEquals($filename, $configuration->getBaselineFile());
450-
$expected_baseline = [
451+
$expected = [
451452
[
452453
'location' => 'Symfony\Bridge\PhpUnit\Tests\DeprecationErrorHandler\ConfigurationTest::runTest',
453454
'message' => 'Test message 2',
@@ -459,7 +460,44 @@ public function testExistingBaselineAndGeneration()
459460
'count' => 1,
460461
],
461462
];
462-
$this->assertEquals(json_encode($expected_baseline, \JSON_PRETTY_PRINT | \JSON_UNESCAPED_SLASHES), file_get_contents($filename));
463+
$this->assertEquals(json_encode($expected, \JSON_PRETTY_PRINT | \JSON_UNESCAPED_SLASHES), file_get_contents($filename));
464+
}
465+
466+
public function testBaselineGenerationWithDeprecationTriggeredByDebugClassLoader()
467+
{
468+
$filename = $this->createFile();
469+
$configuration = Configuration::fromUrlEncodedString('generateBaseline=true&baselineFile='.urlencode($filename));
470+
471+
$trace = debug_backtrace();
472+
$this->assertTrue($configuration->isBaselineDeprecation(new Deprecation('Regular deprecation', $trace, '')));
473+
474+
$trace[2] = [
475+
'class' => DebugClassLoader::class,
476+
'function' => 'testBaselineGenerationWithDeprecationTriggeredByDebugClassLoader',
477+
'args' => [self::class]
478+
];
479+
480+
$deprecation = new Deprecation('Deprecation by debug class loader', $trace, '');
481+
482+
$this->assertTrue($deprecation->originatesFromDebugClassLoader());
483+
484+
$this->assertTrue($configuration->isBaselineDeprecation($deprecation));
485+
486+
$configuration->writeBaseline();
487+
$this->assertEquals($filename, $configuration->getBaselineFile());
488+
$expected = [
489+
[
490+
'location' => 'Symfony\Bridge\PhpUnit\Tests\DeprecationErrorHandler\ConfigurationTest::runTest',
491+
'message' => 'Regular deprecation',
492+
'count' => 1,
493+
],
494+
[
495+
'location' => self::class,
496+
'message' => 'Deprecation by debug class loader',
497+
'count' => 1,
498+
],
499+
];
500+
$this->assertEquals(json_encode($expected, \JSON_PRETTY_PRINT | \JSON_UNESCAPED_SLASHES), file_get_contents($filename));
463501
}
464502

465503
public function testBaselineArgumentException()

src/Symfony/Bridge/PhpUnit/bin/simple-phpunit.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,9 @@ class_exists(\SymfonyExcludeListSimplePhpunit::class, false) && PHPUnit\Util\Bla
401401
}
402402
}
403403

404+
$lastOutput = null;
405+
$lastOutputTime = null;
406+
404407
while ($runningProcs) {
405408
usleep(300000);
406409
$terminatedProcs = [];
@@ -413,6 +416,26 @@ class_exists(\SymfonyExcludeListSimplePhpunit::class, false) && PHPUnit\Util\Bla
413416
}
414417
}
415418

419+
if (!$terminatedProcs && 1 === count($runningProcs)) {
420+
$component = key($runningProcs);
421+
422+
$output = file_get_contents("$component/phpunit.stdout");
423+
$output .= file_get_contents("$component/phpunit.stderr");
424+
425+
if ($lastOutput !== $output) {
426+
$lastOutput = $output;
427+
$lastOutputTime = microtime(true);
428+
} elseif (microtime(true) - $lastOutputTime > 60) {
429+
echo "\033[41mTimeout\033[0m $component\n\n";
430+
431+
if ('\\' === \DIRECTORY_SEPARATOR) {
432+
exec(sprintf('taskkill /F /T /PID %d 2>&1', $procStatus['pid']), $output, $exitCode);
433+
} else {
434+
proc_terminate(current($runningProcs));
435+
}
436+
}
437+
}
438+
416439
foreach ($terminatedProcs as $component => $procStatus) {
417440
foreach (['out', 'err'] as $file) {
418441
$file = "$component/phpunit.std$file";

src/Symfony/Bundle/FrameworkBundle/Command/CacheClearCommand.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
129129
if ($output->isVerbose()) {
130130
$io->comment('Warming up optional cache...');
131131
}
132-
$this->warmupOptionals($realCacheDir, $io);
132+
$this->warmupOptionals($realCacheDir, $realBuildDir, $io);
133133
}
134134
} else {
135135
$fs->mkdir($warmupDir);
@@ -144,7 +144,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
144144
if ($output->isVerbose()) {
145145
$io->comment('Warming up optional cache...');
146146
}
147-
$this->warmupOptionals($realCacheDir, $io);
147+
$this->warmupOptionals($useBuildDir ? $realCacheDir : $warmupDir, $warmupDir, $io);
148148
}
149149
}
150150

@@ -239,15 +239,15 @@ private function warmup(string $warmupDir, string $realBuildDir): void
239239
}
240240
}
241241

242-
private function warmupOptionals(string $realCacheDir, SymfonyStyle $io): void
242+
private function warmupOptionals(string $cacheDir, string $warmupDir, SymfonyStyle $io): void
243243
{
244244
$kernel = $this->getApplication()->getKernel();
245245
$warmer = $kernel->getContainer()->get('cache_warmer');
246246
// non optional warmers already ran during container compilation
247247
$warmer->enableOnlyOptionalWarmers();
248-
$preload = (array) $warmer->warmUp($realCacheDir, $io);
248+
$preload = (array) $warmer->warmUp($cacheDir, $io);
249249

250-
if ($preload && file_exists($preloadFile = $realCacheDir.'/'.$kernel->getContainer()->getParameter('kernel.container_class').'.preload.php')) {
250+
if ($preload && file_exists($preloadFile = $warmupDir.'/'.$kernel->getContainer()->getParameter('kernel.container_class').'.preload.php')) {
251251
Preloader::append($preloadFile, $preload);
252252
}
253253
}

src/Symfony/Component/CssSelector/Tests/XPath/Fixtures/ids.html

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,8 @@
4545
</div>
4646
<div id="foobar-div" foobar="ab bc
4747
cde"><span id="foobar-span"></span></div>
48-
</body></html>
48+
<section>
49+
<span id="no-siblings-of-any-type"></span>
50+
</section>
51+
</body>
52+
</html>

src/Symfony/Component/CssSelector/Tests/XPath/TranslatorTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ public function testHtmlIds($css, array $elementsId)
114114
$document->loadHTMLFile(__DIR__.'/Fixtures/ids.html');
115115
$document = simplexml_import_dom($document);
116116
$elements = $document->xpath($translator->cssToXPath($css));
117-
$this->assertCount(\count($elementsId), $elementsId);
117+
$this->assertCount(\count($elementsId), $elements);
118118
foreach ($elements as $element) {
119119
if (null !== $element->attributes()->id) {
120120
$this->assertContains((string) $element->attributes()->id, $elementsId);
@@ -304,14 +304,14 @@ public static function getHtmlIdsTestData()
304304
['li:nth-last-child(-n+1)', ['seventh-li']],
305305
['li:nth-last-child(-n+3)', ['fifth-li', 'sixth-li', 'seventh-li']],
306306
['ol:first-of-type', ['first-ol']],
307-
['ol:nth-child(1)', ['first-ol']],
307+
['ol:nth-child(4)', ['first-ol']],
308308
['ol:nth-of-type(2)', ['second-ol']],
309309
['ol:nth-last-of-type(1)', ['second-ol']],
310-
['span:only-child', ['foobar-span']],
310+
['span:only-child', ['foobar-span', 'no-siblings-of-any-type']],
311311
['li div:only-child', ['li-div']],
312312
['div *:only-child', ['li-div', 'foobar-span']],
313313
['p:only-of-type', ['paragraph']],
314-
[':only-of-type', ['html', 'li-div', 'foobar-span', 'paragraph']],
314+
[':only-of-type', ['html', 'li-div', 'foobar-span', 'no-siblings-of-any-type']],
315315
['div#foobar-div :only-of-type', ['foobar-span']],
316316
['a:empty', ['name-anchor']],
317317
['a:EMpty', ['name-anchor']],
@@ -320,8 +320,8 @@ public static function getHtmlIdsTestData()
320320
['html:root', ['html']],
321321
['li:root', []],
322322
['* :root', []],
323-
['*:contains("link")', ['html', 'outer-div', 'tag-anchor', 'nofollow-anchor']],
324-
[':CONtains("link")', ['html', 'outer-div', 'tag-anchor', 'nofollow-anchor']],
323+
['*:contains("link")', ['html', 'nil', 'outer-div', 'tag-anchor', 'nofollow-anchor']],
324+
[':CONtains("link")', ['html', 'nil', 'outer-div', 'tag-anchor', 'nofollow-anchor']],
325325
['*:contains("LInk")', []], // case sensitive
326326
['*:contains("e")', ['html', 'nil', 'outer-div', 'first-ol', 'first-li', 'paragraph', 'p-em']],
327327
['*:contains("E")', []], // case-sensitive

0 commit comments

Comments
 (0)
0