Skip to content

Commit 6cb2647

Browse files
Merge branch '5.4' into 6.2
* 5.4: [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 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 8a28b59 + de7ab4d commit 6cb2647

File tree

534 files changed

+58409
-58421
lines changed

Some content is hidden

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

534 files changed

+58409
-58421
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;
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
@@ -238,7 +238,9 @@ public function isBaselineDeprecation(Deprecation $deprecation)
238238
return false;
239239
}
240240

241-
if ($deprecation->originatesFromAnObject()) {
241+
if ($deprecation->originatesFromDebugClassLoader()) {
242+
$location = $deprecation->triggeringClass();
243+
} elseif ($deprecation->originatesFromAnObject()) {
242244
$location = $deprecation->originatingClass().'::'.$deprecation->originatingMethod();
243245
} else {
244246
$location = 'procedural code';

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

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ class Deprecation
4040
private $originClass;
4141
private $originMethod;
4242
private $triggeringFile;
43+
private $triggeringClass;
4344

4445
/** @var string[] Absolute paths to vendor directories */
4546
private static $vendors;
@@ -60,6 +61,10 @@ class Deprecation
6061
*/
6162
public function __construct($message, array $trace, $file, $languageDeprecation = false)
6263
{
64+
if (isset($trace[2]['class']) && \in_array($trace[2]['class'], [DebugClassLoader::class, LegacyDebugClassLoader::class], true)) {
65+
$this->triggeringClass = $trace[2]['args'][0];
66+
}
67+
6368
if (isset($trace[2]['function']) && 'trigger_deprecation' === $trace[2]['function']) {
6469
$file = $trace[2]['file'];
6570
array_splice($trace, 1, 1);
@@ -157,6 +162,26 @@ private function lineShouldBeSkipped(array $line)
157162
return 'ReflectionMethod' === $class || 0 === strpos($class, 'PHPUnit\\');
158163
}
159164

165+
/**
166+
* @return bool
167+
*/
168+
public function originatesFromDebugClassLoader()
169+
{
170+
return isset($this->triggeringClass);
171+
}
172+
173+
/**
174+
* @return string
175+
*/
176+
public function triggeringClass()
177+
{
178+
if (null === $this->triggeringClass) {
179+
throw new \LogicException('Check with originatesFromDebugClassLoader() before calling this method.');
180+
}
181+
182+
return $this->triggeringClass;
183+
}
184+
160185
/**
161186
* @return bool
162187
*/

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
@@ -398,6 +398,9 @@ class_exists(\SymfonyExcludeListSimplePhpunit::class, false) && PHPUnit\Util\Bla
398398
}
399399
}
400400

401+
$lastOutput = null;
402+
$lastOutputTime = null;
403+
401404
while ($runningProcs) {
402405
usleep(300000);
403406
$terminatedProcs = [];
@@ -410,6 +413,26 @@ class_exists(\SymfonyExcludeListSimplePhpunit::class, false) && PHPUnit\Util\Bla
410413
}
411414
}
412415

416+
if (!$terminatedProcs && 1 === count($runningProcs)) {
417+
$component = key($runningProcs);
418+
419+
$output = file_get_contents("$component/phpunit.stdout");
420+
$output .= file_get_contents("$component/phpunit.stderr");
421+
422+
if ($lastOutput !== $output) {
423+
$lastOutput = $output;
424+
$lastOutputTime = microtime(true);
425+
} elseif (microtime(true) - $lastOutputTime > 60) {
426+
echo "\033[41mTimeout\033[0m $component\n\n";
427+
428+
if ('\\' === \DIRECTORY_SEPARATOR) {
429+
exec(sprintf('taskkill /F /T /PID %d 2>&1', $procStatus['pid']), $output, $exitCode);
430+
} else {
431+
proc_terminate(current($runningProcs));
432+
}
433+
}
434+
}
435+
413436
foreach ($terminatedProcs as $component => $procStatus) {
414437
foreach (['out', 'err'] as $file) {
415438
$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);
132+
$this->warmupOptionals($realCacheDir, $realBuildDir);
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);
147+
$this->warmupOptionals($useBuildDir ? $realCacheDir : $warmupDir, $warmupDir);
148148
}
149149
}
150150

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

242-
private function warmupOptionals(string $realCacheDir): void
242+
private function warmupOptionals(string $cacheDir, string $warmupDir): 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);
248+
$preload = (array) $warmer->warmUp($cacheDir);
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);
@@ -302,14 +302,14 @@ public static function getHtmlIdsTestData()
302302
['li:nth-last-child(-n+1)', ['seventh-li']],
303303
['li:nth-last-child(-n+3)', ['fifth-li', 'sixth-li', 'seventh-li']],
304304
['ol:first-of-type', ['first-ol']],
305-
['ol:nth-child(1)', ['first-ol']],
305+
['ol:nth-child(4)', ['first-ol']],
306306
['ol:nth-of-type(2)', ['second-ol']],
307307
['ol:nth-last-of-type(1)', ['second-ol']],
308-
['span:only-child', ['foobar-span']],
308+
['span:only-child', ['foobar-span', 'no-siblings-of-any-type']],
309309
['li div:only-child', ['li-div']],
310310
['div *:only-child', ['li-div', 'foobar-span']],
311311
['p:only-of-type', ['paragraph']],
312-
[':only-of-type', ['html', 'li-div', 'foobar-span', 'paragraph']],
312+
[':only-of-type', ['html', 'li-div', 'foobar-span', 'no-siblings-of-any-type']],
313313
['div#foobar-div :only-of-type', ['foobar-span']],
314314
['a:empty', ['name-anchor']],
315315
['a:EMpty', ['name-anchor']],
@@ -318,8 +318,8 @@ public static function getHtmlIdsTestData()
318318
['html:root', ['html']],
319319
['li:root', []],
320320
['* :root', []],
321-
['*:contains("link")', ['html', 'outer-div', 'tag-anchor', 'nofollow-anchor']],
322-
[':CONtains("link")', ['html', 'outer-div', 'tag-anchor', 'nofollow-anchor']],
321+
['*:contains("link")', ['html', 'nil', 'outer-div', 'tag-anchor', 'nofollow-anchor']],
322+
[':CONtains("link")', ['html', 'nil', 'outer-div', 'tag-anchor', 'nofollow-anchor']],
323323
['*:contains("LInk")', []], // case sensitive
324324
['*:contains("e")', ['html', 'nil', 'outer-div', 'first-ol', 'first-li', 'paragraph', 'p-em']],
325325
['*:contains("E")', []], // case-sensitive

0 commit comments

Comments
 (0)