Skip to content

Commit ea98331

Browse files
committed
Merge branch '4.1'
* 4.1: (31 commits) Documented the false_values option of checkbox types Added the versionadded directive Update the documentation for Symfony Flex Improved the multiple user providers article Reowrd to restore the original meaning Removed a no longer relevant text Update NotBlank constraint description add missing argument binding section Added a minor note about Composer's plaform config Documented the use of binary values as container params Documented the support of iterators in write() and writeln() Update 3.3-di-changes.rst ...
2 parents 8ffcfca + 8c63a98 commit ea98331

File tree

17 files changed

+285
-58
lines changed

17 files changed

+285
-58
lines changed

components/http_foundation/session_configuration.rst

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ easily serve as examples if you wish to write your own.
7373

7474
* :class:`Symfony\\Component\\HttpFoundation\\Session\\Storage\\Handler\\PdoSessionHandler`
7575
* :class:`Symfony\\Component\\HttpFoundation\\Session\\Storage\\Handler\\MemcachedSessionHandler`
76+
* :class:`Symfony\\Component\\HttpFoundation\\Session\\Storage\\Handler\\MigratingSessionHandler`
7677
* :class:`Symfony\\Component\\HttpFoundation\\Session\\Storage\\Handler\\RedisSessionHandler`
7778
* :class:`Symfony\\Component\\HttpFoundation\\Session\\Storage\\Handler\\MongoDbSessionHandler`
7879
* :class:`Symfony\\Component\\HttpFoundation\\Session\\Storage\\Handler\\NullSessionHandler`
@@ -87,6 +88,32 @@ Example usage::
8788
$sessionStorage = new NativeSessionStorage(array(), new PdoSessionHandler($pdo));
8889
$session = new Session($sessionStorage);
8990

91+
Migrating Between Save Handlers
92+
-------------------------------
93+
94+
.. versionadded:: 4.1
95+
  The ``MigratingSessionHandler`` class was introduced in Symfony 4.1.
96+
97+
If your application changes the way sessions are stored, use the
98+
:class:`Symfony\\Component\\HttpFoundation\\Session\\Storage\\Handler\\MigratingSessionHandler`
99+
to migrate between old and new save handlers without losing session data.
100+
101+
This is the recommended migration workflow:
102+
103+
#. Switch to the migrating handler, with your new handler as the write-only one.
104+
The old handler behaves as usual and sessions get written to the new one::
105+
106+
$sessionStorage = new MigratingSessionHandler($oldSessionStorage, $newSessionStorage);
107+
108+
#. After your session gc period, verify that the data in the new handler is correct.
109+
#. Update the migrating handler to use the old handler as the write-only one, so
110+
the sessions will now be read from the new handler. This step allows easier rollbacks::
111+
112+
$sessionStorage = new MigratingSessionHandler($newSessionStorage, $oldSessionStorage);
113+
114+
#. After verifying that the sessions in your application are working, switch
115+
from the migrating handler to the new handler.
116+
90117
Configuring PHP Sessions
91118
~~~~~~~~~~~~~~~~~~~~~~~~
92119

console.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,10 @@ messages to the console)::
101101
'',
102102
]);
103103

104+
// the value returned by someMethod() can be an iterator (https://secure.php.net/iterator)
105+
// that generates and returns the messages with the 'yield' PHP keyword
106+
$output->writeln($this->someMethod());
107+
104108
// outputs a message followed by a "\n"
105109
$output->writeln('Whoa!');
106110

@@ -109,6 +113,10 @@ messages to the console)::
109113
$output->write('create a user.');
110114
}
111115

116+
.. versionadded:: 4.1
117+
The support of PHP iterators in the ``write()`` and ``writeln()`` methods
118+
was introduced in Symfony 4.1.
119+
112120
Now, try executing the command:
113121

114122
.. code-block:: terminal

console/request_context.rst

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ Configuring the Request Context Globally
2121

2222
To configure the Request Context - which is used by the URL Generator - you can
2323
redefine the parameters it uses as default values to change the default host
24-
(``localhost``) and scheme (``http``). You can also configure the base path if
25-
Symfony is not running in the root directory.
24+
(``localhost``) and scheme (``http``). You can also configure the base path (both for
25+
the URL generator and the assets) if Symfony is not running in the root directory.
2626

2727
Note that this does not impact URLs generated via normal web requests, since those
2828
will override the defaults.
@@ -36,6 +36,8 @@ will override the defaults.
3636
router.request_context.host: example.org
3737
router.request_context.scheme: https
3838
router.request_context.base_url: my/path
39+
asset.request_context.base_path: %router.request_context.base_url%
40+
asset.request_context.secure: true
3941
4042
.. code-block:: xml
4143
@@ -48,6 +50,8 @@ will override the defaults.
4850
<parameter key="router.request_context.host">example.org</parameter>
4951
<parameter key="router.request_context.scheme">https</parameter>
5052
<parameter key="router.request_context.base_url">my/path</parameter>
53+
<parameter key="asset.request_context.base_path">%router.request_context.base_url%</parameter>
54+
<parameter key="asset.request_context.secure">true</parameter>
5155
</parameters>
5256
5357
</container>
@@ -58,6 +62,11 @@ will override the defaults.
5862
$container->setParameter('router.request_context.host', 'example.org');
5963
$container->setParameter('router.request_context.scheme', 'https');
6064
$container->setParameter('router.request_context.base_url', 'my/path');
65+
$container->setParameter('asset.request_context.base_path', $container->getParameter('router.request_context.base_url'));
66+
$container->setParameter('asset.request_context.secure', true);
67+
68+
.. versionadded:: 3.4
69+
The ``asset.request_context.*`` parameters were introduced in Symfony 3.4.
6170

6271
Configuring the Request Context per Command
6372
-------------------------------------------

contributing/code/security.rst

Lines changed: 4 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ confirmed, the core team works on a solution following these steps:
3737
#. Package new versions for all affected versions;
3838
#. Publish the post on the official Symfony `blog`_ (it must also be added to
3939
the "`Security Advisories`_" category);
40-
#. Update the security advisory list (see below).
4140
#. Update the public `security advisories database`_ maintained by the
4241
FriendsOfPHP organization and which is used by the ``security:check`` command.
4342

@@ -100,47 +99,13 @@ Security Advisories
10099
You can check your Symfony application for known security vulnerabilities
101100
using the ``security:check`` command (see :doc:`/security/security_checker`).
102101

103-
This section indexes security vulnerabilities that were fixed in Symfony
104-
releases, starting from Symfony 1.0.0:
105-
106-
* Jul 17, 2017, `CVE-2017-11365: Empty passwords validation issue <https://symfony.com/blog/cve-2017-11365-empty-passwords-validation-issue>`_ (2.7.30, 2.7.31, 2.8.23, 2.8.24, 3.2.10, 3.2.11, 3.3.3, and 3.3.4)
107-
* May 9, 2016: `CVE-2016-2403: Unauthorized access on a misconfigured Ldap server when using an empty password <https://symfony.com/blog/cve-2016-2403-unauthorized-access-on-a-misconfigured-ldap-server-when-using-an-empty-password>`_ (2.8.0-2.8.5, 3.0.0-3.0.5)
108-
* May 9, 2016: `CVE-2016-4423: Large username storage in session <https://symfony.com/blog/cve-2016-4423-large-username-storage-in-session>`_ (2.3.0-2.3.40, 2.7.0-2.7.12, 2.8.0-2.8.5, 3.0.0-3.0.5)
109-
* January 18, 2016: `CVE-2016-1902: SecureRandom's fallback not secure when OpenSSL fails <https://symfony.com/blog/cve-2016-1902-securerandom-s-fallback-not-secure-when-openssl-fails>`_ (2.3.0-2.3.36, 2.6.0-2.6.12, 2.7.0-2.7.8)
110-
* November 23, 2015: `CVE-2015-8125: Potential Remote Timing Attack Vulnerability in Security Remember-Me Service <https://symfony.com/blog/cve-2015-8125-potential-remote-timing-attack-vulnerability-in-security-remember-me-service>`_ (2.3.35, 2.6.12 and 2.7.7)
111-
* November 23, 2015: `CVE-2015-8124: Session Fixation in the "Remember Me" Login Feature <https://symfony.com/blog/cve-2015-8124-session-fixation-in-the-remember-me-login-feature>`_ (2.3.35, 2.6.12 and 2.7.7)
112-
* May 26, 2015: `CVE-2015-4050: ESI unauthorized access <https://symfony.com/blog/cve-2015-4050-esi-unauthorized-access>`_ (Symfony 2.3.29, 2.5.12 and 2.6.8)
113-
* April 1, 2015: `CVE-2015-2309: Unsafe methods in the Request class <https://symfony.com/blog/cve-2015-2309-unsafe-methods-in-the-request-class>`_ (Symfony 2.3.27, 2.5.11 and 2.6.6)
114-
* April 1, 2015: `CVE-2015-2308: Esi Code Injection <https://symfony.com/blog/cve-2015-2308-esi-code-injection>`_ (Symfony 2.3.27, 2.5.11 and 2.6.6)
115-
* September 3, 2014: `CVE-2014-6072: CSRF vulnerability in the Web Profiler <https://symfony.com/blog/cve-2014-6072-csrf-vulnerability-in-the-web-profiler>`_ (Symfony 2.3.19, 2.4.9 and 2.5.4)
116-
* September 3, 2014: `CVE-2014-6061: Security issue when parsing the Authorization header <https://symfony.com/blog/cve-2014-6061-security-issue-when-parsing-the-authorization-header>`_ (Symfony 2.3.19, 2.4.9 and 2.5.4)
117-
* September 3, 2014: `CVE-2014-5245: Direct access of ESI URLs behind a trusted proxy <https://symfony.com/blog/cve-2014-5245-direct-access-of-esi-urls-behind-a-trusted-proxy>`_ (Symfony 2.3.19, 2.4.9 and 2.5.4)
118-
* September 3, 2014: `CVE-2014-5244: Denial of service with a malicious HTTP Host header <https://symfony.com/blog/cve-2014-5244-denial-of-service-with-a-malicious-http-host-header>`_ (Symfony 2.3.19, 2.4.9 and 2.5.4)
119-
* July 15, 2014: `Security releases: Symfony 2.3.18, 2.4.8, and 2.5.2 released <https://symfony.com/blog/security-releases-cve-2014-4931-symfony-2-3-18-2-4-8-and-2-5-2-released>`_ (`CVE-2014-4931 <http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2014-4931>`_)
120-
* October 10, 2013: `Security releases: Symfony 2.0.25, 2.1.13, 2.2.9, and 2.3.6 released <https://symfony.com/blog/security-releases-cve-2013-5958-symfony-2-0-25-2-1-13-2-2-9-and-2-3-6-released>`_ (`CVE-2013-5958 <http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2013-5958>`_)
121-
* August 7, 2013: `Security releases: Symfony 2.0.24, 2.1.12, 2.2.5, and 2.3.3 released <https://symfony.com/blog/security-releases-symfony-2-0-24-2-1-12-2-2-5-and-2-3-3-released>`_ (`CVE-2013-4751 <http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2013-4751>`_ and `CVE-2013-4752 <http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2013-4752>`_)
122-
* January 17, 2013: `Security release: Symfony 2.0.22 and 2.1.7 released <https://symfony.com/blog/security-release-symfony-2-0-22-and-2-1-7-released>`_ (`CVE-2013-1348 <http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2013-1348>`_ and `CVE-2013-1397 <http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2013-1397>`_)
123-
* December 20, 2012: `Security release: Symfony 2.0.20 and 2.1.5 <https://symfony.com/blog/security-release-symfony-2-0-20-and-2-1-5-released>`_ (`CVE-2012-6431 <http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2012-6431>`_ and `CVE-2012-6432 <http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2012-6432>`_)
124-
* November 29, 2012: `Security release: Symfony 2.0.19 and 2.1.4 <https://symfony.com/blog/security-release-symfony-2-0-19-and-2-1-4>`_
125-
* November 25, 2012: `Security release: symfony 1.4.20 released <https://symfony.com/blog/security-release-symfony-1-4-20-released>`_ (`CVE-2012-5574 <http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2012-5574>`_)
126-
* August 28, 2012: `Security Release: Symfony 2.0.17 released <https://symfony.com/blog/security-release-symfony-2-0-17-released>`_
127-
* May 30, 2012: `Security Release: symfony 1.4.18 released <https://symfony.com/blog/security-release-symfony-1-4-18-released>`_ (`CVE-2012-2667 <http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2012-2667>`_)
128-
* February 24, 2012: `Security Release: Symfony 2.0.11 released <https://symfony.com/blog/security-release-symfony-2-0-11-released>`_
129-
* November 16, 2011: `Security Release: Symfony 2.0.6 <https://symfony.com/blog/security-release-symfony-2-0-6>`_
130-
* March 21, 2011: `symfony 1.3.10 and 1.4.10: security releases <https://symfony.com/blog/symfony-1-3-10-and-1-4-10-security-releases>`_
131-
* June 29, 2010: `Security Release: symfony 1.3.6 and 1.4.6 <https://symfony.com/blog/security-release-symfony-1-3-6-and-1-4-6>`_
132-
* May 31, 2010: `symfony 1.3.5 and 1.4.5 <https://symfony.com/blog/symfony-1-3-5-and-1-4-5>`_
133-
* February 25, 2010: `Security Release: 1.2.12, 1.3.3 and 1.4.3 <https://symfony.com/blog/security-release-1-2-12-1-3-3-and-1-4-3>`_
134-
* February 13, 2010: `symfony 1.3.2 and 1.4.2 <https://symfony.com/blog/symfony-1-3-2-and-1-4-2>`_
135-
* April 27, 2009: `symfony 1.2.6: Security fix <https://symfony.com/blog/symfony-1-2-6-security-fix>`_
136-
* October 03, 2008: `symfony 1.1.4 released: Security fix <https://symfony.com/blog/symfony-1-1-4-released-security-fix>`_
137-
* May 14, 2008: `symfony 1.0.16 is out <https://symfony.com/blog/symfony-1-0-16-is-out>`_
138-
* April 01, 2008: `symfony 1.0.13 is out <https://symfony.com/blog/symfony-1-0-13-is-out>`_
139-
* March 21, 2008: `symfony 1.0.12 is (finally) out ! <https://symfony.com/blog/symfony-1-0-12-is-finally-out>`_
140-
* June 25, 2007: `symfony 1.0.5 released (security fix) <https://symfony.com/blog/symfony-1-0-5-released-security-fix>`_
102+
Check the `Security Advisories`_ blog category for a list of all security
103+
vulnerabilities that were fixed in Symfony releases, starting from Symfony
104+
1.0.0.
141105

142106
.. _Git repository: https://github.com/symfony/symfony
143107
.. _blog: https://symfony.com/blog/
144108
.. _Security Advisories: https://symfony.com/blog/category/security-advisories
145109
.. _`security advisories database`: https://github.com/FriendsOfPHP/security-advisories
146110
.. _`mitre.org`: https://cveform.mitre.org/
111+
.. _`Security Advisories`: https://symfony.com/blog/category/security-advisories

messenger.rst

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -605,6 +605,116 @@ you can disable them like this:
605605
),
606606
));
607607
608+
Using Middleware Factories
609+
~~~~~~~~~~~~~~~~~~~~~~~~~~
610+
611+
Some third-party bundles and libraries provide configurable middleware via
612+
factories. Using them requires a two-step configuration based on Symfony's
613+
:doc:`dependency injection </service_container>` features:
614+
615+
.. code-block:: yaml
616+
617+
services:
618+
619+
# Step 1: a factory class is registered as a service with the required
620+
# dependencies to instantiate a middleware
621+
doctrine.orm.messenger.middleware_factory.transaction:
622+
class: Symfony\Bridge\Doctrine\Messenger\DoctrineTransactionMiddlewareFactory
623+
arguments: ['@doctrine']
624+
625+
# Step 2: an abstract definition that will call the factory with default
626+
# arguments or the one provided in the middleware config
627+
messenger.middleware.doctrine_transaction_middleware:
628+
class: Symfony\Bridge\Doctrine\Messenger\DoctrineTransactionMiddleware
629+
factory: ['@doctrine.orm.messenger.middleware_factory.transaction', 'createMiddleware']
630+
abstract: true
631+
# the default arguments to use when none provided from config. Example:
632+
# middleware:
633+
# - doctrine_transaction_middleware: ~
634+
arguments: ['default']
635+
636+
The "default" value in this example is the name of the entity manager to use,
637+
which is the argument expected by the
638+
``Symfony\Bridge\Doctrine\Messenger\DoctrineTransactionMiddlewareFactory::createMiddleware`` method.
639+
640+
Then you can reference and configure the
641+
``messenger.middleware.doctrine_transaction_middleware`` service as a middleware:
642+
643+
.. configuration-block::
644+
645+
.. code-block:: yaml
646+
647+
# config/packages/messenger.yaml
648+
framework:
649+
messenger:
650+
buses:
651+
command_bus:
652+
middleware:
653+
# Using defaults:
654+
- doctrine_transaction_middleware
655+
# Using another entity manager:
656+
- doctrine_transaction_middleware: ['custom']
657+
658+
.. code-block:: xml
659+
660+
<!-- config/packages/messenger.xml -->
661+
<container xmlns="http://symfony.com/schema/dic/symfony"
662+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
663+
xmlns:framework="http://symfony.com/schema/dic/symfony"
664+
xsi:schemaLocation="http://symfony.com/schema/dic/services
665+
http://symfony.com/schema/dic/services/services-1.0.xsd
666+
http://symfony.com/schema/dic/symfony
667+
http://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
668+
669+
<framework:config>
670+
<framework:messenger>
671+
<framework:bus name="command_bus">
672+
<!-- Using defaults: -->
673+
<framework:middleware id="doctrine_transaction_middleware" />
674+
<!-- Using another entity manager -->
675+
<framework:middleware id="doctrine_transaction_middleware">
676+
<framework:argument>custom</framework:argument>
677+
</framework:middleware>
678+
</framework:bus>
679+
</framework:messenger>
680+
</framework:config>
681+
</container>
682+
683+
.. code-block:: php
684+
685+
// config/packages/messenger.php
686+
$container->loadFromExtension('framework', array(
687+
'messenger' => array(
688+
'buses' => array(
689+
'command_bus' => array(
690+
'middleware' => array(
691+
// Using defaults:
692+
'doctrine_transaction_middleware',
693+
// Using another entity manager
694+
array('id' => 'doctrine_transaction_middleware', 'arguments' => array('custom')),
695+
),
696+
),
697+
),
698+
),
699+
));
700+
701+
.. note::
702+
703+
The ``doctrine_transaction_middleware`` shortcut is a convention. The real
704+
service id is prefixed with the ``messenger.middleware.`` namespace.
705+
706+
.. note::
707+
708+
Middleware factories only allow scalar and array arguments in config (no
709+
references to other services). For most advanced use-cases, register a
710+
concrete definition of the middleware manually and use its id.
711+
712+
.. tip::
713+
714+
The ``doctrine_transaction_middleware`` is a built-in middleware wired
715+
automatically when the DoctrineBundle and the Messenger component are
716+
installed and enabled.
717+
608718
Your own Transport
609719
------------------
610720

reference/constraints/NotBlank.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ NotBlank
22
========
33

44
Validates that a value is not blank - meaning not equal to a blank string,
5-
a blank array or ``null``::
5+
a blank array, ``null`` or ``false``::
66

77
if (false === $value || (empty($value) && '0' != $value)) {
88
// validation will fail

reference/forms/types/checkbox.rst

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,16 @@ CheckboxType Field
66

77
Creates a single input checkbox. This should always be used for a field
88
that has a boolean value: if the box is checked, the field will be set to
9-
true, if the box is unchecked, the value will be set to false.
9+
true, if the box is unchecked, the value will be set to false. Optionally
10+
you can specify an array of values that, if submitted, will be evaluated
11+
to "false" as well (this differs from what HTTP defines, but can be handy
12+
if you want to handle submitted values like "0" or "false").
1013

1114
+-------------+------------------------------------------------------------------------+
1215
| Rendered as | ``input`` ``checkbox`` field |
1316
+-------------+------------------------------------------------------------------------+
14-
| Options | - `value`_ |
17+
| Options | - `false_values`_ |
18+
| | - `value`_ |
1519
+-------------+------------------------------------------------------------------------+
1620
| Overridden | - `compound`_ |
1721
| options | - `empty_data`_ |
@@ -48,6 +52,13 @@ Example Usage
4852
Field Options
4953
-------------
5054

55+
false_values
56+
~~~~~~~~~~~~
57+
58+
**type**: ``array`` **default**: ``array(null)``
59+
60+
An array of values to be interpreted as ``false``.
61+
5162
.. include:: /reference/forms/types/options/value.rst.inc
5263

5364
Overridden Options

reference/forms/types/options/choice_attr.rst.inc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@ choice_attr
33

44
**type**: ``array``, ``callable`` or ``string`` **default**: ``array()``
55

6-
Use this to add additional HTML attributes to each choice. This can be an array
7-
of attributes (if they are the same for each choice), a callable or a property path
6+
Use this to add additional HTML attributes to each choice. This can be
7+
an associative array where the keys match the choice keys and the values
8+
are the attributes for each choice, a callable or a property path
89
(just like `choice_label`_).
910

1011
If an array, the keys of the ``choices`` array must be used as keys::

0 commit comments

Comments
 (0)