-
-
Notifications
You must be signed in to change notification settings - Fork 390
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PHP 8: "PDOException: There is no active transaction" #1202
Comments
Why would we hide this fact to our users? |
Because user want to commit already commited transaction. So all is fine basically. No Exception is needed. But I'm little confused since MariaDb doc states something different:
But it looks to me it is about PHP version not the Database. |
Please elaborate. What code using |
Reproduceable with
New property name (press to stop adding fields): symfony console make:entity B
Field type (enter ? to see all types) [string]:
What class should this entity be related to?:
Is the B.a property allowed to be null (nullable)? (yes/no) [yes]: Do you want to add a new property to A so that you can access/update B objects from it - e.g. $a->getBs()? (yes/no) [yes]: A new property will also be added to the A class so that you can access the related B objects from it. New field name inside A [bs]: updated: src/Entity/B.php Add another property? Enter the property name (or press to stop adding fields):
Error There is no active transaction exit status 1 Workaround |
Ok so your issue is when executing |
Please get a stack trace for the migrate command that fails. Please also read https://www.doctrine-project.org/projects/doctrine-migrations/en/3.3/explanation/implicit-commits |
The above example (#1202 (comment)) produces a However, adding isTransactional with return false in a migration did not help
I do have an Exception trace of the "There is no active transaction"-error:
|
Hey! I wrote this error message! What do you think about it? |
Not sure if zenstruck/foundry#207 is related but I discovered this error only occurs when php >= 8 and dbal >= 3. With php 8 and dbal 2.13.4, no error. |
🤔 it's weird that the DBAL has an impact here, but maybe that's because it has some influence on the version of some other packages? |
It works as expected when I add a dbal 3 conflict - dbal is the only package that changes. |
When trying to work around the initial bug, I played with However, I expect that it is working by default. So when using MySQL/MariaDB/Oracle transactional should be set to false automatically, as they do not support transactional DDL-statements or at least if DDL-statements are used in a migration. |
Thanks @alexgit2k, overriding |
I think we have considered and rejected this in the past. You can read the very long #1104 and all link threads, and IMO you should be able to learn more about what lead to the current situation here. Closing. |
Thanks for the link @greg0ire, I understand the issue better now. |
@greg0ire I know it now, but for other developers throwing this exception without further information is just PITA. Or you just want to punish them for using MySQL/MariaDB/Oracle ;-) |
Can we really be sure this error message will only ever happen in that situation?
👼 |
I don't know, but accordingly to #1104 this wasn't an issue with earlier versions of doctrine-migrations. It has also been fixed in doctrine-migrations 2.3 (#1104 (comment)), but I haven't found a fix for doctrine-migrations 3, although #1104 has been closed. |
I have SAME problem in my own framework exactly trying to excecute MIGRATIONS with PHP 8+ Any glue about what is the cause for it? |
@boctulus have you read and understood https://www.doctrine-project.org/projects/doctrine-migrations/en/stable/explanation/implicit-commits ? |
Under PHP 8 there is Exception thrown, when transaction was autocommited.
PDOException: There is no active transaction
This is the change in PHP sources: php/php-src@990bb34
Ideal would be not to throw the exception if transaction was already commited.
This is similar to this issue in unrelated project: yiisoft/yii2#18406
The text was updated successfully, but these errors were encountered: