Commit 8b4d899
補回 React 殼的 SQL 查詢明細並收斂收集成本,刪除使用者恢復兩段確認
- 舊版 Blade layout 底部的「本次查詢共 N 筆」+管理員明細 modal 在 React 遷移時漏移植,
而 DB::listen 仍無條件把每筆 SQL 與 bindings 累進記憶體——照樣收集卻沒人看得到。
- 權限分界對齊舊版:摘要行對所有人顯示(舊版該行無權限閘,含訪客),明細只給管理員。
故閘的是「保留明細」而非「整個收集」,flag 回退到 Blade 的頁面行為亦不變。
- 顯示端(HandleInertiaRequests)自己再檢查一次 isAdmin,不只依賴收集端閘門。
- shared prop 必須延後求值:inertia-laravel 在 $next() 之前呼叫 share(),直接求值只會
拿到 session/撈使用者那兩筆(實測 2 筆 vs 實際 6~7 筆);再包 Inertia::always 讓
局部重載也更新筆數,但刻意不夾帶明細(props 會進 window.history.state)。
- 前端沿用舊明細的條件由後端明說(details_omitted),非管理員永遠為 false,
避免登出/被降權後同一個 React 殼繼續顯示管理員的 SQL。
- QueryProfile 加明細上限(筆數與耗時另計、永遠精確)、先切再編碼,改為 scoped 綁定
且在回呼內解析;View::composer 由 '*' 收窄到 layouts.dashboard-v3。
- 閘門明確用 web guard(預設 guard 會被 OptionalAuthentication 改寫)、不做跨請求記憶、
例外只 report 第一次且 report 自身再包一層 try/catch。
- /app/manage/{id}/edit 刪除使用者恢復兩段確認(對齊舊版兩道 confirm),payload 不變。
測試:
- 新增 tests/Feature/QueryProfileGateTest.php(15 tests)
- 已執行 ./vendor/bin/phpunit(2493 tests 全綠)、npx vitest run(51 tests)
- 已執行 ./vendor/bin/php-cs-fixer fix 與 npm run build
- 另以 headless Chrome 對真實庫驗證 11 項(6 項查詢明細含非管理員 payload 無 SQL、
5 項兩段刪除含第一段繼續不刪除/第二段取消不刪除/兩段確認才刪除)
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>1 parent f106118 commit 8b4d899
11 files changed
Lines changed: 762 additions & 14 deletions
File tree
- app
- Http/Middleware
- Providers
- Services
- resources
- js/inertia
- Layouts
- Pages/Admin/Manage
- components/shell
- types
- lang
- en
- zh-TW
- tests/Feature
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
7 | 24 | | |
8 | 25 | | |
9 | 26 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
| |||
72 | 73 | | |
73 | 74 | | |
74 | 75 | | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
75 | 89 | | |
76 | 90 | | |
77 | 91 | | |
| |||
105 | 119 | | |
106 | 120 | | |
107 | 121 | | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
108 | 180 | | |
109 | 181 | | |
110 | 182 | | |
| |||
0 commit comments