summaryrefslogtreecommitdiff
path: root/CLAUDE.md
blob: 97b13934b15fc669e898530e3b1ca6be9dcddd3f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# Wiki Package — Developer Notes

## BitPage::store() — missing RollbackTrans
`BitPage::store()` (line 220) wraps the entire save in `StartTrans()` / `CompleteTrans()`
but has no `RollbackTrans()` fallback. If an exception escapes — e.g. from the nested
`LibertyMime::store()` call at line 222, which has its own `StartTrans()` — `CompleteTrans()`
never runs and Firebird is left with an open transaction holding locks on `wiki_pages`
and/or `liberty_content` rows.

Symptom: wiki pages return "page not found" until Firebird is restarted. The failed save
appears to cause no visible error, but the stuck transaction blocks subsequent access to
the affected rows.

**Diagnostic** — run in isql when stuck:
```sql
SELECT t.MON$TRANSACTION_ID, t.MON$TIMESTAMP,
       s.MON$SQL_TEXT, s.MON$STATE
FROM MON$TRANSACTIONS t
LEFT JOIN MON$STATEMENTS s ON s.MON$TRANSACTION_ID = t.MON$TRANSACTION_ID
WHERE t.MON$STATE = 1;
```

**Fix** — wrap the body of `store()` in a try/catch with `RollbackTrans()`:
```php
$this->StartTrans();
try {
    // ... existing body ...
    $this->CompleteTrans();
} catch( \Exception $e ) {
    $this->mDb->RollbackTrans();
    $this->mErrors['store'] = $e->getMessage();
}
```

Do not action until confirmed via `MON$TRANSACTIONS` — use xdebug or the monitoring
query above to verify this is the actual call stack before patching.