From 7a2e6061ab33424e624db7bff802b707ca86bb8b Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Mon, 2 Dec 2013 16:46:42 +0100 Subject: [PATCH] [REVERT] Do not use TX ID boundaries for archiving --- public/include/classes/transaction.class.php | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/public/include/classes/transaction.class.php b/public/include/classes/transaction.class.php index ecf93357..dd566489 100644 --- a/public/include/classes/transaction.class.php +++ b/public/include/classes/transaction.class.php @@ -34,21 +34,15 @@ class Transaction extends Base { * @param bool boolean True or False **/ public function setArchived($account_id, $txid) { - // Fetch last archived transaction for user, we must exclude our Debits though! There might be unarchived/archived - // records before our last payout - $stmt = $this->mysqli->prepare("SELECT IFNULL(MAX(id), 0) AS id FROM $this->table WHERE archived = 1 AND account_id = ? AND type NOT IN ('Debit_MP','Debit_AP','TXFee')"); - if ($this->checkStmt($stmt) && $stmt->bind_param('i', $account_id) && $stmt->execute() && $result = $stmt->get_result()) - $last_id = $result->fetch_object()->id; - $this->debug->append('Found last archived transaction: ' . $last_id); - // Update all transactions, mark as archived for user previous to $txid and higher than last archived transaction + // Update all paid out transactions as archived $stmt = $this->mysqli->prepare(" UPDATE $this->table AS t LEFT JOIN " . $this->block->getTableName() . " AS b ON b.id = t.block_id - SET archived = 1 - WHERE t.archived = 0 AND t.account_id = ? AND t.id <= ? AND t.id > ? AND (b.confirmations >= ? OR b.confirmations IS NULL) - "); - if ($this->checkStmt($stmt) && $stmt->bind_param('iiii', $account_id, $txid, $last_id, $this->config['confirmations']) && $stmt->execute()) + SET t.archived = 1 + 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; return $this->sqlError(); }