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

2.0.40: yii\web\HttpException: PDO::inTransaction(): SQLSTATE[00000]: No error: PDO constructor was not called #18471

Closed
freddyw opened this issue Jan 7, 2021 · 13 comments

Comments

@freddyw
Copy link

freddyw commented Jan 7, 2021

What steps will reproduce the problem?

Update yii2 to 2.0.40 (from 2.39.3)

What is the expected result?

No errors

What do you get instead?

[error][yii\web\HttpException:500] yii\web\HttpException: PDO::inTransaction(): SQLSTATE[00000]: No error: PDO constructor was not called in controllers/DocumentController.php:614
Stack trace:
#0 [internal function]: app\controllers\DocumentController->actionUpdateKpiValuesCompany()
#1 vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#2 vendor/yiisoft/yii2/base/Controller.php(181): yii\base\InlineAction->runWithParams(Array)
#3 vendor/yiisoft/yii2/base/Module.php(534): yii\base\Controller->runAction('update-kpi-valu...', Array)
#4 vendor/yiisoft/yii2/web/Application.php(104): yii\base\Module->runAction('document/update...', Array)
#5 vendor/yiisoft/yii2/base/Application.php(392): yii\web\Application->handleRequest(Object(yii\web\Request))
#6 web/index.php(11): yii\base\Application->run()

Additional info

Q A
Yii version 2.0.40
PHP version 7.4.13
Operating system OracleLinux/7, Apache/2.4.6
@yii-bot
Copy link

yii-bot commented Jan 7, 2021

Thanks for posting in our issue tracker.
In order to properly assist you, we need additional information:

  • When does the issue occur?
  • What do you see?
  • What was the expected result?
  • Can you supply us with a stacktrace? (optional)
  • Do you have exact code to reproduce it? Maybe a PHPUnit tests that fails? (optional)

Thanks!

This is an automated comment, triggered by adding the label status:need more info.

@freddyw
Copy link
Author

freddyw commented Jan 7, 2021

When does the issue occur?
After an upgrade from 2.0.39.3 => 2.0.40 and using kartik\editable\Editable to edit a single value the "Internal Server Error" is thrown. The debug console shows the correct update query. Then, immediately after "yii\db\Transaction::commit" the "yii\web\HttpException: PDO::inTransaction(): SQLSTATE[00000]: No error: PDO constructor was not called" error shows up.

What do you see?
"Internal Server error"

What was the expected result?
the value is updated correctly, the transaction is committed.

I am going out on a limb here, but maybe the fix for "Bug #18406" has something to do with this?

@bizley
Copy link
Member

bizley commented Jan 7, 2021

What DB engine are you using here?

@freddyw
Copy link
Author

freddyw commented Jan 7, 2021

Good question, apologies for not stating that:

sfedosimov/yii2-oci8pdo v1.0.0.0 Emulation of the PDO driver by means of OCI8

@bizley
Copy link
Member

bizley commented Jan 7, 2021

I cannot say this for 100% sure but this might be because of that package. I can see that https://github.com/sfedosimov/yii2-oci8pdo/blob/master/Oci8PDO.php constructor's is not calling parent's constructor. @sfedosimov might be better than me to judge that

@freddyw
Copy link
Author

freddyw commented Jan 7, 2021

But why does this happen only after updating yii to version 2.0.40? Up to now it has been working flawless.

@bizley
Copy link
Member

bizley commented Jan 7, 2021

Fix in #18406 revealed it.

@freddyw
Copy link
Author

freddyw commented Jan 7, 2021

So as long as I am using an oracle database I am stuck at version 2.0.39.3. Since sfedosimov/yii2-oci8pdo does not seem to be actively maintained. I inherited this project but sticking with 2.0.39.3 seems a lot less work than switching databases or database connectors. I just don't understand why the 'regular' database transactions work, just not when used in conjunction with kartik\editable\Editable. Maybe at some point I can figure out a way around this, for now I will simply not upgrade.

@freddyw
Copy link
Author

freddyw commented Jan 7, 2021

Thanks for the quick responses by the way, it is greatly appreciated.

@bizley
Copy link
Member

bizley commented Jan 7, 2021

Cheers.

My guess would be that there is multilevel transaction involved here. Please check if this is the case as well when not using Editable.

@freddyw
Copy link
Author

freddyw commented Jan 8, 2021

Right. Did some more digging, added a ton of debugging stuff and you know what? The Oci8PDO.php does have a function isTransaction, but not an inTransaction (I probably missed this one letter difference a couple of 100 times during debugging). So, adding the inTransaction funtion (returning $this->_isTransaction) works wonders. Everything seems to work fine with this added function. Does that make any sense?

@freddyw
Copy link
Author

freddyw commented Jan 8, 2021

Apparently I am not the only one who figured this out:
sfedosimov/yii2-oci8pdo#5

@bizley
Copy link
Member

bizley commented Jan 8, 2021

Hmm, yes. Without this it tries to use parent's method and this probably causes the problem. Thanks for all the digging. I'm closing this since it's the 3rd party package that must be fixed.

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

No branches or pull requests

3 participants