Files
openproject/lib
Kabiru Mwenja 3cbe554414 Use formatted_id and displayId for #N text macros
In semantic mode, plain `#N` references inside formatted text rendered
`<a href="/work_packages/N">#N</a>`. The link should carry the
human-readable identifier on both the label and the href, matching how
the `##N` quickinfo macro already renders via Angular.

Two pieces:

1. `PatternMatcherFilter` gains an opt-in pre/cleanup hook around the
   per-node loop. Matchers that own per-render lookup caches (e.g. a
   batched WP load) implement `preload_for_doc` and `cleanup_after_doc`
   to populate and drop them.

2. `ResourceLinksMatcher` implements those hooks: it scans every text
   node for `#N` matches, runs a single batched `WorkPackage.where(id:
   ids)`, and exposes the result via a thread-isolated class attribute.
   The `WorkPackages` link handler reads from it to choose
   `wp.formatted_id` for the label and `wp.display_id` for the href.
   Falls back to the legacy `#N` shape when the WP isn't loadable
   (deleted, out of scope, or no preload ran).

Visibility filtering is intentionally not introduced — the matcher
links regardless of viewer permissions on the referenced WP, preserving
pre-existing behaviour. Out of scope for this ticket.

Refs https://community.openproject.org/work_packages/74315
2026-05-15 08:24:12 +03:00
..