[REVERT] Do not use TX ID boundaries for archiving
This commit is contained in:
parent
44f4b466a4
commit
7a2e6061ab
@ -34,21 +34,15 @@ class Transaction extends Base {
|
|||||||
* @param bool boolean True or False
|
* @param bool boolean True or False
|
||||||
**/
|
**/
|
||||||
public function setArchived($account_id, $txid) {
|
public function setArchived($account_id, $txid) {
|
||||||
// Fetch last archived transaction for user, we must exclude our Debits though! There might be unarchived/archived
|
// Update all paid out transactions as 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
|
|
||||||
$stmt = $this->mysqli->prepare("
|
$stmt = $this->mysqli->prepare("
|
||||||
UPDATE $this->table AS t
|
UPDATE $this->table AS t
|
||||||
LEFT JOIN " . $this->block->getTableName() . " AS b
|
LEFT JOIN " . $this->block->getTableName() . " AS b
|
||||||
ON b.id = t.block_id
|
ON b.id = t.block_id
|
||||||
SET archived = 1
|
SET t.archived = 1
|
||||||
WHERE t.archived = 0 AND t.account_id = ? AND t.id <= ? AND t.id > ? AND (b.confirmations >= ? OR b.confirmations IS NULL)
|
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('iiii', $account_id, $txid, $last_id, $this->config['confirmations']) && $stmt->execute())
|
if ($this->checkStmt($stmt) && $stmt->bind_param('iiiii', $account_id, $txid, $this->config['confirmations'], $account_id, $txid) && $stmt->execute())
|
||||||
return true;
|
return true;
|
||||||
return $this->sqlError();
|
return $this->sqlError();
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user