Skip to content
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 "There is no active transaction" with a pdosqlexec with transaction #1626

Closed
victorjkhalaf opened this issue Aug 3, 2021 · 2 comments · Fixed by #1628
Closed

PHP 8 "There is no active transaction" with a pdosqlexec with transaction #1626

victorjkhalaf opened this issue Aug 3, 2021 · 2 comments · Fixed by #1628

Comments

@victorjkhalaf
Copy link

victorjkhalaf commented Aug 3, 2021

Describe the bug
Since the PHP 8 update having an xml block for pdosqlexec with a transaction will trigger the following error message upon building

BUILD FAILED
/build.xml:361:138: /build.xml:361:138: There is no active transaction

Steps To Reproduce

Having a block like the following will trigger it

<pdosqlexec url="xxxx:host=xxxx" encoding="xxxx" userid="xxxxx" password="xxxx" onerror="abort">
            <transaction>DROP DATABASE IF EXISTS `xxxxx`;</transaction>
            <transaction>CREATE DATABASE `xxxxx`;</transaction>
</pdosqlexec>

Expected behavior
It should run the query without any warnings as pre-PHP8.

Additional context
This seems to be a known issue with other packages that run migrations or provide DB abstraction layers.
doctrine/migrations#1104
yiisoft/yii2#18406

@siad007
Copy link
Member

siad007 commented Aug 22, 2021

@victorjkhalaf thanks for the bug report - it was fixed in the attached PR

@ogmueller
Copy link

I am using dev-main, but this fix still doesn't work, except if I add autocommit="true to pdosqlexec.

so this is NOT working:

        <pdosqlexec url="${db.pdo.driver}:host=${db.host}"
            userId="${db.user}" password="${db.password}"
            onerror="abort">
                DROP DATABASE IF EXISTS `${call.db.name}`;
                CREATE DATABASE `${call.db.name}`;
        </pdosqlexec>

this is working (enabling autocommit):

        <pdosqlexec url="${db.pdo.driver}:host=${db.host}"
            userId="${db.user}" password="${db.password}"
            autocommit="true" onerror="abort">
                DROP DATABASE IF EXISTS `${call.db.name}`;
                CREATE DATABASE `${call.db.name}`;
        </pdosqlexec>

But I would assume, that this is still not as expected. The drop and create should work no matter if autocommit is on or off.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

3 participants