Problem/Motivation
potx holds its extraction state in 16 global arrays, shared by about 70 global functions in potx.inc and its include files. Every caller resets that state by hand: the tests reset $_potx_store, $_potx_strings and $_potx_install, and l10n_server unsets every $_potx_* global around each release it parses. Schema storage is configured through function names in $_potx_callbacks, reporting through a static mode of potx_status(), and the extract form prints the download and ends with exit.
Proposed resolution
- A
Potxservice starts anExtractionRun, which owns the state of one extraction: strings, diagnostics, config schema and YAML translation patterns. No global state is left behind. - One internal extractor service per file type: PHP, JavaScript, Twig, YAML and
.info. PHP extraction usestoken_get_all(), with a token stream per file and one recognizer class per construct. Twig templates are lexed with potx's own environment, independent of the site's extensions. - An
ApiVersionenum withDrupal5,Drupal6,Drupal7andModern(Drupal 8 and later) selects the recognizers. - Config schema and shipped configuration get their own classes; the six schema callbacks become a
SchemaStorageInterfacethat l10n_server can implement. - Value objects for strings, occurrences and diagnostics; callers present the diagnostics (Messenger, Drush, arrays).
- A template builder and writer produce one template. The form returns a streamed download, and services are injected into the form and the Drush command (Drush 13 or later).
- Removed as outdated: the CVS
$Id$versions (the header should list the paths of the source files only), the multiple and core builds, installer strings as a separate kind, and the fallbackt(). potx.incbecomes a compatibility layer over the services, deprecated for removal in 3.0.0.
Remaining tasks
Do it. First Remove the outdated output; in testDrupal5() to testDrupal7(), installer strings become ordinary strings. After that generated test templates should be byte-identical at every step.
LLM disclosure
LLM was used to create the high level plan and do implementation for this issue. With human review. Attached full plan.
| Comment | File | Size | Author |
|---|---|---|---|
| Potx3Architecture.pdf | 5.67 MB | gábor hojtsy |
Issue fork potx-3630359
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #4
gábor hojtsyComment #6
gábor hojtsy