From 0b8243ab699bb73151124cc5db0d84e0999b7255 Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Tue, 6 Aug 2013 09:24:01 +0200 Subject: [PATCH 1/2] Fixing archiving of PPS, TXFees and Debits Emergency fix. Includes balance PPS calculation fix. Addresses #563 --- public/include/classes/transaction.class.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/public/include/classes/transaction.class.php b/public/include/classes/transaction.class.php index b8716ae4..58646a4e 100644 --- a/public/include/classes/transaction.class.php +++ b/public/include/classes/transaction.class.php @@ -37,12 +37,14 @@ class Transaction extends Base { public function setArchived($account_id, $txid) { $stmt = $this->mysqli->prepare(" UPDATE $this->table AS t - INNER JOIN " . $this->block->getTableName() . " AS b + LEFT JOIN " . $this->block->getTableName() . " AS b ON b.id = t.block_id SET t.archived = 1 - WHERE t.account_id = ? AND t.id <= ? AND b.confirmations >= ?"); - if ($this->checkStmt($stmt) && $stmt->bind_param('iii', $account_id, $txid, $this->config['confirmations']) && $stmt->execute()) + WHERE ( t.account_id = ? AND t.id <= ? AND b.confirmations >= ? ) + OR ( t.account_id = ? AND t.id <= ? AND t.type IN ( 'Credit_PPS', 'Donation_PPS', 'Fee_PPS', 'TXFee', 'Debit_MP', 'Debit_AP' ) )"); + if ($this->checkStmt($stmt) && $stmt->bind_param('iiiii', $account_id, $txid, $this->config['confirmations'], $account_id, $txid) && $stmt->execute()) return true; + echo 'Fail: ' . $this->mysqli->error; return false; } @@ -221,7 +223,7 @@ class Transaction extends Base { $stmt = $this->mysqli->prepare(" SELECT ROUND(( - SUM( IF( ( t.type IN ('Credit','Bonus') OR t.type = 'Credit_PPS') AND b.confirmations >= ?, t.amount, 0 ) ) - + SUM( IF( ( t.type IN ('Credit','Bonus') AND b.confirmations >= ? ) OR t.type = 'Credit_PPS', t.amount, 0 ) ) - SUM( IF( t.type IN ('Debit_MP', 'Debit_AP'), t.amount, 0 ) ) - SUM( IF( ( t.type IN ('Donation','Fee') AND b.confirmations >= ? ) OR ( t.type IN ('Donation_PPS', 'Fee_PPS', 'TXFee') ), t.amount, 0 ) ) ), 8) AS confirmed, From d4a9af86c4289ee2b3fa468cd1cf88033b990be8 Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Tue, 6 Aug 2013 09:26:43 +0200 Subject: [PATCH 2/2] removed debug output --- public/include/classes/transaction.class.php | 1 - 1 file changed, 1 deletion(-) diff --git a/public/include/classes/transaction.class.php b/public/include/classes/transaction.class.php index 58646a4e..6da0ee49 100644 --- a/public/include/classes/transaction.class.php +++ b/public/include/classes/transaction.class.php @@ -44,7 +44,6 @@ class Transaction extends Base { OR ( t.account_id = ? AND t.id <= ? AND t.type IN ( 'Credit_PPS', 'Donation_PPS', 'Fee_PPS', 'TXFee', 'Debit_MP', 'Debit_AP' ) )"); if ($this->checkStmt($stmt) && $stmt->bind_param('iiiii', $account_id, $txid, $this->config['confirmations'], $account_id, $txid) && $stmt->execute()) return true; - echo 'Fail: ' . $this->mysqli->error; return false; }