Merge branch '5.0'

* 5.0: (24 commits)
  Removing unused variable
  Fixed #35084
  Add missing use statement
  [HttpClient] fix scheduling pending NativeResponse
  do not overwrite variable value
  [Profiler] wording
  Use spaces correctly to display options in DebugCommand
  Add supported schemes doc blocks type
  X-Accel Nginx URL updated
  ticket-30197 [Validator] Add the missing translations for the Chinese (Taiwan) ("zh_TW") locale
  Fixed test added in #35022
  Use locale_parse for computing fallback locales
  [Console] Fix filtering out identical alternatives when there is a command loader
  [String][UnicodeString] Remove unneeded flag in chunk regex pattern
  add note about HTTP status code change
  Migrate server:log command away from WebServerBundle
  [DependencyInjection][CheckTypeDeclarationsPass] Handle \Closure for callable
  [Security] Fix missing defaults for auto-migrating encoders
  bumped Symfony version to 5.0.3
  updated VERSION for 5.0.2
  ...
This commit is contained in:
Nicolas Grekas 2019-12-28 16:12:20 +01:00
commit 392d0b01f3
33 changed files with 579 additions and 69 deletions

View File

@ -7,6 +7,81 @@ in 4.4 minor versions.
To get the diff for a specific change, go to https://github.com/symfony/symfony/commit/XXX where XXX is the change hash
To get the diff between two versions, go to https://github.com/symfony/symfony/compare/v4.4.0...v4.4.1
* 4.4.2 (2019-12-19)
* bug #35051 [DependencyInjection] Fix binding tagged services to containers (nicolas-grekas)
* bug #35039 [DI] skip looking for config class when the extension class is anonymous (nicolas-grekas)
* bug #35049 [ProxyManager] fix generating proxies for root-namespaced classes (nicolas-grekas)
* bug #35022 [Dotenv] FIX missing getenv (mccullagh)
* bug #35023 [HttpKernel] ignore failures generated by opcache.restrict_api (nicolas-grekas)
* bug #35024 [HttpFoundation] fix pdo session handler for sqlsrv (azjezz)
* bug #35025 [HttpClient][Psr18Client] Remove Psr18ExceptionTrait (fancyweb)
* bug #35015 [Config] fix perf of glob discovery when GLOB_BRACE is not available (nicolas-grekas)
* bug #35014 [HttpClient] make pushed responses retry-able (nicolas-grekas)
* bug #35010 [VarDumper] ignore failing __debugInfo() (nicolas-grekas)
* bug #34998 [DI] fix auto-binding service providers to their service subscribers (nicolas-grekas)
* bug #34954 [Mailer] Fixed undefined index when sending via Mandrill API (wulff)
* bug #33670 [DI] Service locators can't be decorated (malarzm)
* bug #35000 [Console][SymfonyQuestionHelper] Handle multibytes question choices keys and custom prompt (fancyweb)
* bug #35005 [HttpClient] force HTTP/1.1 when NTLM auth is used (nicolas-grekas)
* bug #34707 [Validation][FrameworkBundle] Allow EnableAutoMapping to work without auto-mapping namespaces (ogizanagi)
* bug #34996 Fix displaying anonymous classes on PHP 7.4 (nicolas-grekas)
* bug #29839 [Validator] fix comparisons with null values at property paths (xabbuh)
* bug #34900 [DoctrineBridge] Fixed submitting invalid ids when using queries with limit (HeahDude)
* bug #34791 [Serializer] Skip uninitialized (PHP 7.4) properties in PropertyNormalizer and ObjectNormalizer (vudaltsov)
* bug #34956 [Messenger][AMQP] Use delivery_mode=2 by default (lyrixx)
* bug #34915 [FrameworkBundle] Fix invalid Windows path normalization in TemplateNameParser (mvorisek)
* bug #34981 stop using deprecated Doctrine persistence classes (xabbuh)
* bug #34904 [Validator][ConstraintValidator] Safe fail on invalid timezones (fancyweb)
* bug #34935 [FrameworkBundle][DependencyInjection] Skip removed ids in the lint container command and its associated pass (fancyweb)
* bug #34957 [Security] Revert "AbstractAuthenticationListener.php error instead info" (larzuk91)
* bug #34922 [FrameworkBundle][Secrets] Hook configured local dotenv file (fancyweb)
* bug #34967 [HttpFoundation] fix redis multi host dsn not recognized (Jan Christoph Beyer)
* bug #34963 [Lock] fix constructor argument type declaration (xabbuh)
* bug #34955 Require doctrine/persistence ^1.3 (nicolas-grekas)
* bug #34923 [DI] Fix support for immutable setters in CallTrait (Lctrs)
* bug #34878 [TwigBundle] fix broken FilesystemLoader::exists() with Twig 3 (dpesch)
* bug #34921 [HttpFoundation] Removed "Content-Type" from the preferred format guessing mechanism (yceruto)
* bug #34886 [HttpKernel] fix triggering deprecation in file locator (xabbuh)
* bug #34918 [Translation] fix memoryleak in PhpFileLoader (nicolas-grekas)
* bug #34920 [Routing] fix memoryleak when loading compiled routes (nicolas-grekas)
* bug #34787 [Cache] Propagate expiry when syncing items in ChainAdapter (trvrnrth)
* bug #34694 [Validator] Fix auto-mapping constraints should not be validated (ogizanagi)
* bug #34848 [Process] change the syntax of portable command lines (nicolas-grekas)
* bug #34862 [FrameworkBundle][ContainerLintCommand] Reinitialize bundles when the container is reprepared (fancyweb)
* bug #34896 [Cache] fix memory leak when using PhpFilesAdapter (nicolas-grekas)
* bug #34438 [HttpFoundation] Use `Cache-Control: must-revalidate` only if explicit lifetime has been given (mpdude)
* bug #34449 [Yaml] Implement multiline string as scalar block for tagged values (natepage)
* bug #34601 [MonologBridge] Fix debug processor datetime type (mRoca)
* bug #34842 [ExpressionLanguage] Process division by zero (tigr1991)
* bug #34902 [PropertyAccess] forward caught exception (xabbuh)
* bug #34903 Fixing bad order of operations with null coalescing operator (weaverryan)
* bug #34888 [TwigBundle] add tags before processing them (xabbuh)
* bug #34760 [Mailer] Fix SMTP Authentication when using STARTTLS (DjLeChuck)
* bug #34762 [Config] never try loading failed classes twice with ClassExistenceResource (nicolas-grekas)
* bug #34783 [DependencyInjection] Handle env var placeholders in CheckTypeDeclarationsPass (fancyweb)
* bug #34839 [Cache] fix memory leak when using PhpArrayAdapter (nicolas-grekas)
* bug #34812 [Yaml] fix parsing negative octal numbers (xabbuh)
* bug #34854 [Messenger] gracefully handle missing event dispatchers (xabbuh)
* bug #34802 [Security] Check UserInterface::getPassword is not null before calling needsRehash (dbrekelmans)
* bug #34788 [SecurityBundle] Properly escape regex in AddSessionDomainConstraintPass (fancyweb)
* bug #34859 [SecurityBundle] Fix TokenStorage::reset not called in stateless firewall (jderusse)
* bug #34827 [HttpFoundation] get currently session.gc_maxlifetime if ttl doesnt exists (rafaeltovar)
* bug #34755 [FrameworkBundle] resolve service locators in `debug:*` commands (nicolas-grekas)
* bug #34832 [Validator] Allow underscore character "_" in URL username and password (romainneutron)
* bug #34811 [TwigBridge] Update bootstrap_4_layout.html.twig missing switch-custom label (sabruss)
* bug #34820 [FrameworkBundle][SodiumVault] Create secrets directory only when it is used (fancyweb)
* bug #34776 [DI] fix resolving bindings for named TypedReference (nicolas-grekas)
* bug #34794 [DependencyInjection] Resolve expressions in CheckTypeDeclarationsPass (fancyweb)
* bug #34797 [Translation] Fix FileDumper behavior (yceruto)
* bug #34738 [SecurityBundle] Passwords are not encoded when algorithm set to "true" (nieuwenhuisen)
* bug #34759 [SecurityBundle] Fix switch_user provider configuration handling (fancyweb)
* bug #34779 [Security] do not validate passwords when the hash is null (xabbuh)
* bug #34786 [SecurityBundle] Use config variable in AnonymousFactory (martijnboers)
* bug #34784 [FrameworkBundle] Set the parameter bag as resolved in ContainerLintCommand (fancyweb)
* bug #34763 [Security/Core] Fix checking for SHA256/SHA512 passwords (David Brooks)
* bug #34757 [DI] Fix making the container path-independent when the app is in /app (nicolas-grekas)
* 4.4.1 (2019-12-01)
* bug #34732 [DependencyInjection][Xml] Fix the attribute 'tag' is not allowed in 'bind' tag (tienvx)

View File

@ -7,6 +7,86 @@ in 5.0 minor versions.
To get the diff for a specific change, go to https://github.com/symfony/symfony/commit/XXX where XXX is the change hash
To get the diff between two versions, go to https://github.com/symfony/symfony/compare/v5.0.0...v5.0.1
* 5.0.2 (2019-12-19)
* bug #35051 [DependencyInjection] Fix binding tagged services to containers (nicolas-grekas)
* bug #35039 [DI] skip looking for config class when the extension class is anonymous (nicolas-grekas)
* bug #35049 [ProxyManager] fix generating proxies for root-namespaced classes (nicolas-grekas)
* bug #35022 [Dotenv] FIX missing getenv (mccullagh)
* bug #35023 [HttpKernel] ignore failures generated by opcache.restrict_api (nicolas-grekas)
* bug #35024 [HttpFoundation] fix pdo session handler for sqlsrv (azjezz)
* bug #35025 [HttpClient][Psr18Client] Remove Psr18ExceptionTrait (fancyweb)
* bug #35028 [TwigBridge] Fix invalid typehint for subject in is_granted Twig function (emodric)
* bug #35015 [Config] fix perf of glob discovery when GLOB_BRACE is not available (nicolas-grekas)
* bug #35014 [HttpClient] make pushed responses retry-able (nicolas-grekas)
* bug #35010 [VarDumper] ignore failing __debugInfo() (nicolas-grekas)
* bug #34998 [DI] fix auto-binding service providers to their service subscribers (nicolas-grekas)
* bug #34954 [Mailer] Fixed undefined index when sending via Mandrill API (wulff)
* bug #33670 [DI] Service locators can't be decorated (malarzm)
* bug #35000 [Console][SymfonyQuestionHelper] Handle multibytes question choices keys and custom prompt (fancyweb)
* bug #35005 [HttpClient] force HTTP/1.1 when NTLM auth is used (nicolas-grekas)
* bug #34707 [Validation][FrameworkBundle] Allow EnableAutoMapping to work without auto-mapping namespaces (ogizanagi)
* bug #34996 Fix displaying anonymous classes on PHP 7.4 (nicolas-grekas)
* bug #29839 [Validator] fix comparisons with null values at property paths (xabbuh)
* bug #34900 [DoctrineBridge] Fixed submitting invalid ids when using queries with limit (HeahDude)
* bug #34791 [Serializer] Skip uninitialized (PHP 7.4) properties in PropertyNormalizer and ObjectNormalizer (vudaltsov)
* bug #34956 [Messenger][AMQP] Use delivery_mode=2 by default (lyrixx)
* bug #34915 [FrameworkBundle] Fix invalid Windows path normalization in TemplateNameParser (mvorisek)
* bug #34981 stop using deprecated Doctrine persistence classes (xabbuh)
* bug #34904 [Validator][ConstraintValidator] Safe fail on invalid timezones (fancyweb)
* bug #34935 [FrameworkBundle][DependencyInjection] Skip removed ids in the lint container command and its associated pass (fancyweb)
* bug #34957 [Security] Revert "AbstractAuthenticationListener.php error instead info" (larzuk91)
* bug #34922 [FrameworkBundle][Secrets] Hook configured local dotenv file (fancyweb)
* bug #34967 [HttpFoundation] fix redis multi host dsn not recognized (Jan Christoph Beyer)
* bug #34963 [Lock] fix constructor argument type declaration (xabbuh)
* bug #34955 Require doctrine/persistence ^1.3 (nicolas-grekas)
* bug #34923 [DI] Fix support for immutable setters in CallTrait (Lctrs)
* bug #34878 [TwigBundle] fix broken FilesystemLoader::exists() with Twig 3 (dpesch)
* bug #34921 [HttpFoundation] Removed "Content-Type" from the preferred format guessing mechanism (yceruto)
* bug #34886 [HttpKernel] fix triggering deprecation in file locator (xabbuh)
* bug #34918 [Translation] fix memoryleak in PhpFileLoader (nicolas-grekas)
* bug #34920 [Routing] fix memoryleak when loading compiled routes (nicolas-grekas)
* bug #34787 [Cache] Propagate expiry when syncing items in ChainAdapter (trvrnrth)
* bug #34694 [Validator] Fix auto-mapping constraints should not be validated (ogizanagi)
* bug #34848 [Process] change the syntax of portable command lines (nicolas-grekas)
* bug #34862 [FrameworkBundle][ContainerLintCommand] Reinitialize bundles when the container is reprepared (fancyweb)
* bug #34896 [Cache] fix memory leak when using PhpFilesAdapter (nicolas-grekas)
* bug #34438 [HttpFoundation] Use `Cache-Control: must-revalidate` only if explicit lifetime has been given (mpdude)
* bug #34449 [Yaml] Implement multiline string as scalar block for tagged values (natepage)
* bug #34601 [MonologBridge] Fix debug processor datetime type (mRoca)
* bug #34842 [ExpressionLanguage] Process division by zero (tigr1991)
* bug #34902 [PropertyAccess] forward caught exception (xabbuh)
* bug #34903 Fixing bad order of operations with null coalescing operator (weaverryan)
* bug #34888 [TwigBundle] add tags before processing them (xabbuh)
* bug #34760 [Mailer] Fix SMTP Authentication when using STARTTLS (DjLeChuck)
* bug #34762 [Config] never try loading failed classes twice with ClassExistenceResource (nicolas-grekas)
* bug #34783 [DependencyInjection] Handle env var placeholders in CheckTypeDeclarationsPass (fancyweb)
* bug #34839 [Cache] fix memory leak when using PhpArrayAdapter (nicolas-grekas)
* bug #34801 [String] implement __sleep()/__wakeup() on strings (nicolas-grekas)
* bug #34782 [String] inline Latin-ASCII rules (nicolas-grekas)
* bug #34812 [Yaml] fix parsing negative octal numbers (xabbuh)
* bug #34854 [Messenger] gracefully handle missing event dispatchers (xabbuh)
* bug #34802 [Security] Check UserInterface::getPassword is not null before calling needsRehash (dbrekelmans)
* bug #34788 [SecurityBundle] Properly escape regex in AddSessionDomainConstraintPass (fancyweb)
* bug #34859 [SecurityBundle] Fix TokenStorage::reset not called in stateless firewall (jderusse)
* bug #34827 [HttpFoundation] get currently session.gc_maxlifetime if ttl doesnt exists (rafaeltovar)
* bug #34755 [FrameworkBundle] resolve service locators in `debug:*` commands (nicolas-grekas)
* bug #34832 [Validator] Allow underscore character "_" in URL username and password (romainneutron)
* bug #34765 [DoctrineBridge] Removed QueryBuilder type hint in getLoader() (HeahDude)
* bug #34811 [TwigBridge] Update bootstrap_4_layout.html.twig missing switch-custom label (sabruss)
* bug #34820 [FrameworkBundle][SodiumVault] Create secrets directory only when it is used (fancyweb)
* bug #34776 [DI] fix resolving bindings for named TypedReference (nicolas-grekas)
* bug #34794 [DependencyInjection] Resolve expressions in CheckTypeDeclarationsPass (fancyweb)
* bug #34795 [Routing][ObjectLoader] Remove forgotten deprecation after merge (fancyweb)
* bug #34797 [Translation] Fix FileDumper behavior (yceruto)
* bug #34738 [SecurityBundle] Passwords are not encoded when algorithm set to "true" (nieuwenhuisen)
* bug #34759 [SecurityBundle] Fix switch_user provider configuration handling (fancyweb)
* bug #34779 [Security] do not validate passwords when the hash is null (xabbuh)
* bug #34786 [SecurityBundle] Use config variable in AnonymousFactory (martijnboers)
* bug #34784 [FrameworkBundle] Set the parameter bag as resolved in ContainerLintCommand (fancyweb)
* bug #34763 [Security/Core] Fix checking for SHA256/SHA512 passwords (David Brooks)
* bug #34757 [DI] Fix making the container path-independent when the app is in /app (nicolas-grekas)
* 5.0.1 (2019-12-01)
* bug #34732 [DependencyInjection][Xml] Fix the attribute 'tag' is not allowed in 'bind' tag (tienvx)

View File

@ -306,7 +306,7 @@ TwigBundle
The new default exception controller will also change the error response content according to
https://tools.ietf.org/html/rfc7807 for `json`, `xml`, `atom` and `txt` formats:
Before:
Before (HTTP status code `200`):
```json
{
"error": {
@ -316,7 +316,7 @@ TwigBundle
}
```
After:
After (HTTP status code `404`):
```json
{
"title": "Not Found",

View File

@ -12,6 +12,7 @@ CHANGELOG
* The `RouteProcessor` class has been made final
* Added `ElasticsearchLogstashHandler`
* Added the `ServerLogCommand`. Backport from the deprecated WebServerBundle
4.3.0
-----

View File

@ -0,0 +1,159 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Bridge\Monolog\Command;
use Monolog\Formatter\FormatterInterface;
use Monolog\Logger;
use Symfony\Bridge\Monolog\Formatter\ConsoleFormatter;
use Symfony\Bridge\Monolog\Handler\ConsoleHandler;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Exception\LogicException;
use Symfony\Component\Console\Exception\RuntimeException;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\ExpressionLanguage\ExpressionLanguage;
/**
* @author Grégoire Pineau <lyrixx@lyrixx.info>
*/
class ServerLogCommand extends Command
{
private static $bgColor = ['black', 'blue', 'cyan', 'green', 'magenta', 'red', 'white', 'yellow'];
private $el;
private $handler;
protected static $defaultName = 'server:log';
public function isEnabled()
{
if (!class_exists(ConsoleFormatter::class)) {
return false;
}
// based on a symfony/symfony package, it crashes due a missing FormatterInterface from monolog/monolog
if (!interface_exists(FormatterInterface::class)) {
return false;
}
return parent::isEnabled();
}
protected function configure()
{
if (!class_exists(ConsoleFormatter::class)) {
return;
}
$this
->addOption('host', null, InputOption::VALUE_REQUIRED, 'The server host', '0.0.0.0:9911')
->addOption('format', null, InputOption::VALUE_REQUIRED, 'The line format', ConsoleFormatter::SIMPLE_FORMAT)
->addOption('date-format', null, InputOption::VALUE_REQUIRED, 'The date format', ConsoleFormatter::SIMPLE_DATE)
->addOption('filter', null, InputOption::VALUE_REQUIRED, 'An expression to filter log. Example: "level > 200 or channel in [\'app\', \'doctrine\']"')
->setDescription('Starts a log server that displays logs in real time')
->setHelp(<<<'EOF'
<info>%command.name%</info> starts a log server to display in real time the log
messages generated by your application:
<info>php %command.full_name%</info>
To get the information as a machine readable format, use the
<comment>--filter</> option:
<info>php %command.full_name% --filter=port</info>
EOF
)
;
}
protected function execute(InputInterface $input, OutputInterface $output)
{
$filter = $input->getOption('filter');
if ($filter) {
if (!class_exists(ExpressionLanguage::class)) {
throw new LogicException('Package "symfony/expression-language" is required to use the "filter" option.');
}
$this->el = new ExpressionLanguage();
}
$this->handler = new ConsoleHandler($output, true, [
OutputInterface::VERBOSITY_NORMAL => Logger::DEBUG,
]);
$this->handler->setFormatter(new ConsoleFormatter([
'format' => str_replace('\n', "\n", $input->getOption('format')),
'date_format' => $input->getOption('date-format'),
'colors' => $output->isDecorated(),
'multiline' => OutputInterface::VERBOSITY_DEBUG <= $output->getVerbosity(),
]));
if (false === strpos($host = $input->getOption('host'), '://')) {
$host = 'tcp://'.$host;
}
if (!$socket = stream_socket_server($host, $errno, $errstr)) {
throw new RuntimeException(sprintf('Server start failed on "%s": %s %s.', $host, $errstr, $errno));
}
foreach ($this->getLogs($socket) as $clientId => $message) {
$record = unserialize(base64_decode($message));
// Impossible to decode the message, give up.
if (false === $record) {
continue;
}
if ($filter && !$this->el->evaluate($filter, $record)) {
continue;
}
$this->displayLog($output, $clientId, $record);
}
return 0;
}
private function getLogs($socket): iterable
{
$sockets = [(int) $socket => $socket];
$write = [];
while (true) {
$read = $sockets;
stream_select($read, $write, $write, null);
foreach ($read as $stream) {
if ($socket === $stream) {
$stream = stream_socket_accept($socket);
$sockets[(int) $stream] = $stream;
} elseif (feof($stream)) {
unset($sockets[(int) $stream]);
fclose($stream);
} else {
yield (int) $stream => fgets($stream);
}
}
}
}
private function displayLog(OutputInterface $output, int $clientId, array $record)
{
if (isset($record['log_id'])) {
$clientId = unpack('H*', $record['log_id'])[1];
}
$logBlock = sprintf('<bg=%s> </>', self::$bgColor[$clientId % 8]);
$output->write($logBlock);
$this->handler->handle($record);
}
}

View File

@ -12,6 +12,7 @@
namespace Symfony\Bundle\DebugBundle;
use Symfony\Bundle\DebugBundle\DependencyInjection\Compiler\DumpDataCollectorPass;
use Symfony\Bundle\DebugBundle\DependencyInjection\Compiler\RemoveWebServerBundleLoggerPass;
use Symfony\Component\Console\Application;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\HttpKernel\Bundle\Bundle;
@ -52,6 +53,7 @@ class DebugBundle extends Bundle
parent::build($container);
$container->addCompilerPass(new DumpDataCollectorPass());
$container->addCompilerPass(new RemoveWebServerBundleLoggerPass());
}
public function registerCommands(Application $application)

View File

@ -0,0 +1,31 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Bundle\DebugBundle\DependencyInjection\Compiler;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
/**
* @author Jérémy Derussé <jeremy@derusse.com>
*/
class RemoveWebServerBundleLoggerPass implements CompilerPassInterface
{
/**
* {@inheritdoc}
*/
public function process(ContainerBuilder $container)
{
if ($container->hasDefinition('web_server.command.server_log') && $container->hasDefinition('monolog.command.server_log')) {
$container->removeDefinition('web_server.command.server_log');
}
}
}

View File

@ -11,6 +11,7 @@
namespace Symfony\Bundle\DebugBundle\DependencyInjection;
use Symfony\Bridge\Monolog\Command\ServerLogCommand;
use Symfony\Bundle\DebugBundle\Command\ServerDumpPlaceholderCommand;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
@ -90,6 +91,10 @@ class DebugExtension extends Extension
]])
;
}
if (!class_exists(ServerLogCommand::class)) {
$container->removeDefinition('monolog.command.server_log');
}
}
/**

View File

@ -107,5 +107,9 @@
</argument>
<tag name="console.command" command="server:dump" />
</service>
<service id="monolog.command.server_log" class="Symfony\Bridge\Monolog\Command\ServerLogCommand">
<tag name="console.command" command="server:log" />
</service>
</services>
</container>

View File

@ -4,7 +4,7 @@
'no_token' : {
status: 'error',
title: (token|default('') == 'latest') ? 'There are no profiles' : 'Token not found',
message: (token|default('') == 'latest') ? 'No profiles found in the database.' : 'Token "' ~ token|default('') ~ '" was not found in the database.'
message: (token|default('') == 'latest') ? 'No profiles found.' : 'Token "' ~ token|default('') ~ '" not found.'
}
} %}

View File

@ -55,7 +55,7 @@ class CachePoolPass implements CompilerPassInterface
}
$seed .= '.'.$container->getParameter('kernel.container_class');
$pools = [];
$allPools = [];
$clearers = [];
$attributes = [
'provider',
@ -163,7 +163,7 @@ class CachePoolPass implements CompilerPassInterface
$clearers[$clearer][$name] = new Reference($id, $container::IGNORE_ON_UNINITIALIZED_REFERENCE);
}
$pools[$name] = new Reference($id, $container::IGNORE_ON_UNINITIALIZED_REFERENCE);
$allPools[$name] = new Reference($id, $container::IGNORE_ON_UNINITIALIZED_REFERENCE);
}
$notAliasedCacheClearerId = $this->cacheClearerId;
@ -171,7 +171,7 @@ class CachePoolPass implements CompilerPassInterface
$this->cacheClearerId = (string) $container->getAlias($this->cacheClearerId);
}
if ($container->hasDefinition($this->cacheClearerId)) {
$clearers[$notAliasedCacheClearerId] = $pools;
$clearers[$notAliasedCacheClearerId] = $allPools;
}
foreach ($clearers as $id => $pools) {
@ -189,7 +189,7 @@ class CachePoolPass implements CompilerPassInterface
}
if ($container->hasDefinition('console.command.cache_pool_list')) {
$container->getDefinition('console.command.cache_pool_list')->replaceArgument(0, array_keys($pools));
$container->getDefinition('console.command.cache_pool_list')->replaceArgument(0, array_keys($allPools));
}
}

View File

@ -648,8 +648,13 @@ class Application implements ResetInterface
// filter out aliases for commands which are already on the list
if (\count($commands) > 1) {
$commandList = $this->commandLoader ? array_merge(array_flip($this->commandLoader->getNames()), $this->commands) : $this->commands;
$commands = array_unique(array_filter($commands, function ($nameOrAlias) use ($commandList, $commands, &$aliases) {
$commandName = $commandList[$nameOrAlias] instanceof Command ? $commandList[$nameOrAlias]->getName() : $nameOrAlias;
$commands = array_unique(array_filter($commands, function ($nameOrAlias) use (&$commandList, $commands, &$aliases) {
if (!$commandList[$nameOrAlias] instanceof Command) {
$commandList[$nameOrAlias] = $this->commandLoader->get($nameOrAlias);
}
$commandName = $commandList[$nameOrAlias]->getName();
$aliases[$nameOrAlias] = $commandName;
return $commandName === $nameOrAlias || !\in_array($commandName, $commands);
@ -664,10 +669,6 @@ class Application implements ResetInterface
$maxLen = max(Helper::strlen($abbrev), $maxLen);
}
$abbrevs = array_map(function ($cmd) use ($commandList, $usableWidth, $maxLen, &$commands) {
if (!$commandList[$cmd] instanceof Command) {
$commandList[$cmd] = $this->commandLoader->get($cmd);
}
if ($commandList[$cmd]->isHidden()) {
unset($commands[array_search($cmd, $commands)]);

View File

@ -626,6 +626,9 @@ class ApplicationTest extends TestCase
$fooCommand->setAliases(['foo2']);
$application = new Application();
$application->setCommandLoader(new FactoryCommandLoader([
'foo3' => static function () use ($fooCommand) { return $fooCommand; },
]));
$application->add($fooCommand);
$result = $application->find('foo');

View File

@ -166,7 +166,7 @@ final class CheckTypeDeclarationsPass extends AbstractRecursivePass
return;
}
if ('callable' === $type && method_exists($class, '__invoke')) {
if ('callable' === $type && (\Closure::class === $class || method_exists($class, '__invoke'))) {
return;
}

View File

@ -681,4 +681,20 @@ class CheckTypeDeclarationsPassTest extends TestCase
$this->addToAssertionCount(1);
}
public function testProcessHandleClosureForCallable()
{
$closureDefinition = new Definition(\Closure::class);
$closureDefinition->setFactory([\Closure::class, 'fromCallable']);
$closureDefinition->setArguments(['strlen']);
$container = new ContainerBuilder();
$container
->register('foobar', BarMethodCall::class)
->addMethodCall('setCallable', [$closureDefinition]);
(new CheckTypeDeclarationsPass(true))->process($container);
$this->addToAssertionCount(1);
}
}

View File

@ -36,4 +36,8 @@ class BarMethodCall
public function setIterable(iterable $iterable)
{
}
public function setCallable(callable $callable): void
{
}
}

View File

@ -20,7 +20,6 @@ class TypedReference extends Reference
{
private $type;
private $name;
private $requiringClass;
/**
* @param string $id The service identifier

View File

@ -448,10 +448,13 @@ class DotenvTest extends TestCase
putenv('Foo=Bar');
$dotenv = new Dotenv(true);
$values = $dotenv->parse('Foo=${Foo}');
$this->assertSame('Bar', $values['Foo']);
putenv('Foo');
try {
$values = $dotenv->parse('Foo=${Foo}');
$this->assertSame('Bar', $values['Foo']);
} finally {
putenv('Foo');
}
}
public function testNoDeprecationWarning()

View File

@ -11,8 +11,6 @@
namespace Symfony\Component\HttpClient\Internal;
use Symfony\Component\HttpClient\Response\NativeResponse;
/**
* Internal representation of the native client's state.
*
@ -24,8 +22,6 @@ final class NativeClientState extends ClientState
{
/** @var int */
public $id;
/** @var NativeResponse[] */
public $pendingResponses = [];
/** @var int */
public $maxHostConnections = PHP_INT_MAX;
/** @var int */

View File

@ -230,11 +230,7 @@ final class NativeResponse implements ResponseInterface
$runningResponses[$i] = [$response->multi, []];
}
if (null === $response->remaining) {
$response->multi->pendingResponses[] = $response;
} else {
$runningResponses[$i][1][$response->id] = $response;
}
$runningResponses[$i][1][$response->id] = $response;
if (null === $response->buffer) {
// Response already completed
@ -336,25 +332,30 @@ final class NativeResponse implements ResponseInterface
return;
}
if ($multi->pendingResponses && \count($multi->handles) < $multi->maxHostConnections) {
// Open the next pending request - this is a blocking operation so we do only one of them
/** @var self $response */
$response = array_shift($multi->pendingResponses);
$response->open();
$responses[$response->id] = $response;
$multi->sleep = false;
self::perform($response->multi);
if (null !== $response->handle) {
$multi->handles[] = $response->handle;
// Create empty activity lists to tell ResponseTrait::stream() we still have pending requests
foreach ($responses as $i => $response) {
if (null === $response->remaining && null !== $response->buffer) {
$multi->handlesActivity[$i] = [];
}
}
if ($multi->pendingResponses) {
// Create empty activity list to tell ResponseTrait::stream() we still have pending requests
$response = $multi->pendingResponses[0];
$responses[$response->id] = $response;
$multi->handlesActivity[$response->id] = [];
if (\count($multi->handles) >= $multi->maxHostConnections) {
return;
}
// Open the next pending request - this is a blocking operation so we do only one of them
foreach ($responses as $i => $response) {
if (null === $response->remaining && null !== $response->buffer) {
$response->open();
$multi->sleep = false;
self::perform($multi);
if (null !== $response->handle) {
$multi->handles[] = $response->handle;
}
break;
}
}
}

View File

@ -214,7 +214,7 @@ class BinaryFileResponse extends Response
}
if ('x-accel-redirect' === strtolower($type)) {
// Do X-Accel-Mapping substitutions.
// @link http://wiki.nginx.org/X-accel#X-Accel-Redirect
// @link https://www.nginx.com/resources/wiki/start/topics/examples/x-accel/#x-accel-redirect
$parts = HeaderUtils::split($request->headers->get('X-Accel-Mapping', ''), ',=');
foreach ($parts as $part) {
list($pathPrefix, $location) = $part;

View File

@ -108,9 +108,9 @@ EOF
$optionsMapping = [];
foreach ($options as $key => $value) {
$optionsMapping[] = ' '.$key.'='.$value;
$optionsMapping[] = $key.'='.$value;
}
return ' (when'.implode(', ', $optionsMapping).')';
return ' (when '.implode(', ', $optionsMapping).')';
}
}

View File

@ -40,7 +40,7 @@ class DebugCommandTest extends TestCase
{
$command = new DebugCommand([
'command_bus' => [
DummyCommand::class => [[DummyCommandHandler::class, []]],
DummyCommand::class => [[DummyCommandHandler::class, ['option1' => '1', 'option2' => '2']]],
MultipleBusesMessage::class => [[MultipleBusesMessageHandler::class, []]],
],
'query_bus' => [
@ -62,12 +62,12 @@ command_bus
The following messages can be dispatched:
---------------------------------------------------------------------------------------
Symfony\Component\Messenger\Tests\Fixtures\DummyCommand
handled by Symfony\Component\Messenger\Tests\Fixtures\DummyCommandHandler
Symfony\Component\Messenger\Tests\Fixtures\MultipleBusesMessage
handled by Symfony\Component\Messenger\Tests\Fixtures\MultipleBusesMessageHandler
---------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------------
Symfony\Component\Messenger\Tests\Fixtures\DummyCommand
handled by Symfony\Component\Messenger\Tests\Fixtures\DummyCommandHandler (when option1=1, option2=2)
Symfony\Component\Messenger\Tests\Fixtures\MultipleBusesMessage
handled by Symfony\Component\Messenger\Tests\Fixtures\MultipleBusesMessageHandler
-----------------------------------------------------------------------------------------------------------
query_bus
---------

View File

@ -40,6 +40,9 @@ class UnsupportedSchemeException extends LogicException
],
];
/**
* @param string[] $supported
*/
public function __construct(Dsn $dsn, string $name = null, array $supported = [])
{
$provider = $dsn->getScheme();

View File

@ -39,6 +39,9 @@ abstract class AbstractTransportFactory implements TransportFactoryInterface
return \in_array($dsn->getScheme(), $this->getSupportedSchemes());
}
/**
* @return string[]
*/
abstract protected function getSupportedSchemes(): array;
protected function getUser(Dsn $dsn): string

View File

@ -144,10 +144,10 @@ class EncoderFactory implements EncoderFactoryInterface
return [
'class' => Pbkdf2PasswordEncoder::class,
'arguments' => [
$config['hash_algorithm'],
$config['encode_as_base64'],
$config['iterations'],
$config['key_length'],
$config['hash_algorithm'] ?? 'sha512',
$config['encode_as_base64'] ?? true,
$config['iterations'] ?? 1000,
$config['key_length'] ?? 40,
],
];
@ -205,8 +205,8 @@ class EncoderFactory implements EncoderFactoryInterface
'class' => MessageDigestPasswordEncoder::class,
'arguments' => [
$config['algorithm'],
$config['encode_as_base64'],
$config['iterations'],
$config['encode_as_base64'] ?? true,
$config['iterations'] ?? 5000,
],
];
}

View File

@ -162,6 +162,11 @@ class EncoderFactoryTest extends TestCase
(new EncoderFactory([SomeUser::class => ['class' => NativePasswordEncoder::class, 'arguments' => []]]))->getEncoder(SomeUser::class)
);
$this->assertInstanceOf(
MigratingPasswordEncoder::class,
(new EncoderFactory([SomeUser::class => ['algorithm' => 'bcrypt', 'cost' => 11]]))->getEncoder(SomeUser::class)
);
if (!SodiumPasswordEncoder::isSupported()) {
return;
}

View File

@ -71,7 +71,7 @@ class UnicodeString extends AbstractUnicodeString
$rx .= '\X{65535}';
$length -= 65535;
}
$rx .= '\X{'.$length.'})/us';
$rx .= '\X{'.$length.'})/u';
$str = clone $this;
$chunks = [];

View File

@ -16,6 +16,7 @@ use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\DataCollector\DataCollector;
use Symfony\Component\HttpKernel\DataCollector\LateDataCollectorInterface;
use Symfony\Component\Translation\DataCollectorTranslator;
use Symfony\Component\VarDumper\Cloner\Data;
/**
* @author Abdellatif Ait boudad <a.aitboudad@gmail.com>

View File

@ -263,15 +263,38 @@ class TranslatorTest extends TestCase
$this->assertSame('bar', $translator->trans('bar'));
}
public function testTransWithFallbackLocaleBis()
/**
* @dataProvider getFallbackLocales
*/
public function testTransWithFallbackLocaleBis($expectedLocale, $locale)
{
$translator = new Translator('en_US');
$translator = new Translator($locale);
$translator->addLoader('array', new ArrayLoader());
$translator->addResource('array', ['foo' => 'foofoo'], 'en_US');
$translator->addResource('array', ['bar' => 'foobar'], 'en');
$translator->addResource('array', ['foo' => 'foofoo'], $locale);
$translator->addResource('array', ['bar' => 'foobar'], $expectedLocale);
$this->assertEquals('foobar', $translator->trans('bar'));
}
public function getFallbackLocales()
{
$locales = [
['en', 'en_US'],
['en', 'en-US'],
['sl_Latn_IT', 'sl_Latn_IT_nedis'],
['sl_Latn', 'sl_Latn_IT'],
];
if (\function_exists('locale_parse')) {
$locales[] = ['sl_Latn_IT', 'sl-Latn-IT-nedis'];
$locales[] = ['sl_Latn', 'sl-Latn-IT'];
} else {
$locales[] = ['sl-Latn-IT', 'sl-Latn-IT-nedis'];
$locales[] = ['sl-Latn', 'sl-Latn-IT'];
}
return $locales;
}
public function testTransWithFallbackLocaleTer()
{
$translator = new Translator('fr_FR');

View File

@ -405,10 +405,17 @@ EOF
while ($locale) {
$parent = $parentLocales[$locale] ?? null;
if (!$parent && false !== strrchr($locale, '_')) {
$locale = substr($locale, 0, -\strlen(strrchr($locale, '_')));
} elseif ('root' !== $parent) {
$locale = $parent;
if ($parent) {
$locale = 'root' !== $parent ? $parent : null;
} elseif (\function_exists('locale_parse')) {
$localeSubTags = locale_parse($locale);
$locale = null;
if (1 < \count($localeSubTags)) {
array_pop($localeSubTags);
$locale = locale_compose($localeSubTags) ?: null;
}
} elseif ($i = strrpos($locale, '_') ?: strrpos($locale, '-')) {
$locale = substr($locale, 0, $i);
} else {
$locale = null;
}

View File

@ -278,6 +278,94 @@
<source>This value should not be identical to {{ compared_value_type }} {{ compared_value }}.</source>
<target>該值不應與 {{ compared_value_type }} {{ compared_value }} 相同。</target>
</trans-unit>
<trans-unit id="73">
<source>The image ratio is too big ({{ ratio }}). Allowed maximum ratio is {{ max_ratio }}.</source>
<target>圖像格式過大 ({{ ratio }})。 最大允許尺寸 {{ max_ratio }}。</target>
</trans-unit>
<trans-unit id="74">
<source>The image ratio is too small ({{ ratio }}). Minimum ratio expected is {{ min_ratio }}.</source>
<target>圖像格式過小 ({{ ratio }})。最小尺寸 {{ min_ratio }}。</target>
</trans-unit>
<trans-unit id="75">
<source>The image is square ({{ width }}x{{ height }}px). Square images are not allowed.</source>
<target>方形圖像 ({{ width }}x{{ height }}px)。不接受方形圖像。</target>
</trans-unit>
<trans-unit id="76">
<source>The image is landscape oriented ({{ width }}x{{ height }}px). Landscape oriented images are not allowed.</source>
<target>紀念冊布局圖像 ({{ width }}x{{ height }}px)。 不接受紀念冊布局圖像。</target>
</trans-unit>
<trans-unit id="77">
<source>The image is portrait oriented ({{ width }}x{{ height }}px). Portrait oriented images are not allowed.</source>
<target>書籍布局圖像 ({{ width }}x{{ height }}px)。不接受圖像書籍布局。</target>
</trans-unit>
<trans-unit id="78">
<source>An empty file is not allowed.</source>
<target>不接受空白文件。</target>
</trans-unit>
<trans-unit id="79">
<source>The host could not be resolved.</source>
<target>未找到服務器。</target>
</trans-unit>
<trans-unit id="80">
<source>This value does not match the expected {{ charset }} charset.</source>
<target>該數值不符合預期 {{ charset }} 符號編碼。</target>
</trans-unit>
<trans-unit id="81">
<source>This is not a valid Business Identifier Code (BIC).</source>
<target>無效企業識別碼 (BIC)。</target>
</trans-unit>
<trans-unit id="82">
<source>Error.</source>
<target>錯誤。</target>
</trans-unit>
<trans-unit id="83">
<source>This is not a valid UUID.</source>
<target>無效的通用唯壹標識符 (UUID)。</target>
</trans-unit>
<trans-unit id="84">
<source>This value should be a multiple of {{ compared_value }}.</source>
<target>該值必須是倍數 {{ compared_value }}。</target>
</trans-unit>
<trans-unit id="85">
<source>This Business Identifier Code (BIC) is not associated with IBAN {{ iban }}.</source>
<target>該企業識別碼 (BIC) 與銀行賬戶國際編號不壹致 (IBAN) {{ iban }}。</target>
</trans-unit>
<trans-unit id="86">
<source>This value should be valid JSON.</source>
<target>該數值必須序列化為JSON格式。</target>
</trans-unit>
<trans-unit id="87">
<source>This collection should contain only unique elements.</source>
<target>該集合應僅包含唯壹元素。</target>
</trans-unit>
<trans-unit id="88">
<source>This value should be positive.</source>
<target>數值應為正數。</target>
</trans-unit>
<trans-unit id="89">
<source>This value should be either positive or zero.</source>
<target>數值應或未正數,或為零。</target>
</trans-unit>
<trans-unit id="90">
<source>This value should be negative.</source>
<target>數值應為負數。</target>
</trans-unit>
<trans-unit id="91">
<source>This value should be either negative or zero.</source>
<target>數值應或未負數,或為零。</target>
</trans-unit>
<trans-unit id="92">
<source>This value is not a valid timezone.</source>
<target>無效時區。</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>依據您的密碼,發生數據泄露,請勿使用改密碼。請更換密碼。</target>
</trans-unit>
<trans-unit id="94">
<source>This value should be between {{ min }} and {{ max }}.</source>
<target>該數值應在 {{ min }} 和 {{ max }} 之間。</target>
</trans-unit>
</body>
</file>
</xliff>

View File

@ -25,7 +25,7 @@ final class CliContextProvider implements ContextProviderInterface
}
return [
'command_line' => $commandLine = implode(' ', $_SERVER['argv']),
'command_line' => $commandLine = implode(' ', $_SERVER['argv'] ?? []),
'identifier' => hash('crc32b', $commandLine.$_SERVER['REQUEST_TIME_FLOAT']),
];
}