Skip to content

Commit a3203cd

Browse files
committed
Merge branch '5.2' into 5.x
* 5.2: Add troubleshooting for parallel merges to maintainer guide Update framework.rst JsonResponse content updated Fixed table markup [Messenger] Add options for PostgreSQL LISTEN/NOTIFY support Update data_collector.rst [#14728] Be explicit about the double 's' [#14700] Minor rewording Update login_link.rst Added explaination on context in events and initial marking [Messenger] fix typo [Messenger] Routing & Inheritance docs(http-client): fix default retry_failed configuration example [Cache] Add TLS scheme for Redis connection
2 parents dbb2c80 + 78bc898 commit a3203cd

File tree

8 files changed

+184
-20
lines changed

8 files changed

+184
-20
lines changed

_build/maintainer_guide.rst

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,26 @@ forgot to merge as ``gh merge NNNNN -s 5.1`` to change the merge branch. Solutio
352352
$ git merge 5.1
353353
$ ...
354354
355+
Merging while the target branch changed
356+
.......................................
357+
358+
Sometimes, someone else merges a PR in ``5.x`` at the same time as you are
359+
doing it. In these cases, ``gh merge ...`` failes to push. Solve this by
360+
resetting your local branch and restarting the merge:
361+
362+
.. code-block:: terminal
363+
364+
$ gh merge ...
365+
# this failed
366+
367+
# fetch the updated 5.x branch from GitHub
368+
$ git fetch upstream
369+
$ git checkout 5.x
370+
$ git reset --hard upstream/5.x
371+
372+
# restart the merge
373+
$ gh merge ...
374+
355375
.. _`symfony/symfony-docs`: https://github.com/symfony/symfony-docs
356376
.. _`Symfony Docs team`: https://github.com/orgs/symfony/teams/team-symfony-docs
357377
.. _`Symfony's respectful review comments`: https://symfony.com/doc/current/contributing/community/review-comments.html

components/cache/adapters/redis_adapter.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,15 +62,16 @@ helper method allows creating and configuring the Redis client class instance us
6262
);
6363

6464
The DSN can specify either an IP/host (and an optional port) or a socket path, as well as a
65-
password and a database index.
65+
password and a database index. To enable TLS for connections, the scheme ``redis`` must be
66+
replaced by ``rediss`` (the second ``s`` means "secure").
6667

6768
.. note::
6869

6970
A `Data Source Name (DSN)`_ for this adapter must use the following format.
7071

7172
.. code-block:: text
7273
73-
redis://[pass@][ip|host|socket[:port]][/db-index]
74+
redis[s]://[pass@][ip|host|socket[:port]][/db-index]
7475
7576
Below are common examples of valid DSNs showing a combination of available values::
7677

components/http_foundation.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -706,9 +706,11 @@ class, which can make this even easier::
706706
// if you know the data to send when creating the response
707707
$response = new JsonResponse(['data' => 123]);
708708

709-
// if you don't know the data to send when creating the response
709+
// if you don't know the data to send or if you want to customize the encoding options
710710
$response = new JsonResponse();
711711
// ...
712+
// configure any custom encoding options (if needed, it must be called before "setData()")
713+
//$response->setEncodingOptions(JsonResponse::DEFAULT_ENCODING_OPTIONS | \JSON_PRESERVE_ZERO_FRACTION);
712714
$response->setData(['data' => 123]);
713715

714716
// if the data to send is already encoded in JSON

messenger.rst

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,13 @@ to multiple transports:
313313
],
314314
]);
315315
316+
.. note::
317+
318+
If you configure routing for both a child and parent class, both rules
319+
are used. E.g. if you have an ``SmsNotification`` object that extends
320+
from ``Notification``, both the routing for ``Notification`` and
321+
``SmsNotification`` will be used.
322+
316323
Doctrine Entities in Messages
317324
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
318325

@@ -1107,6 +1114,12 @@ a table named ``messenger_messages``.
11071114
Or, to create the table yourself, set the ``auto_setup`` option to ``false`` and
11081115
:ref:`generate a migration <doctrine-creating-the-database-tables-schema>`.
11091116

1117+
.. caution::
1118+
1119+
The datetime property of the messages stored in the database uses the
1120+
timezone of the current system. This may cause issues if multiple machines
1121+
with different timezone configuration use the same storage.
1122+
11101123
The transport has a number of options:
11111124

11121125
================== ===================================== ======================
@@ -1126,11 +1139,28 @@ auto_setup Whether the table should be created
11261139
automatically during send / get. true
11271140
================== ===================================== ======================
11281141

1129-
.. caution::
1142+
.. versionadded:: 5.1
11301143

1131-
The datetime property of the messages stored in the database uses the
1132-
timezone of the current system. This may cause issues if multiple machines
1133-
with different timezone configuration use the same storage.
1144+
The ability to leverage PostgreSQL's LISTEN/NOTIFY was introduced
1145+
in Symfony 5.1.
1146+
1147+
When using PostgreSQL, you have access to the following options to leverage
1148+
the `LISTEN/NOTIFY`_ feature. This allow for a more performant approach
1149+
than the default polling behavior of the Doctrine transport because
1150+
PostgreSQL will directly notify the workers when a new message is inserted
1151+
in the table.
1152+
1153+
======================= ========================================== ======================
1154+
Option Description Default
1155+
======================= ========================================== ======================
1156+
use_notify Whether to use LISTEN/NOTIFY. true
1157+
check_delayed_interval The interval to check for delayed 1000
1158+
messages, in milliseconds.
1159+
Set to 0 to disable checks.
1160+
get_notify_timeout The length of time to wait for a 0
1161+
response when calling
1162+
``PDO::pgsqlGetNotify```, in milliseconds.
1163+
======================= ========================================== ======================
11341164

11351165
Beanstalkd Transport
11361166
~~~~~~~~~~~~~~~~~~~~
@@ -2081,3 +2111,4 @@ Learn more
20812111
.. _`Long polling`: https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-short-and-long-polling.html
20822112
.. _`Visibility Timeout`: https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-visibility-timeout.html
20832113
.. _`FIFO queue`: https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/FIFO-queues.html
2114+
.. _`LISTEN/NOTIFY`: https://www.postgresql.org/docs/current/sql-notify.html

profiler/data_collector.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ request::
3131
use Symfony\Bundle\FrameworkBundle\DataCollector\AbstractDataCollector;
3232
use Symfony\Component\HttpFoundation\Request;
3333
use Symfony\Component\HttpFoundation\Response;
34-
use Symfony\Component\HttpKernel\DataCollector\DataCollector;
3534

3635
class RequestCollector extends AbstractDataCollector
3736
{

reference/configuration/framework.rst

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -831,17 +831,18 @@ will automatically retry failed HTTP requests.
831831
# ...
832832
http_client:
833833
# ...
834-
retry_failed:
835-
# retry_strategy: app.custom_strategy
836-
http_codes:
837-
0: ['GET', 'HEAD'] # retry network errors if request method is GET or HEAD
838-
429: true # retry all responses with 429 status code
839-
500: ['GET', 'HEAD']
840-
max_retries: 2
841-
delay: 1000
842-
multiplier: 3
843-
max_delay: 5000
844-
jitter: 0.3
834+
default_options:
835+
retry_failed:
836+
# retry_strategy: app.custom_strategy
837+
http_codes:
838+
0: ['GET', 'HEAD'] # retry network errors if request method is GET or HEAD
839+
429: true # retry all responses with 429 status code
840+
500: ['GET', 'HEAD']
841+
max_retries: 2
842+
delay: 1000
843+
multiplier: 3
844+
max_delay: 5000
845+
jitter: 0.3
845846
846847
scoped_clients:
847848
my_api.client:
@@ -1415,7 +1416,7 @@ The value can be one of:
14151416
``true``
14161417
Throw an exception when the requirements are not met;
14171418
``false``
1418-
Disable exceptions when the requirements are not met and return ``null``
1419+
Disable exceptions when the requirements are not met and return ``''``
14191420
instead;
14201421
``null``
14211422
Disable checking the requirements (thus, match the route even when the

security/login_link.rst

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -654,3 +654,88 @@ user create this POST request (e.g. by clicking a button)::
654654
<button type="submit">Continue</button>
655655
</form>
656656
{% endblock %}
657+
658+
Customizing the Success Handler
659+
-------------------------------
660+
661+
Sometimes, the default success handling does not fit your use-case (e.g.
662+
when you need to generate and return an API key). To customize how the
663+
success handler behaves, create your own
664+
:class:`Symfony\Component\Security\Http\Authentication\AuthenticationSuccessHandlerInterface`::
665+
666+
// src/Security/Authentication/AuthenticationSuccessHandler.php
667+
namespace App\Security\Authentication;
668+
669+
use Symfony\Component\HttpFoundation\JsonResponse;
670+
use Symfony\Component\HttpFoundation\Request;
671+
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
672+
use Symfony\Component\Security\Http\Authentication\AuthenticationSuccessHandlerInterface;
673+
674+
class AuthenticationSuccessHandler implements AuthenticationSuccessHandlerInterface
675+
{
676+
public function onAuthenticationSuccess(Request $request, TokenInterface $token): JsonResponse
677+
{
678+
$user = $token->getUser();
679+
$userApiToken = $user->getApiToken();
680+
681+
return new JsonResponse(['apiToken' => 'userApiToken']);
682+
}
683+
}
684+
685+
Then, configure this service ID as the ``success_handler``:
686+
687+
.. configuration-block::
688+
689+
.. code-block:: yaml
690+
691+
# config/packages/security.yaml
692+
security:
693+
firewalls:
694+
main:
695+
login_link:
696+
check_route: login_check
697+
lifetime: 600
698+
max_uses: 1
699+
success_handler: App\Security\Authentication\AuthenticationSuccessHandler
700+
701+
.. code-block:: xml
702+
703+
<!-- config/packages/security.xml -->
704+
<?xml version="1.0" encoding="UTF-8"?>
705+
<srv:container xmlns="http://symfony.com/schema/dic/security"
706+
xmlns:srv="http://symfony.com/schema/dic/services"
707+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
708+
xsi:schemaLocation="http://symfony.com/schema/dic/services
709+
https://symfony.com/schema/dic/services/services-1.0.xsd
710+
http://symfony.com/schema/dic/security
711+
https://symfony.com/schema/dic/security/security-1.0.xsd">
712+
713+
<config>
714+
<firewall name="main">
715+
<login-link check-route="login_check"
716+
check-post-only="true"
717+
max-uses="1"
718+
lifetime="600"
719+
success-handler="App\Security\Authentication\AuthenticationSuccessHandler"
720+
/>
721+
</firewall>
722+
</config>
723+
</srv:container>
724+
725+
.. code-block:: php
726+
727+
// config/packages/security.php
728+
use App\Security\Authentication\AuthenticationSuccessHandler;
729+
730+
$container->loadFromExtension('security', [
731+
'firewalls' => [
732+
'main' => [
733+
'login_link' => [
734+
'check_route' => 'login_check',
735+
'lifetime' => 600,
736+
'max_uses' => 1,
737+
'success_handler' => AuthenticationSuccessHandler::class,
738+
],
739+
],
740+
],
741+
]);

workflow.rst

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,11 +381,36 @@ order:
381381
* ``workflow.[workflow name].announce``
382382
* ``workflow.[workflow name].announce.[transition name]``
383383

384+
You can avoid triggering those events by using the context::
385+
386+
$workflow->apply($subject, $transitionName, [Workflow::DISABLE_ANNOUNCE_EVENT => true]);
387+
388+
.. versionadded:: 5.1
389+
390+
The ``Workflow::DISABLE_ANNOUNCE_EVENT`` constant was introduced in Symfony 5.1.
391+
392+
.. versionadded:: 5.2
393+
394+
In Symfony 5.2, the context is accessible in all events::
395+
396+
// $context must be an array
397+
$context = ['context_key' => 'context_value'];
398+
$workflow->apply($subject, $transitionName, $context);
399+
400+
// in an event listener
401+
$context = $event->getContext(); // returns ['context']
402+
384403
.. note::
385404

386405
The leaving and entering events are triggered even for transitions that stay
387406
in same place.
388407

408+
.. note::
409+
410+
If you initialize the marking by calling ``$workflow->getMarking($object);``,
411+
then the ``workflow.[workflow_name].entered.[initial_place_name]`` event will
412+
be called with the default context (``Workflow::DEFAULT_INITIAL_CONTEXT``).
413+
389414
Here is an example of how to enable logging for every time a "blog_publishing"
390415
workflow leaves a place::
391416

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy