php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #80871 PDO::inTransactional() always return false (Yii2)
Submitted: 2021-03-16 08:39 UTC Modified: 2021-04-19 13:55 UTC
Votes:7
Avg. Score:5.0 ± 0.0
Reproduced:7 of 7 (100.0%)
Same Version:7 (100.0%)
Same OS:6 (85.7%)
From: sevak754 at gmail dot com Assigned:
Status: Closed Package: PDO DBlib
PHP Version: 8.0.3 OS: Linux
Private report: No CVE-ID: None
 [2021-03-16 08:39 UTC] sevak754 at gmail dot com
Description:
------------
I've tried to begin transaction with Yii2, but it didn't commit. It happened because here yiisoft/yii2/db/Transaction.php:168 is PDO::inTransactional() check and he always return false. This problem appeared after update to php 8.
I use MSSQL and I think there is a problem with driver.

Test script:
---------------
if ($this->_level === 0) {
            Yii::debug('Commit transaction', __METHOD__);
            // make sure the transaction wasn't autocommitted
            if ($this->db->pdo->inTransaction()) { // always false
                $this->db->pdo->commit();
            }
            $this->db->trigger(Connection::EVENT_COMMIT_TRANSACTION);
            return;
        }


Expected result:
----------------
Transaction has been commited

Actual result:
--------------
Transaction has been rollbacked

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2021-03-16 08:46 UTC] nikic@php.net
When you say you use MSSQL, does that mean you use the PDO DBLIB driver?
 [2021-03-17 06:58 UTC] sevak754 at gmail dot com
Yes, DBLIB version 7.2
 [2021-03-18 23:30 UTC] cmb@php.net
-Package: PDO related +Package: PDO DBlib
 [2021-04-13 13:58 UTC] menschov dot evgeny at yandex dot ru
Are there any chances of fixing this problem?
 [2021-04-13 14:19 UTC] nikic@php.net
PDO DBlib uses PDOs transaction state emulation. I looked through the code, but didn't spot any obvious issues. I can't test this driver myself.
 [2021-04-19 13:55 UTC] sevak754 at gmail dot com
-Status: Open +Status: Closed
 [2021-04-19 13:55 UTC] sevak754 at gmail dot com
This bug appeared after this bugfix: https://github.com/yiisoft/yii2/pull/18481 , cause I'd driverName => 'mssql' instead of 'dblib'. When I changed this property to 'dblib', transactions started to work correctly
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 08:01:28 2024 UTC