From d75b53bed8bb9d748e53f01ee2afcaee0c0ced29 Mon Sep 17 00:00:00 2001 From: "Thibault G." Date: Tue, 25 Mar 2025 16:05:56 +0100 Subject: [PATCH 1/7] Informations about disabling the autocommit mode --- reference/configuration/doctrine.rst | 88 +++++++++++++++++++++++++++- 1 file changed, 87 insertions(+), 1 deletion(-) diff --git a/reference/configuration/doctrine.rst b/reference/configuration/doctrine.rst index 6e5bd12aaea..cd4c878b41c 100644 --- a/reference/configuration/doctrine.rst +++ b/reference/configuration/doctrine.rst @@ -166,6 +166,91 @@ you can access it using the ``getConnection()`` method and the name of the conne } } +Disabling the Autocommit mode +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +If you want to disable the `Autocommit`_ mode, you need to update your DBAL configuration as follows: + +.. configuration-block:: + + .. code-block:: yaml + + doctrine: + dbal: + connections: + default: + options: + # Only if you're using DBAL with PDO: + !php/const PDO::ATTR_AUTOCOMMIT: false + + # This line disables auto-commit at the DBAL level: + auto_commit: false + + .. code-block:: xml + + + + false + + + + + +If you are managing your database migrations using the `Doctrine Migrations Bundle`_, you must also register a listener to ensure that the last migration is properly commited: + +.. configuration-block:: + + .. code-block:: yaml + + # config/services.yaml + services: + Doctrine\Migrations\Event\Listeners\AutoCommitListener: + tags: + - name: doctrine.event_listener + event: !php/const Doctrine\Migrations\Events::onMigrationsMigrated + + .. code-block:: xml + + + + + + + + + + + + + .. code-block:: php + + // config/services.php + namespace Symfony\Component\DependencyInjection\Loader\Configurator; + + use Doctrine\Migrations\Event\Listeners\AutoCommitListener; + use Doctrine\Migrations\Events; + + return function(ContainerConfigurator $container): void { + $services = $container->services(); + + $services->set(AutoCommitListener::class) + ->tag('doctrine.event_listener', [ + 'event' => Events::onMigrationsMigrated + ]) + ; + }; + Doctrine ORM Configuration -------------------------- @@ -544,6 +629,7 @@ Ensure your environment variables are correctly set in the ``.env.local`` or This configuration secures your MySQL connection with SSL by specifying the paths to the required certificates. - +.. _Autocommit: https://en.wikipedia.org/wiki/Autocommit +.. _Doctrine Migrations Bundle: https://github.com/doctrine/DoctrineMigrationsBundle .. _DBAL documentation: https://www.doctrine-project.org/projects/doctrine-dbal/en/current/reference/configuration.html .. _`Doctrine Metadata Drivers`: https://www.doctrine-project.org/projects/doctrine-orm/en/current/reference/metadata-drivers.html From e3027d906123678424b884754274ef0b86209b9f Mon Sep 17 00:00:00 2001 From: "Thibault G." Date: Tue, 25 Mar 2025 16:13:41 +0100 Subject: [PATCH 2/7] add missing quotes and missing xsd schema --- reference/configuration/doctrine.rst | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/reference/configuration/doctrine.rst b/reference/configuration/doctrine.rst index cd4c878b41c..54a44df24be 100644 --- a/reference/configuration/doctrine.rst +++ b/reference/configuration/doctrine.rst @@ -192,18 +192,22 @@ If you want to disable the `Autocommit`_ mode, you need to update your DBAL conf xmlns:doctrine="http://symfony.com/schema/dic/doctrine" xmlns="http://symfony.com/schema/dic/services" xsi:schemaLocation="http://symfony.com/schema/dic/services - https://symfony.com/schema/dic/services/services-1.0.xsd> + https://symfony.com/schema/dic/services/services-1.0.xsd + http://symfony.com/schema/dic/doctrine + https://symfony.com/schema/dic/doctrine/doctrine-1.0.xsd"> + - false + + false + - If you are managing your database migrations using the `Doctrine Migrations Bundle`_, you must also register a listener to ensure that the last migration is properly commited: .. configuration-block:: From e3a7a81654c51046c2605c803d99e348024293f6 Mon Sep 17 00:00:00 2001 From: "Thibault G." Date: Tue, 25 Mar 2025 16:23:49 +0100 Subject: [PATCH 3/7] fixed lint --- reference/configuration/doctrine.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/reference/configuration/doctrine.rst b/reference/configuration/doctrine.rst index 54a44df24be..6e836814f17 100644 --- a/reference/configuration/doctrine.rst +++ b/reference/configuration/doctrine.rst @@ -219,7 +219,7 @@ If you are managing your database migrations using the `Doctrine Migrations Bund Doctrine\Migrations\Event\Listeners\AutoCommitListener: tags: - name: doctrine.event_listener - event: !php/const Doctrine\Migrations\Events::onMigrationsMigrated + event: onMigrationsMigrated .. code-block:: xml @@ -232,7 +232,7 @@ If you are managing your database migrations using the `Doctrine Migrations Bund - + From 6acc681a580465f8d468e8e62c8d354eab6a1f13 Mon Sep 17 00:00:00 2001 From: "Thibault G." Date: Tue, 25 Mar 2025 16:25:23 +0100 Subject: [PATCH 4/7] fixed lint --- reference/configuration/doctrine.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/reference/configuration/doctrine.rst b/reference/configuration/doctrine.rst index 6e836814f17..7a3fb802f42 100644 --- a/reference/configuration/doctrine.rst +++ b/reference/configuration/doctrine.rst @@ -187,6 +187,7 @@ If you want to disable the `Autocommit`_ mode, you need to update your DBAL conf auto_commit: false .. code-block:: xml + Date: Wed, 26 Mar 2025 10:24:39 +0100 Subject: [PATCH 5/7] fix: shorter section title Co-authored-by: Oskar Stark --- reference/configuration/doctrine.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/reference/configuration/doctrine.rst b/reference/configuration/doctrine.rst index 7a3fb802f42..793ecb803c2 100644 --- a/reference/configuration/doctrine.rst +++ b/reference/configuration/doctrine.rst @@ -166,8 +166,8 @@ you can access it using the ``getConnection()`` method and the name of the conne } } -Disabling the Autocommit mode -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Disable Autocommit Mode +~~~~~~~~~~~~~~~~~~~~~~~ If you want to disable the `Autocommit`_ mode, you need to update your DBAL configuration as follows: From 2a1c31bc4b250971def9e2aa8e399a112519a2fe Mon Sep 17 00:00:00 2001 From: "Thibault G." Date: Wed, 26 Mar 2025 10:25:33 +0100 Subject: [PATCH 6/7] Improved sentence formulation Co-authored-by: Oskar Stark --- reference/configuration/doctrine.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reference/configuration/doctrine.rst b/reference/configuration/doctrine.rst index 793ecb803c2..2e38e69b2c9 100644 --- a/reference/configuration/doctrine.rst +++ b/reference/configuration/doctrine.rst @@ -169,7 +169,7 @@ you can access it using the ``getConnection()`` method and the name of the conne Disable Autocommit Mode ~~~~~~~~~~~~~~~~~~~~~~~ -If you want to disable the `Autocommit`_ mode, you need to update your DBAL configuration as follows: +To disable the `Autocommit`_ mode, update your DBAL configuration as follows: .. configuration-block:: From 205c882a95452c8245c4734122713b0aae4a7957 Mon Sep 17 00:00:00 2001 From: "Thibault G." Date: Wed, 26 Mar 2025 10:25:44 +0100 Subject: [PATCH 7/7] Improved sentence formulation Co-authored-by: Oskar Stark --- reference/configuration/doctrine.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reference/configuration/doctrine.rst b/reference/configuration/doctrine.rst index 2e38e69b2c9..be655f90ae9 100644 --- a/reference/configuration/doctrine.rst +++ b/reference/configuration/doctrine.rst @@ -209,7 +209,7 @@ To disable the `Autocommit`_ mode, update your DBAL configuration as follows: -If you are managing your database migrations using the `Doctrine Migrations Bundle`_, you must also register a listener to ensure that the last migration is properly commited: +When using the `Doctrine Migrations Bundle`_, an additional listener needs to be registered to ensure that the last migration is properly committed: .. configuration-block::