• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
CI 2.0 transaction testmode bug

#1
[eluser]diostm[/eluser]
Hello!

I don't now, is it bug or not, but anyway, I decide to report it:
When I execute code:

Code:
<?php

        $this->db->trans_start(TRUE); // Query will be rolled back
        $this->db->query("INSERT INTO menus VALUES(NULL,'Yahoo!','http://yahoo.com',NULL)");
#        $this->db->query("INSERT INTO menus VALUES(NULL,NULL,NULL,NULL)");//this string is commented out
        $this->db->trans_complete();

?>

Query have to be rolled back automatically, when I pass TRUE, but it don't

I watch several time the sources of CodeIgniter and find out, that in file system/database/drivers/mysql/mysql_driver.php
Line #216 of mysql_driver.php, contains
Code:
$this->_trans_failure = ($test_mode === TRUE) ? TRUE : FALSE;

I replaced it with a line:
Code:
$this->_trans_status = ($test_mode === FALSE) ? $this->_trans_status : FALSE;

Now all seems to be OK.

I hope you'll find this information useful.

#2
[eluser]WanWizard[/eluser]
That is not the issue.

In the drivers, $this->_trans_failure is used to force a failure of the transaction, and therefore a rollback. This rollback is performed in DB_driver.php:
Code:
// The query() function will set this flag to FALSE in the event that a query failed
if ($this->_trans_status === FALSE)
{
    $this->trans_rollback();

    // If we are NOT running in strict mode, we will reset
    // the _trans_status flag so that subsequent groups of transactions
    // will be permitted.
    if ($this->trans_strict === FALSE)
    {
        $this->_trans_status = TRUE;
    }

    log_message('debug', 'DB Transaction Failure');
    return FALSE;
}

This should be:

Code:
// The query() function will set this flag to FALSE in the event that a query failed
// Also do a rollback if the transaction failure flag was set
if ($this->_trans_status === FALSE  OR $this->_trans_failure === TRUE)


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.