Merge branch '4.4'
* 4.4: [Translation] Fixed case sensitivity of lint:xliff command fix type hint for salt in PasswordEncoderInterface Add missing deprecations for PHP templating layer Simplify code - catch \Throwable capture all exceptions Collect locale details earlier in the process in TranslationDataCollector fix typo in PR #31802 update italian validator translation Add missing translations [Messenger] Deprecate passing a bus locator to ConsumeMessagesCommand constructor [SecurityBundled] Forbid security-http >= 5.0 [Security][Guard] Forbid security-http >= 5.0 [TwigBridge] suggest Translation Component when TranslationExtension is used [Monolog] Setup the LoggerProcessor after all other processor
This commit is contained in:
commit
5e293d9e58
@ -4,7 +4,7 @@ UPGRADE FROM 4.3 to 4.4
|
||||
HttpKernel
|
||||
----------
|
||||
|
||||
* The `DebugHandlersListener` class has been marked as `final`
|
||||
* The `DebugHandlersListener` class has been marked as `final`
|
||||
|
||||
DependencyInjection
|
||||
-------------------
|
||||
@ -25,10 +25,21 @@ DependencyInjection
|
||||
factory: ['@factory_service', method]
|
||||
```
|
||||
|
||||
Messenger
|
||||
---------
|
||||
|
||||
* Deprecated passing a `ContainerInterface` instance as first argument of the `ConsumeMessagesCommand` constructor,
|
||||
pass a `RoutableMessageBus` instance instead.
|
||||
|
||||
FrameworkBundle
|
||||
---------------
|
||||
|
||||
* Deprecated support for `templating` engine in `TemplateController`, use Twig instead
|
||||
|
||||
MonologBridge
|
||||
--------------
|
||||
|
||||
* The `RouteProcessor` has been marked final.
|
||||
* The `RouteProcessor` has been marked final.
|
||||
|
||||
TwigBridge
|
||||
----------
|
||||
|
@ -219,6 +219,7 @@ FrameworkBundle
|
||||
* Removed support for legacy translations directories `src/Resources/translations/` and `src/Resources/<BundleName>/translations/`, use `translations/` instead.
|
||||
* Support for the legacy directory structure in `translation:update` and `debug:translation` commands has been removed.
|
||||
* Removed the "Psr\SimpleCache\CacheInterface" / "cache.app.simple" service, use "Symfony\Contracts\Cache\CacheInterface" / "cache.app" instead.
|
||||
* Removed support for `templating` engine in `TemplateController`, use Twig instead
|
||||
|
||||
HttpFoundation
|
||||
--------------
|
||||
@ -269,6 +270,8 @@ Messenger
|
||||
---------
|
||||
|
||||
* The `LoggingMiddleware` class has been removed, pass a logger to `SendMessageMiddleware` instead.
|
||||
* Passing a `ContainerInterface` instance as first argument of the `ConsumeMessagesCommand` constructor now
|
||||
throws as `\TypeError`, pass a `RoutableMessageBus` instance instead.
|
||||
|
||||
Monolog
|
||||
-------
|
||||
|
@ -49,11 +49,19 @@ class TranslationExtension extends AbstractExtension
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated since Symfony 4.2
|
||||
* @return TranslatorInterface|null
|
||||
*/
|
||||
public function getTranslator()
|
||||
{
|
||||
@trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.2.', __METHOD__), E_USER_DEPRECATED);
|
||||
if (null === $this->translator) {
|
||||
if (!interface_exists(TranslatorInterface::class)) {
|
||||
throw new \LogicException(sprintf('You cannot use the "%s" if the Translation Contracts are not available. Try running "composer require symfony/translation".', __CLASS__));
|
||||
}
|
||||
|
||||
$this->translator = new class() implements TranslatorInterface {
|
||||
use TranslatorTrait;
|
||||
};
|
||||
}
|
||||
|
||||
return $this->translator;
|
||||
}
|
||||
@ -108,13 +116,8 @@ class TranslationExtension extends AbstractExtension
|
||||
if (null !== $count) {
|
||||
$arguments['%count%'] = $count;
|
||||
}
|
||||
if (null === $this->translator) {
|
||||
$this->translator = new class() implements TranslatorInterface {
|
||||
use TranslatorTrait;
|
||||
};
|
||||
}
|
||||
|
||||
return $this->translator->trans($message, $arguments, $domain, $locale);
|
||||
return $this->getTranslator()->trans($message, $arguments, $domain, $locale);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -122,17 +125,13 @@ class TranslationExtension extends AbstractExtension
|
||||
*/
|
||||
public function transchoice($message, $count, array $arguments = [], $domain = null, $locale = null)
|
||||
{
|
||||
if (null === $this->translator) {
|
||||
$this->translator = new class() implements TranslatorInterface {
|
||||
use TranslatorTrait;
|
||||
};
|
||||
$translator = $this->getTranslator();
|
||||
|
||||
if ($translator instanceof TranslatorInterface) {
|
||||
return $translator->trans($message, array_merge(['%count%' => $count], $arguments), $domain, $locale);
|
||||
}
|
||||
|
||||
if ($this->translator instanceof TranslatorInterface) {
|
||||
return $this->translator->trans($message, array_merge(['%count%' => $count], $arguments), $domain, $locale);
|
||||
}
|
||||
|
||||
return $this->translator->transChoice($message, $count, array_merge(['%count%' => $count], $arguments), $domain, $locale);
|
||||
return $translator->transChoice($message, $count, array_merge(['%count%' => $count], $arguments), $domain, $locale);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -6,6 +6,11 @@ CHANGELOG
|
||||
|
||||
* Removed support to load translation resources from the legacy directories `src/Resources/translations/` and `src/Resources/<BundleName>/translations/`
|
||||
|
||||
4.4.0
|
||||
-----
|
||||
|
||||
* Deprecated support for `templating` engine in `TemplateController`, use Twig instead
|
||||
|
||||
4.3.0
|
||||
-----
|
||||
|
||||
|
@ -29,6 +29,10 @@ class TemplateController
|
||||
|
||||
public function __construct(Environment $twig = null, EngineInterface $templating = null)
|
||||
{
|
||||
if (null !== $templating) {
|
||||
@trigger_error(sprintf('Using a "%s" instance for "%s" is deprecated since version 4.4; use a \Twig\Environment instance instead.', EngineInterface::class, __CLASS__), E_USER_DEPRECATED);
|
||||
}
|
||||
|
||||
$this->twig = $twig;
|
||||
$this->templating = $templating;
|
||||
}
|
||||
|
@ -132,7 +132,7 @@ class FrameworkBundle extends Bundle
|
||||
$container->addCompilerPass(new RegisterReverseContainerPass(false), PassConfig::TYPE_AFTER_REMOVING);
|
||||
|
||||
if ($container->getParameter('kernel.debug')) {
|
||||
$container->addCompilerPass(new AddDebugLogProcessorPass(), PassConfig::TYPE_BEFORE_OPTIMIZATION, -32);
|
||||
$container->addCompilerPass(new AddDebugLogProcessorPass(), PassConfig::TYPE_BEFORE_OPTIMIZATION, 2);
|
||||
$container->addCompilerPass(new UnusedTagsPass(), PassConfig::TYPE_AFTER_REMOVING);
|
||||
$container->addCompilerPass(new ContainerBuilderDebugDumpPass(), PassConfig::TYPE_BEFORE_REMOVING, -255);
|
||||
$container->addCompilerPass(new CacheCollectorPass(), PassConfig::TYPE_BEFORE_REMOVING);
|
||||
|
@ -31,6 +31,9 @@ class TemplateControllerTest extends TestCase
|
||||
$this->assertEquals('bar', $controller('mytemplate')->getContent());
|
||||
}
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
*/
|
||||
public function testTemplating()
|
||||
{
|
||||
$templating = $this->getMockBuilder(EngineInterface::class)->getMock();
|
||||
|
@ -11,6 +11,8 @@
|
||||
|
||||
namespace Symfony\Bundle\TwigBundle\CacheWarmer;
|
||||
|
||||
@trigger_error('The '.TemplateCacheCacheWarmer::class.' class is deprecated since version 4.4 and will be removed in 5.0; use Twig instead.', E_USER_DEPRECATED);
|
||||
|
||||
use Psr\Container\ContainerInterface;
|
||||
use Symfony\Bundle\FrameworkBundle\CacheWarmer\TemplateFinderInterface;
|
||||
use Symfony\Component\DependencyInjection\ServiceSubscriberInterface;
|
||||
@ -26,6 +28,8 @@ use Twig\Error\Error;
|
||||
* as the Twig loader will need the cache generated by it.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* @deprecated since version 4.4, to be removed in 5.0; use Twig instead.
|
||||
*/
|
||||
class TemplateCacheCacheWarmer implements CacheWarmerInterface, ServiceSubscriberInterface
|
||||
{
|
||||
|
@ -105,6 +105,7 @@ class ExtensionPass implements CompilerPassInterface
|
||||
} else {
|
||||
$container->setAlias('twig.loader.filesystem', new Alias('twig.loader.native_filesystem', false));
|
||||
$container->removeDefinition('templating.engine.twig');
|
||||
$container->removeDefinition('twig.cache_warmer');
|
||||
}
|
||||
|
||||
if ($container->has('assets.packages')) {
|
||||
|
@ -17,6 +17,8 @@
|
||||
<argument type="service" id="twig" />
|
||||
<argument type="service" id="templating.name_parser" />
|
||||
<argument type="service" id="templating.locator" />
|
||||
|
||||
<deprecated>The "%service_id%" service is deprecated since Symfony 4.4 and will be removed in 5.0.</deprecated>
|
||||
</service>
|
||||
</services>
|
||||
</container>
|
||||
|
@ -35,6 +35,8 @@
|
||||
<argument type="service" id="Psr\Container\ContainerInterface" />
|
||||
<argument type="service" id="templating.finder" on-invalid="ignore" />
|
||||
<argument type="collection" /> <!-- Twig paths -->
|
||||
|
||||
<deprecated>The "%service_id%" service is deprecated since Symfony 4.4 and will be removed in 5.0.</deprecated>
|
||||
</service>
|
||||
|
||||
<service id="twig.template_iterator" class="Symfony\Bundle\TwigBundle\TemplateIterator">
|
||||
|
@ -751,7 +751,6 @@ class Filesystem
|
||||
|
||||
return $result;
|
||||
} catch (\Throwable $e) {
|
||||
} catch (\Exception $e) {
|
||||
}
|
||||
\restore_error_handler();
|
||||
|
||||
|
@ -52,6 +52,8 @@ class HIncludeFragmentRenderer extends RoutableFragmentRenderer
|
||||
* @param EngineInterface|Environment|null $templating An EngineInterface or an Environment instance
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
public function setTemplating($templating)
|
||||
{
|
||||
|
@ -494,7 +494,6 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl
|
||||
$fresh = true;
|
||||
}
|
||||
} catch (\Throwable $e) {
|
||||
} catch (\Exception $e) {
|
||||
} finally {
|
||||
error_reporting($errorLevel);
|
||||
}
|
||||
@ -563,7 +562,6 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl
|
||||
try {
|
||||
$oldContainer = include $cache->getPath();
|
||||
} catch (\Throwable $e) {
|
||||
} catch (\Exception $e) {
|
||||
} finally {
|
||||
error_reporting($errorLevel);
|
||||
}
|
||||
|
@ -6,6 +6,12 @@ CHANGELOG
|
||||
|
||||
* The `LoggingMiddleware` class has been removed, pass a logger to `SendMessageMiddleware` instead.
|
||||
|
||||
4.4.0
|
||||
-----
|
||||
|
||||
* Deprecated passing a `ContainerInterface` instance as first argument of the `ConsumeMessagesCommand` constructor,
|
||||
pass a `RoutableMessageBus` instance instead.
|
||||
|
||||
4.3.0
|
||||
-----
|
||||
|
||||
|
@ -54,8 +54,8 @@ class ConsumeMessagesCommand extends Command
|
||||
*/
|
||||
public function __construct($routableBus, ContainerInterface $receiverLocator, LoggerInterface $logger = null, array $receiverNames = [], /* ContainerInterface */ $retryStrategyLocator = null, EventDispatcherInterface $eventDispatcher = null)
|
||||
{
|
||||
// to be deprecated in 4.4
|
||||
if ($routableBus instanceof ContainerInterface) {
|
||||
@trigger_error(sprintf('Passing a "%s" instance as first argument to "%s()" is deprecated since Symfony 4.4, pass a "%s" instance instead.', ContainerInterface::class, __METHOD__, RoutableMessageBus::class), E_USER_DEPRECATED);
|
||||
$routableBus = new RoutableMessageBus($routableBus);
|
||||
}
|
||||
|
||||
|
@ -27,7 +27,7 @@ class ConsumeMessagesCommandTest extends TestCase
|
||||
{
|
||||
public function testConfigurationWithDefaultReceiver()
|
||||
{
|
||||
$command = new ConsumeMessagesCommand($this->createMock(ServiceLocator::class), $this->createMock(ServiceLocator::class), null, ['amqp']);
|
||||
$command = new ConsumeMessagesCommand($this->createMock(RoutableMessageBus::class), $this->createMock(ServiceLocator::class), null, ['amqp']);
|
||||
$inputArgument = $command->getDefinition()->getArgument('receivers');
|
||||
$this->assertFalse($inputArgument->isRequired());
|
||||
$this->assertSame(['amqp'], $inputArgument->getDefault());
|
||||
@ -98,6 +98,10 @@ class ConsumeMessagesCommandTest extends TestCase
|
||||
$this->assertContains('[OK] Consuming messages from transports "dummy-receiver"', $tester->getDisplay());
|
||||
}
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
* @expectedDeprecation Passing a "Psr\Container\ContainerInterface" instance as first argument to "Symfony\Component\Messenger\Command\ConsumeMessagesCommand::__construct()" is deprecated since Symfony 4.4, pass a "Symfony\Component\Messenger\RoutableMessageBus" instance instead.
|
||||
*/
|
||||
public function testBasicRunWithBusLocator()
|
||||
{
|
||||
$envelope = new Envelope(new \stdClass(), [new BusNameStamp('dummy-bus')]);
|
||||
@ -130,6 +134,10 @@ class ConsumeMessagesCommandTest extends TestCase
|
||||
$this->assertContains('[OK] Consuming messages from transports "dummy-receiver"', $tester->getDisplay());
|
||||
}
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
* @expectedDeprecation Passing a "Psr\Container\ContainerInterface" instance as first argument to "Symfony\Component\Messenger\Command\ConsumeMessagesCommand::__construct()" is deprecated since Symfony 4.4, pass a "Symfony\Component\Messenger\RoutableMessageBus" instance instead.
|
||||
*/
|
||||
public function testRunWithBusOptionAndBusLocator()
|
||||
{
|
||||
$envelope = new Envelope(new \stdClass());
|
||||
|
@ -49,7 +49,7 @@ abstract class BasePasswordEncoder implements PasswordEncoderInterface
|
||||
* Merges a password and a salt.
|
||||
*
|
||||
* @param string $password The password to be used
|
||||
* @param string $salt The salt to be used
|
||||
* @param string|null $salt The salt to be used
|
||||
*
|
||||
* @return string a merged password and salt
|
||||
*
|
||||
|
@ -24,7 +24,7 @@ interface PasswordEncoderInterface
|
||||
* Encodes the raw password.
|
||||
*
|
||||
* @param string $raw The password to encode
|
||||
* @param string $salt The salt
|
||||
* @param string|null $salt The salt
|
||||
*
|
||||
* @return string The encoded password
|
||||
*
|
||||
@ -38,7 +38,7 @@ interface PasswordEncoderInterface
|
||||
*
|
||||
* @param string $encoded An encoded password
|
||||
* @param string $raw A raw password
|
||||
* @param string $salt The salt
|
||||
* @param string|null $salt The salt
|
||||
*
|
||||
* @return bool true if the password is valid, false otherwise
|
||||
*
|
||||
|
@ -124,7 +124,9 @@ EOF
|
||||
$normalizedLocale = preg_quote(str_replace('-', '_', $targetLanguage), '/');
|
||||
// strict file names require translation files to be named '____.locale.xlf'
|
||||
// otherwise, both '____.locale.xlf' and 'locale.____.xlf' are allowed
|
||||
$expectedFilenamePattern = $this->requireStrictFileNames ? sprintf('/^.*\.%s\.xlf/', $normalizedLocale) : sprintf('/^(.*\.%s\.xlf|%s\..*\.xlf)/', $normalizedLocale, $normalizedLocale);
|
||||
// also, the regexp matching must be case-insensitive, as defined for 'target-language' values
|
||||
// http://docs.oasis-open.org/xliff/v1.2/os/xliff-core.html#target-language
|
||||
$expectedFilenamePattern = $this->requireStrictFileNames ? sprintf('/^.*\.(?i:%s)\.xlf/', $normalizedLocale) : sprintf('/^(.*\.(?i:%s)\.xlf|(?i:%s)\..*\.xlf)/', $normalizedLocale, $normalizedLocale);
|
||||
|
||||
if (0 === preg_match($expectedFilenamePattern, basename($file))) {
|
||||
$errors[] = [
|
||||
|
@ -36,12 +36,9 @@ class TranslationDataCollector extends DataCollector implements LateDataCollecto
|
||||
{
|
||||
$messages = $this->sanitizeCollectedMessages($this->translator->getCollectedMessages());
|
||||
|
||||
$this->data = $this->computeCount($messages);
|
||||
$this->data += $this->computeCount($messages);
|
||||
$this->data['messages'] = $messages;
|
||||
|
||||
$this->data['locale'] = $this->translator->getLocale();
|
||||
$this->data['fallback_locales'] = $this->translator->getFallbackLocales();
|
||||
|
||||
$this->data = $this->cloneVar($this->data);
|
||||
}
|
||||
|
||||
@ -50,6 +47,8 @@ class TranslationDataCollector extends DataCollector implements LateDataCollecto
|
||||
*/
|
||||
public function collect(Request $request, Response $response, \Exception $exception = null)
|
||||
{
|
||||
$this->data['locale'] = $this->translator->getLocale();
|
||||
$this->data['fallback_locales'] = $this->translator->getFallbackLocales();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -94,6 +94,17 @@ class XliffLintCommandTest extends TestCase
|
||||
$this->assertContains('There is a mismatch between the language included in the file name ("messages.en.xlf") and the "es" value used in the "target-language" attribute of the file.', trim($tester->getDisplay()));
|
||||
}
|
||||
|
||||
public function testLintTargetLanguageIsCaseInsensitive()
|
||||
{
|
||||
$tester = $this->createCommandTester();
|
||||
$filename = $this->createFile('note', 'zh-cn', 'messages.zh_CN.xlf');
|
||||
|
||||
$tester->execute(['filename' => $filename], ['decorated' => false]);
|
||||
|
||||
$this->assertEquals(0, $tester->getStatusCode());
|
||||
$this->assertContains('[OK] All 1 XLIFF files contain valid syntax.', trim($tester->getDisplay()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \RuntimeException
|
||||
*/
|
||||
|
@ -334,6 +334,34 @@
|
||||
<source>This value should be valid JSON.</source>
|
||||
<target>Ova vrijednost treba biti validan JSON.</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="87">
|
||||
<source>This collection should contain only unique elements.</source>
|
||||
<target>Ova kolekcija treba sadržavati samo unikatne elemente.</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="88">
|
||||
<source>This value should be positive.</source>
|
||||
<target>Ova vrijednost treba biti pozitivna.</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="89">
|
||||
<source>This value should be either positive or zero.</source>
|
||||
<target>Ova vrijednost treba biti pozitivna ili jednaka nuli.</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="90">
|
||||
<source>This value should be negative.</source>
|
||||
<target>Ova vrijednost treba biti negativna.</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="91">
|
||||
<source>This value should be either negative or zero.</source>
|
||||
<target>Ova vrijednost treba biti negativna ili jednaka nuli.</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="92">
|
||||
<source>This value is not a valid timezone.</source>
|
||||
<target>Ova vrijednost nije validna vremenska zona.</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="93">
|
||||
<source>This password has been leaked in a data breach, it must not be used. Please use another password.</source>
|
||||
<target>Ova lozinka je procurila u nekom od sigurnosnih propusta, te je potrebno koristiti drugu lozinku.</target>
|
||||
</trans-unit>
|
||||
</body>
|
||||
</file>
|
||||
</xliff>
|
||||
|
@ -330,6 +330,38 @@
|
||||
<source>This Business Identifier Code (BIC) is not associated with IBAN {{ iban }}.</source>
|
||||
<target>Questo codice identificativo bancario (BIC) non è associato all'IBAN {{ iban }}.</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="86">
|
||||
<source>This value should be valid JSON.</source>
|
||||
<target>Questo valore dovrebbe essere un JSON valido.</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="87">
|
||||
<source>This collection should contain only unique elements.</source>
|
||||
<target>Questa collezione dovrebbe contenere solo elementi unici.</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="88">
|
||||
<source>This value should be positive.</source>
|
||||
<target>Questo valore dovrebbe essere positivo.</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="89">
|
||||
<source>This value should be either positive or zero.</source>
|
||||
<target>Questo valore dovrebbe essere positivo oppure zero.</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="90">
|
||||
<source>This value should be negative.</source>
|
||||
<target>Questo valore dovrebbe essere negativo.</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="91">
|
||||
<source>This value should be either negative or zero.</source>
|
||||
<target>Questo valore dovrebbe essere negativo oppure zero.</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="92">
|
||||
<source>This value is not a valid timezone.</source>
|
||||
<target>Questo valore non è un fuso orario valido.</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="93">
|
||||
<source>This password has been leaked in a data breach, it must not be used. Please use another password.</source>
|
||||
<target>Questa password è trapelata durante una compromissione di dati, non deve essere usata. Si prega di usare una password diversa.</target>
|
||||
</trans-unit>
|
||||
</body>
|
||||
</file>
|
||||
</xliff>
|
||||
|
Reference in New Issue
Block a user