fix: #3326303 Correct the Ace library base path for JS aggregation
Fixes #3326303.
Ace resolves the mode, theme and worker files it loads on demand against the URL of its own script. That URL is not always the library directory - an aggregate, or an asset served from elsewhere - and those requests then 404. Since #3322712 the Ace builds are excluded from aggregation, which keeps the common case working; this makes the path explicit and guaranteed however the asset is delivered.
Changes
hook_js_settings_alter()publishes the library directory indrupalSettings.ace_editor.base_pathfor any page carrying an Ace library. Implemented as an object-oriented hook onAceEditorHookswith a#[LegacyHook]wrapper, following the module's hook pattern from #3594544.js/setup.jsapplies the published path toace.config(basePath, modePath, themePath, workerPath). Every integration's library depends onace_editor/setup.AceEditorLibraries::libUrl()builds the URL, carrying the site base path so a site served from a subdirectory stays correct.- The located library path is kept in the discovery cache (
cache.discovery, injected) instead of being rescanned: the lookup walks the candidate directories recursively and is now on the path of every page that renders an editor.
This reroll carries the original work by Klaas Van Waesberghe (the settings publication, the setup script, the caching idea and the FAQ entry) onto the current 2.0.x, where the hooks are object-oriented and the library logic lives in AceEditorLibraries. The pre-conversion ace_editor_lib_path() rewrite from the original diff is superseded by that service, so only its caching survives.
Verification
On Drupal 11.4.5 with JavaScript aggregation ON: drupalSettings.ace_editor.base_path published, all four ace.config paths set, mode-gherkin.js and worker-css.js resolve with HTTP 200, no console errors.
Local gate green: PHPUnit 64 tests / 203 assertions (new kernel coverage: hook registered with its legacy wrapper, pages without Ace untouched, all four integrations covered with a guard that fails when a new integration is not listed, path cached, URL carries the base path), phpcs (Drupal, DrupalPractice), cspell, PHPStan. PHPStan is approximated locally since the configuration comes from the drupalci templates, so that job gates on this pipeline.
Checkpoints:
- File an issue
- Addition/Change/Update/Fix
- Testing to ensure no regression
- Automated unit testing coverage
- Automated functional testing coverage
- UX/UI designer responsibilities
- Readability
- Accessibility
- Performance
- Security
- Developer Documentation
- User Guide Documentation
- Reviewed by human
- Code review by maintainers
- Full testing and approval
- Credit contributors
- Review with the product owner
- Release notes snippet
- Release
AI-Generated: Yes