Skip to content

Bugfix Issue 2130 Authored Maintainability Chapter

sebiboga edited this page Nov 29, 2026 · 1 revision

Bugfix — Issue #2130: authored Maintainability & Portability chapter text

Symptom

Chapter 28 (Non-Functional: Maintainability / Maintainability & Portability) was a read-only reference page. On a freshly imported 2.0.1 database with project 1 (Strategy Fixture 2130, prefix SF2130) the editor gui/templates/strategy/nfrMaintainability.html?tproject_id=1 returned HTTP 200 but the DOM contained 0 textareas and 0 buttons, no BFF request was made, and GET /api/strategyreport/index.php?action=init&tproject_id=1 had no chapter-text key. There was no way to author project-specific text, and therefore nothing for the Test Strategy report to aggregate or print.

Root cause

The chapter pages are static Dashio HTML fragments (issue #1052/#1462 family) and were never given a persistence path, unlike the nine sections of the authored strategy document (api/strategydoc/index.php, issue #1943/#2101):

  • gui/templates/strategy/nfrMaintainability.html:40-57 held only static content; the chapter list in gui/templates/i18n/en.json had no editor labels/messages.
  • api/strategydoc/index.php:87-91 wrote the JSON blob for the document sections only; it has no chapter-code dimension and could not represent chapter 28.
  • api/strategyreport/index.php assembled context, scope, types, levels, environments, tooling, team, related, signals, authored but never read a chapter table.
  • gui/templates/results/strategyReport.html had ten numbered panels plus a project context header (the last panel being authored document sections) and no place for chapter notes.
  • lib/functions/object.class.php:306 allowlisted only testproject_strategy_docs, so a new lazy table would fail with Wrong table name(s) for getDBTables() detected! (object.class.php:344) until explicitly registered.

Approach chosen

  1. One small project-scoped table and one BFF, reused by both screens. A new api/strategychapter/index.php exposes GET action=init&tproject_id=N&chapter=maintainability, GET action=list&tproject_id=N and POST action=save. It reuses the repo's session auth, bffSameOriginGuard(), the project rights matrix and the lazy-create-table pattern already used by api/strategydoc/index.php. testproject_strategy_chapters has UNIQUE KEY (testproject_id, chapter_code), so the save path is a single INSERT ... ON DUPLICATE KEY UPDATE upsert; text is capped at 20 000 characters and round-tripped as UTF-8 with newlines preserved. Every write emits an

    AUDIT event. The table was added both to the installer DDL and to the getDBTables() allowlist. A JSON exception handler keeps DB failures contract-safe, and the verb gate runs before rights/schema work so unsupported methods always get 405 with Allow: GET, POST.

  2. Editor in the existing Dashio page, not a new screen. The chapter page now has a labeled #maintText textarea, #btnSave, last-author metadata and status text. Loading, saving and permission states all come from the BFF; a read-only user gets disabled controls and a localized explanatory message instead of an error toast. The project id comes from the signed-in session/project context, and the back link keeps tproject_id. All 15 new labels/messages live in TLi18n bundles in all ten client locales — no hardcoded user-facing text.

  3. Additive report aggregation. api/strategyreport/index.php returns a new chapters[] array (code, text, author, updated) under the existing document read right, with a SHOW TABLES LIKE probe so an older DB without the new table contributes [] instead of failing. The report renders panel 11, Authored chapter notes, escapes all dynamic text and appends the same section to buildMarkdown(). The already present Export PDF button (window.print()) prints it without a new server dependency. Nothing in the existing authored[] payload or the nine document sections changed, so #2101 consumers are unaffected.

Alternatives rejected

  • Extending testproject_strategy_docs with a fake document would have leaked chapter text into the authored document list and changed the #2101 payload shape.
  • Reusing the report's computed scope/signals fields would have made authored prose indistinguishable from generated values and broken project isolation.
  • A server-side PDF library was unnecessary: the existing print path already produces PDF and now includes panel 11 automatically.
  • Turning all 18 strategy chapter pages into editors would be an architecture-sized change; this issue names chapter 28 specifically, so the fix is scoped to it while leaving the table/API prepared for additional chapter_code values.

Files changed

  • api/strategychapter/index.php — new chapter BFF (init/list/save, rights, audit, upsert).
  • lib/functions/object.class.php — allowlisted testproject_strategy_chapters.
  • install/sql/mysql/testlink_create_tables.sql — new table DDL for fresh installs.
  • gui/templates/strategy/nfrMaintainability.html — editor UI + BFF wiring.
  • api/strategyreport/index.php — additive chapters[] payload.
  • gui/templates/results/strategyReport.html — panel 11 + Markdown/print surface.
  • gui/templates/i18n/{de,en,es,fr,it,ja,pt,ro,ru,zh}.json — 15 new keys, real translations in every locale.
  • tmp/TLU_Test_Cases.md — regression suite Regression — Issue #2130.
  • CHANGELOG — [KEY BUGFIX] - #2130 entry.

Verification

  • Repro before: 0 textareas, 0 buttons, no BFF call; report had no chapter text.
  • After: editor Save changed metadata 10:14:58 → 10:16:16; UTF-8/newline text round-tripped through a second atomic upsert (10:24:31) and reloaded into the textarea. Report API returned chapters[] and the rendered panel 11 showed the same text, author and timestamp; Markdown export contained ## 11. Authored chapter notes.
  • Project isolation: project 2 (SO2130) returned "" and chapters: []; one DB row only for project 1.
  • Permissions: ro2130 (global role <no rights>) saw disabled textarea and Save with the localized explanation; its POST returned 403 no_right and the DB row did not change. Anonymous GET → 401, anonymous POST → 403 via the shared same-origin guard. Unknown chapter → 400, unknown project → 404, DELETE → 405 with Allow: GET, POST.
  • Gates: php -l clean for both touched PHP files; extracted report JS node --check clean; all ten bundles valid JSON; bash ai/verify_i18n_coverage.sh 9/9 PASS; suite gate TLU_REQUIRE_SUITE="Issue #2130" bash ai/verify_test_suites.sh → 34 PASS / 0 FAIL / 0 SKIP.
  • Console: no new Error/Warning entries; Event Viewer: 4 rows, all log_level=16 (LOGIN/CREATE/STRATEGY_CHAPTER_SAVE), 0 Error and 0 Warning.
  • Review: subagent review found and fixes were applied for JSON error handling, verb gate order/header accuracy, atomic upsert, unused i18n keys and untranslated values; re-review verdict APPROVE with no new regression.

Screenshots

Authored text in the chapter editor (project 1, admin):

Maintainability & Portability editor with authored text

The same text in Test Strategy Report panel 11:

Authored chapter notes in the Test Strategy Report

Clone this wiki locally