You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit cd65fca
Browse filesBrowse the repository at this point in the historyBrowse files
chore(cleanup): drop dead PHP fields rendering unreferenced JS calls (#1404) (#1407)
* chore(cleanup): drop dead v1.x PHP fields + ReferenceError-throwing script blobs (#1404)
Five page handlers built server-side data fields (or `<script>`
blobs) containing dead JS function calls that survived the v2.0
`sourcebans.js` deletion (#1123 D1). Two cleanup shapes:
Shape 1 — inert dead fields (no template consumed them):
* `page.banlist.php:858-862` — drop `$data['friend_ban_link']` /
`$data['unban_link']` / `$data['delete_link']` (v1.x
`CreateLinkR`-built `BanFriendsProcess` / `UnbanBan` /
`RemoveBan` `<a onclick=…>` blobs). Modern unban / delete
affordances ride `.row-actions` with `data-action="bans-unban"`
/ `data-action="bans-delete"` in `page_bans.tpl`.
* `page.commslist.php:679-688` — drop `$data['unban_link']`
(UnGag / UnMute switch arms) + `$data['delete_link']`
(RemoveBlock blob). Same story, mirror affordances in
`page_comms.tpl`.
* `page.home.php:73` — drop `$info['popup']` (`ShowBox(...)`
blob the dashboard never echoed). The dashboard reads
`short_name` / `search_link` / `bid` / `sname` / `blocked_human`
instead; the no-nickname placeholder string that fed the popup
goes with it.
Shape 2 — live dead `<script>` blobs that raised ReferenceErrors:
* `admin.admins.php:132-140` — drop the `$serverscript` blob that
emitted `LoadServerHost('SID', 'id', 'saSID');` per server
(every Add Admin page load raised `ReferenceError:
LoadServerHost is not defined` once per configured server with
no visible effect — the `sa<SID>` span already renders bare
`IP:port` from `$server_list`). Paired drops:
- `AdminAdminsAddView.php`: remove the orphan `server_script`
readonly property (SmartyTemplateRule would fail otherwise).
- `page_admin_admins_add.tpl:224`: drop the
`{$server_script nofilter}` echo.
* `admin.groups.php:166-168` — drop the per-row
`<script>LoadServerHostPlayersList('<sids>', 'id',
'servers_<gid>')</script>` echo (every page load raised
`ReferenceError: LoadServerHostPlayersList is not defined` once
per server group). The `:prefix_servers_groups` lookup that fed
the SID list goes too (nothing else reads it). Paired drops:
- `page_admin_groups_list.tpl:341-343`: drop the literal
"Servers populate via the legacy `LoadServerHostPlayersList`
hook." placeholder copy (admin-facing forever pre-fix) +
the sibling `<div id="servers_{gid}">` hydration slot.
The two hydration features (Add Admin's Server-access multi-select;
Server-Groups card's per-group server list) are filed as separate
follow-up feature tickets per the issue body's recommendation —
mixing cleanup with new feature wiring would inflate the PR review
surface.
Regression guard: `web/tests/integration/DeadJsCallSitesTest.php`
(three methods, 12 assertions). The per-file forbidden-substring
list is scanned against the **comment-stripped** source of each
page handler — `php_strip_whitespace()` drops the explanatory
`// #1404 — ...` markers so they don't false-fire the gate.
Sibling cross-checks pin the template halves (`{$server_script}`
echo, hydration slot, placeholder copy) and the View DTO
(`AdminAdminsAddView::server_script`). A future "convenient"
reintroduction (a fork pasting back the v1.x row-action shape) is
caught at PR time rather than landing as another silent
`ReferenceError` flood. Ties the existing AGENTS.md "Anti-patterns"
entries (legacy 1.4.11 JS handler names, sourcebans.js bulk file)
to the code.
No user-visible behavior change. Sister #1402 / #1403 cover the
JS-handler wiring rewrites (RemoveAdmin trash-icon, the
`ShowBox(...)` toast emission); those scopes deliberately stay out
of this PR.
* chore(cleanup): drop defensive $info reset + cite #1404 in AGENTS.md (#1404 review)
Adversarial-review feedback follow-ups on the #1404 cleanup. No behaviour
change — pure deletion + docs.
- web/pages/admin.admins.php: drop the per-iteration `$info = []` reset
inside the `foreach ($servers as $server)` loop. Pre-review self-report
flagged this as a "latent state-leak fix"; the reviewer verified under
`E_ALL` that the loop assigns every key (`sid` / `ip` / `port`) on
every iteration AND `array_push($server_list, $info)` is value-copy for
PHP arrays, so prior-iteration values are fully overwritten before the
next push. The reset added zero observable behaviour change and muddied
what should be a pure-deletion PR.
- AGENTS.md: amend the `web/scripts/sourcebans.js` anti-pattern entry
(lines 2136-2156 after the edit) to cite both #1404 surfaces (the
trailing per-row `<script>LoadServerHost('SID', …)</script>` echo on
the Add Admin form AND the per-group
`<script>LoadServerHostPlayersList('<sids>', …)</script>` echo on the
Server Groups list), name the regression guard (`DeadJsCallSitesTest`),
and forward-reference the two hydration follow-ups (#1405 + #1406).
Add a sister row to the "Where to find what" regression-guard cluster
(next to `Php82DeprecationsTest` and `SrvAdminsPdoParamTest`) so an
archaeologist searching for "what test stops dead JS call sites from
coming back" finds it on the first index lookup. Mandated by the
"Keep the docs in sync" table's "Remove a legacy pattern" row.
No source code changed beyond the one-line `$info` reset removal; every
quality gate stays green (PHPStan 240 files / 0 errors, PHPUnit 680 tests
/ 2710 assertions, ts-check clean, API contract no-diff, Playwright E2E
at CI=1 = 267 passed / 279 skipped / 0 failed).
| Trap PHP 8.1 null-into-scalar deprecations at runtime (the bits PHPStan can't see) | `web/tests/integration/Php82DeprecationsTest.php` (#1273) — process-isolated render harness with a stub Smarty + `set_error_handler` that promotes `E_DEPRECATED` / `E_USER_DEPRECATED` to `\ErrorException`. Mirrors the LostPasswordChromeTest stub-Smarty pattern; each test method runs in a separate process because the page handlers declare top-level helpers (`setPostKey()` etc.) that PHP can't redeclare in one process. Add a marquee route here whenever a new high-traffic page handler ships, especially if it reads nullable `:prefix_*` columns or `$_POST` / `$_GET` lookups. |
2827
2842
| Pin the "every `:name` PDO placeholder needs as many `bind()` calls as occurrences" contract under native prepares | `web/tests/integration/SrvAdminsPdoParamTest.php` (#1314) — two methods. `testReusedNamedPlaceholderUnderNativePreparesIsRejected` issues a tiny `SELECT 1 ... WHERE aid = :sid OR aid = :sid` against `Sbpp\Db\Database` with one `bind()` and asserts it throws `HY093`; this is the contract pin (also a regression guard if anyone re-flips `EMULATE_PREPARES` back to `true`). `testAdminSrvadminsPageRendersWithoutPdoException` is the page-level regression guard for the actual #1314 fatal — process-isolated `require` of `pages/admin.srvadmins.php` with `?id=0` asserting no `PDOException` escapes. Mirrors the Php82DeprecationsTest stub-Smarty + process-isolation shape. |
2843
+
| Pin "dead v1.x JS call sites + their server-side feeders stay deleted" (the `<script>LoadServerHost(...)</script>` / `$data['unban_link']` / `$info['popup']` shapes the v2.0.0 `sourcebans.js` cutover left without a JS landing site) | `web/tests/integration/DeadJsCallSitesTest.php` (#1404) — three methods, 12 assertions. Per-file forbidden-substring map (`page.banlist.php` / `page.commslist.php` / `page.home.php` / `admin.admins.php` / `admin.groups.php`) scanned against the **comment-stripped** source of each handler via `php_strip_whitespace()`, so the cleanup's own `// #1404 — ...` explanatory comments (and pre-existing historical-context comments that name the dead helpers in passing) don't false-fire the gate. The Smarty half (`{$server_script nofilter}`, the `<div id="servers_{$group.gid}">` hydration slot, the "Servers populate via the legacy LoadServerHostPlayersList hook." placeholder copy) is pinned by `testDeadTemplateSidesStayDropped` (also comment-stripped via `{* *}`-regex). The View-DTO side (`Sbpp\View\AdminAdminsAddView::server_script` orphan property) is pinned independently by `testAdminAdminsAddViewDoesNotCarryServerScriptProperty` so the failure points at the View directly instead of cascading through SmartyTemplateRule. Pure file scanning — extends `PHPUnit\Framework\TestCase` (no DB / session / Smarty bring-up). Sister #1402 (rewire dead JS handlers) and #1403 (ShowBox→`window.SBPP.showToast` rewrite) extend the per-file forbidden-substring map as their PRs land. |
2828
2844
| Add an E2E spec | `web/tests/e2e/specs/<smoke|flows|a11y|responsive>/...` + `web/tests/e2e/pages/...` |
2829
2845
| Add a route to the screenshot gallery | `web/tests/e2e/specs/_screenshots.spec.ts` (`ROUTES` array) |
2830
2846
| Tweak mobile (<=768px) chrome layout | `web/themes/default/css/theme.css` — see the `#1207` `@media (max-width: 768px)` blocks for the canonical shapes (icon-only topbar search, full-width drawer + scroll lock). Sub-paged admin routes (servers / mods / groups / comms / settings / admins / bans) use the `<details open>` accordion in the `#1259` `@media (min-width: 1024px)` block (sidebar inline at `<1024px`, sticky 14rem rail at `>=1024px`); see "Sub-paged admin routes" in Conventions. |
0 commit comments