Details
-
Type: Improvement
-
Status: Closed
-
Priority: Major
-
Resolution: Fixed
-
Affects Version/s: None
-
Fix Version/s: 5.5.0
-
Component/s: None
-
Labels:None
Description
Database transactions are not nestable (mostly) and thus should be avoided when possible. We can remove one from Transactions::applyFromCredits() by using Transactions::unapply()
Change app/models/transactions.php around line 875 from
// Begin a transaction $this->begin(); // Apply all credits foreach ($apply_amounts as $transaction_id => $trans_amounts) { $this->apply($transaction_id, ['amounts' => $trans_amounts]); if (($errors = $this->errors())) { // Roll back $this->rollBack(); return; } } // Commit transaction $this->commit();
To
// Apply all credits $last_transaction_id = null; $errors = null; foreach ($apply_amounts as $transaction_id => $trans_amounts) { $this->apply($transaction_id, ['amounts' => $trans_amounts]); if (($errors = $this->errors())) { break; } $last_transaction_id = $transaction_id; } if ($errors && $last_transaction_id) { foreach ($apply_amounts as $transaction_id => $trans_amounts) { $invoice_ids = array_map(function ($value) { return $value['invoice_id']; }, $trans_amounts); $this->unapply($transaction_id, $invoice_ids); if ($last_transaction_id == $transaction_id) { break; } } }
Activity
Jonathan Reissmueller
created issue -
Jonathan Reissmueller
made changes -
Field | Original Value | New Value |
---|---|---|
Rank | Ranked higher |
Jonathan Reissmueller
made changes -
Description |
Database transactions are not nestable in MinPHP and thus should be avoided when possible. We can remove one from Transactions::applyFromCredits() by using Transactions::unapply()
Change {code:java} // Begin a transaction $this->begin(); // Apply all credits foreach ($apply_amounts as $transaction_id => $trans_amounts) { $this->apply($transaction_id, ['amounts' => $trans_amounts]); if (($errors = $this->errors())) { // Roll back $this->rollBack(); return; } } // Commit transaction $this->commit(); {code} To {code:java} // Apply all credits $last_transaction_id = null; $errors = null; foreach ($apply_amounts as $transaction_id => $trans_amounts) { $this->apply($transaction_id, ['amounts' => $trans_amounts]); if (($errors = $this->errors())) { break; } $last_transaction_id = $transaction_id; } if ($errors && $last_transaction_id) { foreach ($apply_amounts as $transaction_id => $trans_amounts) { $invoice_ids = array_map(function ($value) { return $value['invoice_id']; }, $trans_amounts); $this->unapply($transaction_id, $invoice_ids); if ($last_transaction_id == $transaction_id) { break; } } } {code} |
Database transactions are not nestable in MinPHP and thus should be avoided when possible. We can remove one from Transactions::applyFromCredits() by using Transactions::unapply() Change app/models/transactions.php around line {code:java} // Begin a transaction $this->begin(); // Apply all credits foreach ($apply_amounts as $transaction_id => $trans_amounts) { $this->apply($transaction_id, ['amounts' => $trans_amounts]); if (($errors = $this->errors())) { // Roll back $this->rollBack(); return; } } // Commit transaction $this->commit(); {code} To {code:java} // Apply all credits $last_transaction_id = null; $errors = null; foreach ($apply_amounts as $transaction_id => $trans_amounts) { $this->apply($transaction_id, ['amounts' => $trans_amounts]); if (($errors = $this->errors())) { break; } $last_transaction_id = $transaction_id; } if ($errors && $last_transaction_id) { foreach ($apply_amounts as $transaction_id => $trans_amounts) { $invoice_ids = array_map(function ($value) { return $value['invoice_id']; }, $trans_amounts); $this->unapply($transaction_id, $invoice_ids); if ($last_transaction_id == $transaction_id) { break; } } } {code} |
Jonathan Reissmueller
made changes -
Description |
Database transactions are not nestable in MinPHP and thus should be avoided when possible. We can remove one from Transactions::applyFromCredits() by using Transactions::unapply() Change app/models/transactions.php around line {code:java} // Begin a transaction $this->begin(); // Apply all credits foreach ($apply_amounts as $transaction_id => $trans_amounts) { $this->apply($transaction_id, ['amounts' => $trans_amounts]); if (($errors = $this->errors())) { // Roll back $this->rollBack(); return; } } // Commit transaction $this->commit(); {code} To {code:java} // Apply all credits $last_transaction_id = null; $errors = null; foreach ($apply_amounts as $transaction_id => $trans_amounts) { $this->apply($transaction_id, ['amounts' => $trans_amounts]); if (($errors = $this->errors())) { break; } $last_transaction_id = $transaction_id; } if ($errors && $last_transaction_id) { foreach ($apply_amounts as $transaction_id => $trans_amounts) { $invoice_ids = array_map(function ($value) { return $value['invoice_id']; }, $trans_amounts); $this->unapply($transaction_id, $invoice_ids); if ($last_transaction_id == $transaction_id) { break; } } } {code} |
Database transactions are not nestable in MinPHP and thus should be avoided when possible. We can remove one from Transactions::applyFromCredits() by using Transactions::unapply() Change app/models/transactions.php around line 875 from {code:java} // Begin a transaction $this->begin(); // Apply all credits foreach ($apply_amounts as $transaction_id => $trans_amounts) { $this->apply($transaction_id, ['amounts' => $trans_amounts]); if (($errors = $this->errors())) { // Roll back $this->rollBack(); return; } } // Commit transaction $this->commit(); {code} To {code:java} // Apply all credits $last_transaction_id = null; $errors = null; foreach ($apply_amounts as $transaction_id => $trans_amounts) { $this->apply($transaction_id, ['amounts' => $trans_amounts]); if (($errors = $this->errors())) { break; } $last_transaction_id = $transaction_id; } if ($errors && $last_transaction_id) { foreach ($apply_amounts as $transaction_id => $trans_amounts) { $invoice_ids = array_map(function ($value) { return $value['invoice_id']; }, $trans_amounts); $this->unapply($transaction_id, $invoice_ids); if ($last_transaction_id == $transaction_id) { break; } } } {code} |
Jonathan Reissmueller
made changes -
Story Points | 2 |
Jonathan Reissmueller
made changes -
Sprint | 5.5.0-b2 Sprint 1 [ 163 ] |
Jonathan Reissmueller
made changes -
Rank | Ranked higher |
Jonathan Reissmueller
made changes -
Fix Version/s | 5.5.0-b2 [ 11733 ] | |
Fix Version/s | 5.6.0-b1 [ 11730 ] |
Jonathan Reissmueller
made changes -
Description |
Database transactions are not nestable in MinPHP and thus should be avoided when possible. We can remove one from Transactions::applyFromCredits() by using Transactions::unapply() Change app/models/transactions.php around line 875 from {code:java} // Begin a transaction $this->begin(); // Apply all credits foreach ($apply_amounts as $transaction_id => $trans_amounts) { $this->apply($transaction_id, ['amounts' => $trans_amounts]); if (($errors = $this->errors())) { // Roll back $this->rollBack(); return; } } // Commit transaction $this->commit(); {code} To {code:java} // Apply all credits $last_transaction_id = null; $errors = null; foreach ($apply_amounts as $transaction_id => $trans_amounts) { $this->apply($transaction_id, ['amounts' => $trans_amounts]); if (($errors = $this->errors())) { break; } $last_transaction_id = $transaction_id; } if ($errors && $last_transaction_id) { foreach ($apply_amounts as $transaction_id => $trans_amounts) { $invoice_ids = array_map(function ($value) { return $value['invoice_id']; }, $trans_amounts); $this->unapply($transaction_id, $invoice_ids); if ($last_transaction_id == $transaction_id) { break; } } } {code} |
Database transactions are not nestable and thus should be avoided when possible. We can remove one from Transactions::applyFromCredits() by using Transactions::unapply() Change app/models/transactions.php around line 875 from {code:java} // Begin a transaction $this->begin(); // Apply all credits foreach ($apply_amounts as $transaction_id => $trans_amounts) { $this->apply($transaction_id, ['amounts' => $trans_amounts]); if (($errors = $this->errors())) { // Roll back $this->rollBack(); return; } } // Commit transaction $this->commit(); {code} To {code:java} // Apply all credits $last_transaction_id = null; $errors = null; foreach ($apply_amounts as $transaction_id => $trans_amounts) { $this->apply($transaction_id, ['amounts' => $trans_amounts]); if (($errors = $this->errors())) { break; } $last_transaction_id = $transaction_id; } if ($errors && $last_transaction_id) { foreach ($apply_amounts as $transaction_id => $trans_amounts) { $invoice_ids = array_map(function ($value) { return $value['invoice_id']; }, $trans_amounts); $this->unapply($transaction_id, $invoice_ids); if ($last_transaction_id == $transaction_id) { break; } } } {code} |
Jonathan Reissmueller
made changes -
Description |
Database transactions are not nestable and thus should be avoided when possible. We can remove one from Transactions::applyFromCredits() by using Transactions::unapply() Change app/models/transactions.php around line 875 from {code:java} // Begin a transaction $this->begin(); // Apply all credits foreach ($apply_amounts as $transaction_id => $trans_amounts) { $this->apply($transaction_id, ['amounts' => $trans_amounts]); if (($errors = $this->errors())) { // Roll back $this->rollBack(); return; } } // Commit transaction $this->commit(); {code} To {code:java} // Apply all credits $last_transaction_id = null; $errors = null; foreach ($apply_amounts as $transaction_id => $trans_amounts) { $this->apply($transaction_id, ['amounts' => $trans_amounts]); if (($errors = $this->errors())) { break; } $last_transaction_id = $transaction_id; } if ($errors && $last_transaction_id) { foreach ($apply_amounts as $transaction_id => $trans_amounts) { $invoice_ids = array_map(function ($value) { return $value['invoice_id']; }, $trans_amounts); $this->unapply($transaction_id, $invoice_ids); if ($last_transaction_id == $transaction_id) { break; } } } {code} |
Database transactions are not nestable (mostly) and thus should be avoided when possible. We can remove one from Transactions::applyFromCredits() by using Transactions::unapply() Change app/models/transactions.php around line 875 from {code:java} // Begin a transaction $this->begin(); // Apply all credits foreach ($apply_amounts as $transaction_id => $trans_amounts) { $this->apply($transaction_id, ['amounts' => $trans_amounts]); if (($errors = $this->errors())) { // Roll back $this->rollBack(); return; } } // Commit transaction $this->commit(); {code} To {code:java} // Apply all credits $last_transaction_id = null; $errors = null; foreach ($apply_amounts as $transaction_id => $trans_amounts) { $this->apply($transaction_id, ['amounts' => $trans_amounts]); if (($errors = $this->errors())) { break; } $last_transaction_id = $transaction_id; } if ($errors && $last_transaction_id) { foreach ($apply_amounts as $transaction_id => $trans_amounts) { $invoice_ids = array_map(function ($value) { return $value['invoice_id']; }, $trans_amounts); $this->unapply($transaction_id, $invoice_ids); if ($last_transaction_id == $transaction_id) { break; } } } {code} |
Abdy Franco
made changes -
Assignee | Abdy Franco [ abdy ] |
Abdy Franco
made changes -
Status | Open [ 1 ] | In Progress [ 3 ] |
Jonathan Reissmueller
made changes -
Sprint | 5.5.0-b2 Sprint 1 [ 163 ] | 5.5.0 Sprint 1 [ 164 ] |
Jonathan Reissmueller
made changes -
Rank | Ranked higher |
Jonathan Reissmueller
made changes -
Fix Version/s | 5.5.0 [ 11734 ] | |
Fix Version/s | 5.5.0-b2 [ 11733 ] |
Abdy Franco
made changes -
Remaining Estimate | 0 minutes [ 0 ] | |
Time Spent | 58 minutes [ 3480 ] | |
Worklog Id | 15862 [ 15862 ] |
Abdy Franco
made changes -
Status | In Progress [ 3 ] | In Review [ 5 ] |
Resolution | Fixed [ 1 ] |
Jonathan Reissmueller
made changes -
Status | In Review [ 5 ] | Closed [ 6 ] |