Page MenuHomePhabricator

Investigate removing the duplicated task-type conversion logic between PHP and JS
Open, LowPublic

Description

The task-type conversion/filtering logic exists twice: in NewcomerTasksUserOptionsLookup (PHP) and TaskTypesAbFilter.js (JS). Parity is enforced only by doc comments ("This has to be equivalent to..."), and the implementations have already drifted: the JS side has the taskTypeOrFalse() guard, "unavailable" task-type filtering, and an empty-result fallback that the PHP side lacks. One such divergence caused an UBN (T431668). This is a recurring maintenance hazard: every change to the conversion logic must be made twice and reviewed for equivalence by hand.

The most promising direction is to compute the conversion map (or the fully converted task-type list) in PHP only and ship it to the client as a generated virtual packageFile (like TaskTypes.json), then delete the duplicated JS logic.

Open questions to resolve in the investigation:

  • whether the JS-only behaviours (unavailable-task-type filtering via wgGESuggestedEditsTaskTypes, empty-result fallback) depend on client-side state that is not available at packageFile generation time
  • how much of TaskTypesAbFilter.js can actually be removed.

Outcome of this task should be a decision plus follow-up implementation task(s).

Acceptance criteria

  • Investigation/PoC determines whether the conversion logic can be computed server-side only, and what the JS-only behaviours require
  • Follow-up implementation task(s) filed accordingly