php - Joomla 3.X - Transactions split between functions -


i have problem (once every 1-3 months) transaction gets run twice, , result, data gets entered db twice.

here's gist of goes on:

function foo() {    $arr = getsomearray();    $db = jfactory::getdbo();     try    {       bar($arr);    }    catch(exception $e)    {       $db->transactionrollback();    } }  function bar($arr) {    $db = jfactory::getdbo();     $db->transactionstart();     // series of inserts , updates    // if fail, throw exception     $db->transactioncommit();    return true; } 

here, $arr in foo() should contain unique values. code prevents duplicate entries being inserted db checking if particular entry exists.

to test base checks work, i've mocked $arr contain 2 values same. receive exception expected.

however, i'm still getting double entries in db , i'm stumped how it's possible. time stamps suggest single transaction gets duplicated , both run in parallel. haven't been able find on particular issue, because it's not supposed happen.

i have seen examples regarding transactions in joomla/php use transactionstart, transactioncommit, , transactionrollback in single function, code i've inherited has split them across 2 different functions. cause problems transactions, such running twice?


Comments

Popular posts from this blog

ruby - Trying to change last to "x"s to 23 -

jquery - Clone last and append item to closest class -

c - Unrecognised emulation mode: elf_i386 on MinGW32 -