Skip to content

COLDBOX-1474 elixirPath() returns the wrong path in three cases - #735

Open
homestar9 wants to merge 2 commits into
ColdBox:developmentfrom
homestar9:fix/elixir-path-cache-key
Open

homestar9 wants to merge 2 commits into
ColdBox:developmentfrom
homestar9:fix/elixir-path-cache-key

Conversation

@homestar9

Copy link
Copy Markdown
Contributor

Description

HTMLHelper.elixirPath() remembers the paths it has already worked out. Three mistakes in how it does that:

  • Two modules asking for the same file name got the same path. With useModuleRoot = true, the cache key was built before the current module was known. The module is now part of the key.
  • A file not in the manifest got a different path on the second call. The first call returned /includes/js/custom.js but cached js/custom.js. The full path is now cached.
  • The manifest file was read from disk on every new lookup. It was stored under one key and looked up under another. The same key is now used for both.

Jira Issues

https://ortussolutions.atlassian.net/browse/COLDBOX-1474

Part of https://ortussolutions.atlassian.net/browse/COLDBOX-1478

Type of change

  • Bug Fix

Checklist

  • My code follows the style guidelines of this project cfformat
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Tests

  • tests/specs/integration/HTMLHelperElixirSpec.cfc (new): one spec for each problem above.

All 3 new specs fail on the 8.3.0 code. With the fix, every spec in the changed files passes on BoxLang (CFML compat), Lucee 5 and Adobe 2025.

- The cache key was built before the current module was known. With useModuleRoot, two modules asking for the same file name shared the first module's path. The module is now part of the key.
- The manifest was stored under one key and looked up under another, so the manifest file was read from disk again on every lookup that was not already cached.
- When a file was not in the manifest, the first call returned the full path but a different value was cached, so later calls returned the bare file name.

Each fix has a spec that fails without it.
@homestar9
homestar9 marked this pull request as ready for review October 27, 2026 22:34
elixirPath() runs for every asset on every page. A cache hit now builds a plain string key and does one struct lookup, instead of serializing the arguments to JSON and hashing them. The request context and current module are only looked up when the module root is used, and the leading slash cleanup, a regex, only runs on a cache miss.
Copilot AI balanced review requested due to automatic review settings October 28, 2026 20:12

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants