From 83a056e45392ca86d62f8381ebb5d2ba21fd8518 Mon Sep 17 00:00:00 2001 From: Alexander Grimalovsky Date: Mon, 26 Feb 2024 14:20:14 +0300 Subject: [PATCH 1/6] [FrameworkBundle] Fix registration of the bundle path to translation Fixup for 31d7a09bf5c423ad2003d6863d7372e49a195af1 --- DependencyInjection/FrameworkExtension.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DependencyInjection/FrameworkExtension.php b/DependencyInjection/FrameworkExtension.php index 00412e5c6..e5956d517 100644 --- a/DependencyInjection/FrameworkExtension.php +++ b/DependencyInjection/FrameworkExtension.php @@ -1349,7 +1349,7 @@ private function registerTranslatorConfiguration(array $config, ContainerBuilder $defaultDir = $container->getParameterBag()->resolveValue($config['default_path']); foreach ($container->getParameter('kernel.bundles_metadata') as $name => $bundle) { if ($container->fileExists($dir = $bundle['path'].'/Resources/translations') || $container->fileExists($dir = $bundle['path'].'/translations')) { - $dirs[] = $dir; + $dirs[] = $transPaths[] = $dir; } else { $nonExistingDirs[] = $dir; } From 1b9da97ab8862b540136ab5af975888c3985676a Mon Sep 17 00:00:00 2001 From: Mathias Arlaud Date: Wed, 29 Nov 2023 16:51:19 +0100 Subject: [PATCH 2/6] [Serializer] Fix unexpected allowed attributes --- Resources/config/serializer.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Resources/config/serializer.php b/Resources/config/serializer.php index ca0cf9b53..63964f34f 100644 --- a/Resources/config/serializer.php +++ b/Resources/config/serializer.php @@ -137,6 +137,8 @@ service('property_info')->ignoreOnInvalid(), service('serializer.mapping.class_discriminator_resolver')->ignoreOnInvalid(), null, + [], + service('property_info')->ignoreOnInvalid(), ]) ->alias(PropertyNormalizer::class, 'serializer.normalizer.property') From 2d10752dde013210d04821ee356893ab489fd750 Mon Sep 17 00:00:00 2001 From: Jeldrik Geraedts Date: Tue, 26 Mar 2024 12:47:45 +0100 Subject: [PATCH 3/6] [FrameworkBundle] fixes #54402: Suppress PHP warning when is_readable() tries to access dirs outside of open_basedir restrictions --- Command/CacheClearCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Command/CacheClearCommand.php b/Command/CacheClearCommand.php index b245dd7a6..3a81a20ec 100644 --- a/Command/CacheClearCommand.php +++ b/Command/CacheClearCommand.php @@ -202,7 +202,7 @@ private function isNfs(string $dir): bool if (null === $mounts) { $mounts = []; - if ('/' === \DIRECTORY_SEPARATOR && is_readable('/proc/mounts') && $files = @file('/proc/mounts')) { + if ('/' === \DIRECTORY_SEPARATOR && @is_readable('/proc/mounts') && $files = @file('/proc/mounts')) { foreach ($files as $mount) { $mount = \array_slice(explode(' ', $mount), 1, -3); if (!\in_array(array_pop($mount), ['vboxsf', 'nfs'])) { From d17b52067c9284e1e580e2b87658eb16ba4b21b2 Mon Sep 17 00:00:00 2001 From: Gwendolen Lynch Date: Thu, 4 Apr 2024 10:25:16 +0200 Subject: [PATCH 4/6] [Serializer] reset backed_enum priority, and re-prioritise translatable --- Resources/config/serializer.php | 4 ++-- .../FrameworkExtensionTestCase.php | 17 ++++++++++++++++- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/Resources/config/serializer.php b/Resources/config/serializer.php index f70d60429..0e0031fba 100644 --- a/Resources/config/serializer.php +++ b/Resources/config/serializer.php @@ -116,7 +116,7 @@ ->set('serializer.normalizer.translatable', TranslatableNormalizer::class) ->args(['$translator' => service('translator')]) - ->tag('serializer.normalizer', ['priority' => -890]) + ->tag('serializer.normalizer', ['priority' => -920]) ->set('serializer.normalizer.form_error', FormErrorNormalizer::class) ->tag('serializer.normalizer', ['priority' => -915]) @@ -219,6 +219,6 @@ ]) ->set('serializer.normalizer.backed_enum', BackedEnumNormalizer::class) - ->tag('serializer.normalizer', ['priority' => -880]) + ->tag('serializer.normalizer', ['priority' => -915]) ; }; diff --git a/Tests/DependencyInjection/FrameworkExtensionTestCase.php b/Tests/DependencyInjection/FrameworkExtensionTestCase.php index 7e3045690..55de5cc24 100644 --- a/Tests/DependencyInjection/FrameworkExtensionTestCase.php +++ b/Tests/DependencyInjection/FrameworkExtensionTestCase.php @@ -69,6 +69,7 @@ use Symfony\Component\Serializer\Mapping\Loader\AttributeLoader; use Symfony\Component\Serializer\Mapping\Loader\XmlFileLoader; use Symfony\Component\Serializer\Mapping\Loader\YamlFileLoader; +use Symfony\Component\Serializer\Normalizer\BackedEnumNormalizer; use Symfony\Component\Serializer\Normalizer\ConstraintViolationListNormalizer; use Symfony\Component\Serializer\Normalizer\DataUriNormalizer; use Symfony\Component\Serializer\Normalizer\DateIntervalNormalizer; @@ -1606,10 +1607,24 @@ public function testTranslatableNormalizerRegistered() $tag = $definition->getTag('serializer.normalizer'); $this->assertSame(TranslatableNormalizer::class, $definition->getClass()); - $this->assertSame(-890, $tag[0]['priority']); + $this->assertSame(-920, $tag[0]['priority']); $this->assertEquals(new Reference('translator'), $definition->getArgument('$translator')); } + /** + * @see https://github.com/symfony/symfony/issues/54478 + */ + public function testBackedEnumNormalizerRegistered() + { + $container = $this->createContainerFromFile('full'); + + $definition = $container->getDefinition('serializer.normalizer.backed_enum'); + $tag = $definition->getTag('serializer.normalizer'); + + $this->assertSame(BackedEnumNormalizer::class, $definition->getClass()); + $this->assertSame(-915, $tag[0]['priority']); + } + public function testSerializerCacheActivated() { $container = $this->createContainerFromFile('serializer_enabled'); From a1d48796ce209e6a6d06efbd4f676b63cfd8d570 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Tue, 16 Apr 2024 10:45:54 +0200 Subject: [PATCH 5/6] Adjust pretty name of closures on PHP 8.4 --- Console/Descriptor/JsonDescriptor.php | 2 +- Console/Descriptor/MarkdownDescriptor.php | 2 +- Console/Descriptor/TextDescriptor.php | 2 +- Console/Descriptor/XmlDescriptor.php | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Console/Descriptor/JsonDescriptor.php b/Console/Descriptor/JsonDescriptor.php index 585af1eef..e25ee21d7 100644 --- a/Console/Descriptor/JsonDescriptor.php +++ b/Console/Descriptor/JsonDescriptor.php @@ -356,7 +356,7 @@ private function getCallableData($callable): array $data['type'] = 'closure'; $r = new \ReflectionFunction($callable); - if (str_contains($r->name, '{closure}')) { + if (str_contains($r->name, '{closure')) { return $data; } $data['name'] = $r->name; diff --git a/Console/Descriptor/MarkdownDescriptor.php b/Console/Descriptor/MarkdownDescriptor.php index f23be9d57..12ab4d4f7 100644 --- a/Console/Descriptor/MarkdownDescriptor.php +++ b/Console/Descriptor/MarkdownDescriptor.php @@ -372,7 +372,7 @@ protected function describeCallable($callable, array $options = []) $string .= "\n- Type: `closure`"; $r = new \ReflectionFunction($callable); - if (str_contains($r->name, '{closure}')) { + if (str_contains($r->name, '{closure')) { return $this->write($string."\n"); } $string .= "\n".sprintf('- Name: `%s`', $r->name); diff --git a/Console/Descriptor/TextDescriptor.php b/Console/Descriptor/TextDescriptor.php index 39dc8fb21..f2e7cee78 100644 --- a/Console/Descriptor/TextDescriptor.php +++ b/Console/Descriptor/TextDescriptor.php @@ -611,7 +611,7 @@ private function formatCallable($callable): string if ($callable instanceof \Closure) { $r = new \ReflectionFunction($callable); - if (str_contains($r->name, '{closure}')) { + if (str_contains($r->name, '{closure')) { return 'Closure()'; } if ($class = \PHP_VERSION_ID >= 80111 ? $r->getClosureCalledClass() : $r->getClosureScopeClass()) { diff --git a/Console/Descriptor/XmlDescriptor.php b/Console/Descriptor/XmlDescriptor.php index 56b1af9bf..8daf880f3 100644 --- a/Console/Descriptor/XmlDescriptor.php +++ b/Console/Descriptor/XmlDescriptor.php @@ -543,7 +543,7 @@ private function getCallableDocument($callable): \DOMDocument $callableXML->setAttribute('type', 'closure'); $r = new \ReflectionFunction($callable); - if (str_contains($r->name, '{closure}')) { + if (str_contains($r->name, '{closure')) { return $dom; } $callableXML->setAttribute('name', $r->name); From 52a2e98c7d27531144a92c2432c4db6b214c261c Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Thu, 18 Apr 2024 09:55:03 +0200 Subject: [PATCH 6/6] Auto-close PRs on subtree-splits --- .gitattributes | 3 +- .github/PULL_REQUEST_TEMPLATE.md | 8 +++++ .github/workflows/check-subtree-split.yml | 37 +++++++++++++++++++++++ 3 files changed, 46 insertions(+), 2 deletions(-) create mode 100644 .github/PULL_REQUEST_TEMPLATE.md create mode 100644 .github/workflows/check-subtree-split.yml diff --git a/.gitattributes b/.gitattributes index 84c7add05..14c3c3594 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,4 +1,3 @@ /Tests export-ignore /phpunit.xml.dist export-ignore -/.gitattributes export-ignore -/.gitignore export-ignore +/.git* export-ignore diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 000000000..4689c4dad --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,8 @@ +Please do not submit any Pull Requests here. They will be closed. +--- + +Please submit your PR here instead: +https://github.com/symfony/symfony + +This repository is what we call a "subtree split": a read-only subset of that main repository. +We're looking forward to your PR there! diff --git a/.github/workflows/check-subtree-split.yml b/.github/workflows/check-subtree-split.yml new file mode 100644 index 000000000..16be48bae --- /dev/null +++ b/.github/workflows/check-subtree-split.yml @@ -0,0 +1,37 @@ +name: Check subtree split + +on: + pull_request_target: + +jobs: + close-pull-request: + runs-on: ubuntu-latest + + steps: + - name: Close pull request + uses: actions/github-script@v6 + with: + script: | + if (context.repo.owner === "symfony") { + github.rest.issues.createComment({ + owner: "symfony", + repo: context.repo.repo, + issue_number: context.issue.number, + body: ` + Thanks for your Pull Request! We love contributions. + + However, you should instead open your PR on the main repository: + https://github.com/symfony/symfony + + This repository is what we call a "subtree split": a read-only subset of that main repository. + We're looking forward to your PR there! + ` + }); + + github.rest.pulls.update({ + owner: "symfony", + repo: context.repo.repo, + pull_number: context.issue.number, + state: "closed" + }); + }