Welcome Guest, Not a member yet? Register   Sign In
Off-by-one bug in nested transactions
#1

[eluser]Unknown[/eluser]
In DB_driver.php:

Code:
function trans_start($test_mode = FALSE)
{    
    if ( ! $this->trans_enabled)
    {
        return FALSE;
    }

    // When transactions are nested we only begin/commit/rollback the outermost ones
    if ($this->_trans_depth > 0)
    {
        $this->_trans_depth += 1;
        return;
    }
    
    $this->trans_begin($test_mode);
}

Since $this->_trans_depth is initialized to 0, it will never pass the > 0 test and be incremented. This means trans_begin() will always be called. It should be changed to:

Code:
$this->_trans_depth += 1;
if ($this->_trans_depth > 1)
{
    return;
}

Each of the *_driver.php files for the different databases need an edit to the trans_begin() function to change so the first transaction will be allowed to start.

From:
Code:
if ($this->_trans_depth > 0)
{
    return TRUE;
}
To:
Code:
if ($this->_trans_depth > 1)
{
    return TRUE;
}

I've attached a unified diff with these changes.

--EDIT--

There's a change in trans_complete() too, which I've put into the diff.
#2

[eluser]Unknown[/eluser]
This bug still exists in 2.0.2. Someone please get the attention of the developers to fix this. It is a clear bug with a clear solution.
#3

[eluser]InsiteFX[/eluser]
You need to submit an error report to the Reactor Team at:

Issues!

InsiteFX




Theme © iAndrew 2016 - Forum software by © MyBB