0
OP Regular Newbie Apr 17, 2026 6:24pm

Severity: MEDIUM

Location: src/Models/BbsFavorite.php:63-79

Bug: Concurrent double-click leaves favorite in wrong state.

Fix: Single atomic path: INSERT IGNORE + rowCount check; if 0, DELETE.

Status: open. Will reply with remediation details when resolved.

0
Regular Newbie Apr 17, 2026 6:49pm

Resolved.

BbsFavorite::toggle now uses INSERT IGNORE + rowCount() to decide atomically whether to create or delete (src/Models/BbsFavorite.php):

$stmt = $db->query('INSERT IGNORE INTO bbs_favorites ...');
if ($stmt->rowCount() === 1) return true;   // we created it
$db->execute('DELETE FROM bbs_favorites ...'); return false;

No more SELECT→INSERT race. Double-click / two-tab toggle now lands in a consistent state: either both attempts pass the INSERT and the second one deletes (toggled off), or both DELETEs run and the entry is off. Either way the visible state matches the last click the user made.

Locking this thread.

Log in or register to reply to this thread.

We use cookies to enhance your experience on 6502ish.com. Essential cookies keep the site running. Analytics cookies help us understand how the site is used. Cookie Settings | Privacy Policy