Skip to content

Commit

Permalink
Merge branch '4.4'
Browse files Browse the repository at this point in the history
* 4.4:
  fix case
  [Messenger] Removed named parameters and replaced with `?` placeholders for sqlsrv compatibility
  [FrameworkBundle] Detect indirect env vars in routing
  [Form] type cannot be a FormTypeInterface anymore
  [HttpClient] use "idle" instead of "inactivity" when telling about the timeout option
  Create mailBody with only attachments part present
  Remove calls to deprecated function assertAttributeX
  [PhpUnitBridge] make the bridge act as a polyfill for newest PHPUnit features
  [Intl] Order alpha2 to alpha3 mapping
  [Routing] added a warning about the getRouteCollection() method
  Allow sutFqcnResolver to return array
  [Messenger] Fix incompatibility with FrameworkBundle <4.3.1
  Created alias to FlattenException to avoid BC break
  [Ldap] Add security LdapUser and provider
  [HttpFoundation] Revert getClientIp @return docblock
  • Loading branch information
xabbuh committed Aug 5, 2019
2 parents 9d9e8dc + 3e523dd commit 2d594d5
Show file tree
Hide file tree
Showing 36 changed files with 747 additions and 201 deletions.
1 change: 1 addition & 0 deletions UPGRADE-4.4.md
Expand Up @@ -149,6 +149,7 @@ Routing
Security
--------

* The `LdapUserProvider` class has been deprecated, use `Symfony\Component\Ldap\Security\LdapUserProvider` instead.
* Implementations of `PasswordEncoderInterface` and `UserPasswordEncoderInterface` should add a new `needsRehash()` method

Stopwatch
Expand Down
1 change: 1 addition & 0 deletions UPGRADE-5.0.md
Expand Up @@ -377,6 +377,7 @@ Routing
Security
--------

* The `LdapUserProvider` class has been removed, use `Symfony\Component\Ldap\Security\LdapUserProvider` instead.
* Implementations of `PasswordEncoderInterface` and `UserPasswordEncoderInterface` must have a new `needsRehash()` method
* The `Role` and `SwitchUserRole` classes have been removed.
* The `getReachableRoles()` method of the `RoleHierarchy` class has been removed. It has been replaced by the new
Expand Down
6 changes: 6 additions & 0 deletions src/Symfony/Bridge/PhpUnit/CHANGELOG.md
Expand Up @@ -6,6 +6,12 @@ CHANGELOG

* removed `weak_vendor` mode, use `max[self]=0` instead

4.4.0
-----

* made the bridge act as a polyfill for newest PHPUnit features
* added `SetUpTearDownTrait` to allow working around the `void` return-type added by PHPUnit 8

4.3.0
-----

Expand Down
Expand Up @@ -76,7 +76,7 @@ public function startTest($test)
$cache = $r->getValue();
$cache = array_replace_recursive($cache, array(
\get_class($test) => array(
'covers' => array($sutFqcn),
'covers' => \is_array($sutFqcn) ? $sutFqcn : array($sutFqcn),
),
));
$r->setValue($testClass, $cache);
Expand Down
Expand Up @@ -1233,7 +1233,7 @@ private function addHttpClientSection(ArrayNodeDefinition $rootNode)
->info('A comma separated list of hosts that do not require a proxy to be reached.')
->end()
->floatNode('timeout')
->info('Defaults to "default_socket_timeout" ini parameter.')
->info('The idle timeout, defaults to the "default_socket_timeout" ini parameter.')
->end()
->scalarNode('bindto')
->info('A network interface name, IP address, a host name or a UNIX socket to bind to.')
Expand Down
Expand Up @@ -82,7 +82,7 @@
</service>

<service id="console.command.messenger_consume_messages" class="Symfony\Component\Messenger\Command\ConsumeMessagesCommand">
<argument type="service" id="messenger.routable_message_bus" />
<argument /> <!-- Routable message bus -->
<argument type="service" id="messenger.receiver_locator" />
<argument type="service" id="logger" on-invalid="null" />
<argument type="collection" /> <!-- Receiver names -->
Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Bundle/FrameworkBundle/Routing/Router.php
Expand Up @@ -160,7 +160,7 @@ private function resolve($value)
return '%%';
}

if (preg_match('/^env\(\w+\)$/', $match[1])) {
if (preg_match('/^env\((?:\w++:)*+\w++\)$/', $match[1])) {
throw new RuntimeException(sprintf('Using "%%%s%%" is not allowed in routing configuration.', $match[1]));
}

Expand All @@ -173,7 +173,7 @@ private function resolve($value)
if (\is_string($resolved) || is_numeric($resolved)) {
$this->collectedParameters[$match[1]] = $resolved;

return (string) $resolved;
return (string) $this->resolve($resolved);
}

throw new RuntimeException(sprintf('The container parameter "%s", used in the route configuration value "%s", must be a string or numeric, but it is of type %s.', $match[1], $value, \gettype($resolved)));
Expand Down
21 changes: 19 additions & 2 deletions src/Symfony/Bundle/FrameworkBundle/Tests/Routing/RouterTest.php
Expand Up @@ -16,6 +16,7 @@
use Symfony\Bundle\FrameworkBundle\Routing\Router;
use Symfony\Component\Config\Loader\LoaderInterface;
use Symfony\Component\DependencyInjection\Config\ContainerParametersResource;
use Symfony\Component\DependencyInjection\Exception\RuntimeException;
use Symfony\Component\Routing\Route;
use Symfony\Component\Routing\RouteCollection;

Expand Down Expand Up @@ -278,13 +279,13 @@ public function testPatternPlaceholdersWithSfContainer()
$routes->add('foo', new Route('/before/%parameter.foo%/after/%%escaped%%'));

$sc = $this->getServiceContainer($routes);
$sc->setParameter('parameter.foo', 'foo');
$sc->setParameter('parameter.foo', 'foo-%%escaped%%');

$router = new Router($sc, 'foo');
$route = $router->getRouteCollection()->get('foo');

$this->assertEquals(
'/before/foo/after/%escaped%',
'/before/foo-%escaped%/after/%escaped%',
$route->getPath()
);
}
Expand Down Expand Up @@ -313,6 +314,22 @@ public function testEnvPlaceholdersWithSfContainer()
$router->getRouteCollection();
}

public function testIndirectEnvPlaceholders()
{
$routes = new RouteCollection();

$routes->add('foo', new Route('/%foo%'));

$router = new Router($container = $this->getServiceContainer($routes), 'foo');
$container->setParameter('foo', 'foo-%bar%');
$container->setParameter('bar', '%env(string:FOO)%');

$this->expectException(RuntimeException::class);
$this->expectExceptionMessage('Using "%env(string:FOO)%" is not allowed in routing configuration.');

$router->getRouteCollection();
}

public function testHostPlaceholders()
{
$routes = new RouteCollection();
Expand Down
Expand Up @@ -170,7 +170,7 @@
<deprecated>The "%service_id%" service is deprecated since Symfony 4.1.</deprecated>
</service>

<service id="security.user.provider.ldap" class="Symfony\Component\Security\Core\User\LdapUserProvider" abstract="true">
<service id="security.user.provider.ldap" class="Symfony\Component\Ldap\Security\LdapUserProvider" abstract="true">
<argument /> <!-- security.ldap.ldap -->
<argument /> <!-- base dn -->
<argument /> <!-- search dn -->
Expand Down
3 changes: 2 additions & 1 deletion src/Symfony/Bundle/SecurityBundle/composer.json
Expand Up @@ -51,7 +51,8 @@
"symfony/twig-bundle": "<4.4",
"symfony/var-dumper": "<4.4",
"symfony/framework-bundle": "<4.4",
"symfony/console": "<4.4"
"symfony/console": "<4.4",
"symfony/ldap": "<4.4"
},
"autoload": {
"psr-4": { "Symfony\\Bundle\\SecurityBundle\\": "" },
Expand Down
15 changes: 15 additions & 0 deletions src/Symfony/Component/ErrorRenderer/Exception/FlattenException.php
Expand Up @@ -364,3 +364,18 @@ public function getAsString()
return rtrim($message);
}
}

namespace Symfony\Component\Debug\Exception;

if (!class_exists(FlattenException::class, false)) {
class_alias(\Symfony\Component\ErrorRenderer\Exception\FlattenException::class, FlattenException::class);
}

if (false) {
/**
* @deprecated since Symfony 4.4, use Symfony\Component\ErrorRenderer\Exception\FlattenException instead.
*/
class FlattenException extends \Symfony\Component\ErrorRenderer\Exception\FlattenException
{
}
}
Expand Up @@ -61,14 +61,14 @@ public function testGetArguments()
public function testSetArguments()
{
$result = $this->event->setArguments(['foo' => 'bar']);
$this->assertAttributeSame(['foo' => 'bar'], 'arguments', $this->event);
$this->assertSame(['foo' => 'bar'], $this->event->getArguments());
$this->assertSame($this->event, $result);
}

public function testSetArgument()
{
$result = $this->event->setArgument('foo2', 'bar2');
$this->assertAttributeSame(['name' => 'Event', 'foo2' => 'bar2'], 'arguments', $this->event);
$this->assertSame(['name' => 'Event', 'foo2' => 'bar2'], $this->event->getArguments());
$this->assertEquals($this->event, $result);
}

Expand Down Expand Up @@ -97,13 +97,13 @@ public function testOffsetGet()
public function testOffsetSet()
{
$this->event['foo2'] = 'bar2';
$this->assertAttributeSame(['name' => 'Event', 'foo2' => 'bar2'], 'arguments', $this->event);
$this->assertSame(['name' => 'Event', 'foo2' => 'bar2'], $this->event->getArguments());
}

public function testOffsetUnset()
{
unset($this->event['name']);
$this->assertAttributeSame([], 'arguments', $this->event);
$this->assertSame([], $this->event->getArguments());
}

public function testOffsetIsset()
Expand Down
7 changes: 0 additions & 7 deletions src/Symfony/Component/Form/ButtonBuilder.php
Expand Up @@ -69,9 +69,6 @@ public function __construct(?string $name, array $options = [])
*
* This method should not be invoked.
*
* @param string|FormBuilderInterface $child
* @param string|FormTypeInterface $type
*
* @throws BadMethodCallException
*/
public function add($child, $type = null, array $options = [])
Expand All @@ -84,10 +81,6 @@ public function add($child, $type = null, array $options = [])
*
* This method should not be invoked.
*
* @param string $name
* @param string|FormTypeInterface $type
* @param array $options
*
* @throws BadMethodCallException
*/
public function create($name, $type = null, array $options = [])
Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Component/Form/Form.php
Expand Up @@ -848,8 +848,8 @@ public function add($child, $type = null, array $options = [])

$child = (string) $child;

if (null !== $type && !\is_string($type) && !$type instanceof FormTypeInterface) {
throw new UnexpectedTypeException($type, 'string or Symfony\Component\Form\FormTypeInterface');
if (null !== $type && !\is_string($type)) {
throw new UnexpectedTypeException($type, 'string or null');
}

// Never initialize child forms automatically
Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Component/Form/FormBuilder.php
Expand Up @@ -66,8 +66,8 @@ public function add($child, $type = null, array $options = [])
throw new UnexpectedTypeException($child, 'string or Symfony\Component\Form\FormBuilderInterface');
}

if (null !== $type && !\is_string($type) && !$type instanceof FormTypeInterface) {
throw new UnexpectedTypeException($type, 'string or Symfony\Component\Form\FormTypeInterface');
if (null !== $type && !\is_string($type)) {
throw new UnexpectedTypeException($type, 'string or null');
}

// Add to "children" to maintain order
Expand Down
7 changes: 0 additions & 7 deletions src/Symfony/Component/Form/Tests/FormBuilderTest.php
Expand Up @@ -120,13 +120,6 @@ public function testMaintainOrderOfLazyAndExplicitChildren()
$this->assertSame(['foo', 'bar', 'baz'], array_keys($children));
}

public function testAddFormType()
{
$this->assertFalse($this->builder->has('foo'));
$this->builder->add('foo', $this->getMockBuilder('Symfony\Component\Form\FormTypeInterface')->getMock());
$this->assertTrue($this->builder->has('foo'));
}

public function testRemove()
{
$this->builder->add('foo', 'Symfony\Component\Form\Extension\Core\Type\TextType');
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/HttpClient/Chunk/ErrorChunk.php
Expand Up @@ -30,7 +30,7 @@ public function __construct(int $offset, \Throwable $error = null)
{
$this->offset = $offset;
$this->error = $error;
$this->errorMessage = null !== $error ? $error->getMessage() : 'Reading from the response stream reached the inactivity timeout.';
$this->errorMessage = null !== $error ? $error->getMessage() : 'Reading from the response stream reached the idle timeout.';
}

/**
Expand Down
6 changes: 5 additions & 1 deletion src/Symfony/Component/HttpFoundation/Request.php
Expand Up @@ -795,7 +795,11 @@ public function getClientIps()
* being the original client, and each successive proxy that passed the request
* adding the IP address where it received the request from.
*
* @return string|null The client IP address
* If your reverse proxy uses a different header name than "X-Forwarded-For",
* ("Client-Ip" for instance), configure it via the $trustedHeaderSet
* argument of the Request::setTrustedProxies() method instead.
*
* @return string The client IP address
*
* @see getClientIps()
* @see http://en.wikipedia.org/wiki/X-Forwarded-For
Expand Down
Expand Up @@ -317,15 +317,15 @@ public function testGetConnectionConnectsIfNeeded()
public function testUrlDsn($url, $expectedDsn, $expectedUser = null, $expectedPassword = null)
{
$storage = new PdoSessionHandler($url);

$this->assertAttributeEquals($expectedDsn, 'dsn', $storage);

if (null !== $expectedUser) {
$this->assertAttributeEquals($expectedUser, 'username', $storage);
}

if (null !== $expectedPassword) {
$this->assertAttributeEquals($expectedPassword, 'password', $storage);
$reflection = new \ReflectionClass(PdoSessionHandler::class);

foreach (['dsn' => $expectedDsn, 'username' => $expectedUser, 'password' => $expectedPassword] as $property => $expectedValue) {
if (!isset($expectedValue)) {
continue;
}
$property = $reflection->getProperty($property);
$property->setAccessible(true);
$this->assertSame($expectedValue, $property->getValue($storage));
}
}

Expand Down
Expand Up @@ -205,6 +205,8 @@ private function generateAlpha2ToAlpha3Mapping(ArrayAccessibleResourceBundle $me
}
}

asort($alpha2ToAlpha3);

return $alpha2ToAlpha3;
}
}

0 comments on commit 2d594d5

Please sign in to comment.