Skip to content

fix: add file-based cache busting for JavaScript and stylesheet assets#749

Merged
RussH merged 4 commits into
opencats:masterfrom
anonymoususer72041:fix/asset-cache-busting
Apr 22, 2026
Merged

fix: add file-based cache busting for JavaScript and stylesheet assets#749
RussH merged 4 commits into
opencats:masterfrom
anonymoususer72041:fix/asset-cache-busting

Conversation

@anonymoususer72041
Copy link
Copy Markdown
Contributor

@anonymoususer72041 anonymoususer72041 commented Apr 9, 2026

This PR replaces the previous legacy asset anti-cache handling for JavaScript and stylesheet files with centralized file-based cache busting.

The change was motivated by stale browser-cached assets causing outdated client-side code to run against newer server-side code. In practice, this can produce misleading regressions that appear to be application bugs but disappear after a forced reload.

During investigation, issues such as #735, #739 and #740 were found to be affected by this class of problem. In those cases, stale JavaScript assets could cause AJAX requests to behave differently from the current server-side code, which made current master appear broken until the browser cache was bypassed. This PR addresses that underlying asset versioning problem so updated JavaScript and stylesheet files are fetched reliably after changes.

@anonymoususer72041
Copy link
Copy Markdown
Contributor Author

I was not able to test this change in a fully reliable way before opening the PR.

Additional testing would be appreciated, especially around shared page headers, direct asset includes and pages with non-standard layouts.

@RussH
Copy link
Copy Markdown
Member

RussH commented Apr 9, 2026

I'll check this out locally and test

@RussH
Copy link
Copy Markdown
Member

RussH commented Apr 14, 2026

Thanks — the asset cache-busting change looks useful, and I do not see a PHP 7.2 compatibility issue in that part.

The main thing I’d ask for before merge is to make the activity notes rendering consistent. These two files are using the safer escaped pattern:

  • modules/companies/Show.tpl
  • modules/contacts/Show.tpl

They now do:

nl2br(htmlspecialchars($activityData['notes'], ENT_QUOTES | ENT_SUBSTITUTE, HTML_ENCODING))

That is ideal, the note text is escaped first and only then converted to <br> for display.

But these other paths are still using nl2br() on raw notes without escaping first:

  • ajax/getPipelineDetails.php
  • modules/activity/Search.tpl
  • modules/activity/dataGrids.php
  • modules/candidates/Show.tpl

So at the moment the PR leaves note output handled in two different ways, and these files are still vulnerable to XSS exploit if notes contains HTML or script content.

Could those be aligned so all note rendering uses the same escaped pattern before nl2br()?

Finally - this PR seems broader than the title suggests, since it also includes the Status Change activity type/schema change and some unrelated cleanup. Splitting those out would make the cache-busting change much easier to review and would keep the PR's aligned.

@anonymoususer72041
Copy link
Copy Markdown
Contributor Author

anonymoususer72041 commented Apr 14, 2026

I think you mixed things up with #733, #737 and #745, @RussH.

Regarding activity notes, I will create a new PR.

@RussH
Copy link
Copy Markdown
Member

RussH commented Apr 22, 2026

Thanks — I’ve rechecked this and I think my earlier comment was mixed up with other PRs. Looking at the current diff, I don’t see any issues.

@RussH RussH merged commit d642ff0 into opencats:master Apr 22, 2026
3 checks passed
@anonymoususer72041 anonymoususer72041 deleted the fix/asset-cache-busting branch April 22, 2026 17:11
anonymoususer72041 added a commit to anonymoususer72041/OpenCATS that referenced this pull request Apr 22, 2026
commit edf5d0f
Author: anonymoususer72041 <247563575+anonymoususer72041@users.noreply.github.com>
Date:   Wed Apr 22 19:59:58 2026 +0200

    Use stricter assertions in tests

commit 8597922
Author: anonymoususer72041 <247563575+anonymoususer72041@users.noreply.github.com>
Date:   Wed Apr 22 19:50:31 2026 +0200

    Centralize PHPUnit test bootstrap

commit 0393e63
Author: anonymoususer72041 <247563575+anonymoususer72041@users.noreply.github.com>
Date:   Wed Apr 22 19:44:48 2026 +0200

    Clean up PHPUnit configuration

commit dd9b184
Author: anonymoususer72041 <247563575+anonymoususer72041@users.noreply.github.com>
Date:   Wed Apr 22 19:36:22 2026 +0200

    Refactor consecutive mock expectations

commit b60e11a
Author: anonymoususer72041 <247563575+anonymoususer72041@users.noreply.github.com>
Date:   Wed Apr 22 19:30:42 2026 +0200

    Replace deprecated mock builder methods

commit 3580471
Author: anonymoususer72041 <247563575+anonymoususer72041@users.noreply.github.com>
Date:   Wed Apr 22 19:27:17 2026 +0200

    Use expectException in CompanyRepositoryTest

commit 9474ef7
Author: anonymoususer72041 <247563575+anonymoususer72041@users.noreply.github.com>
Date:   Wed Apr 22 19:22:28 2026 +0200

    Replace deprecated regex assertions in tests

commit 6361194
Author: anonymoususer72041 <247563575+anonymoususer72041@users.noreply.github.com>
Date:   Wed Apr 22 19:13:19 2026 +0200

    Escape activity notes before applying nl2br (opencats#751)

    The remaining note rendering paths are now aligned with the safer pattern already used elsewhere in the codebase: nl2br(htmlspecialchars($notes, ENT_QUOTES | ENT_SUBSTITUTE, HTML_ENCODING))

commit d642ff0
Author: anonymoususer72041 <247563575+anonymoususer72041@users.noreply.github.com>
Date:   Wed Apr 22 19:08:54 2026 +0200

    fix: add file-based cache busting for JavaScript and stylesheet assets (opencats#749)

    * Add file-based asset versioning helper

    * Switch JavaScript and stylesheet includes to file-based cache busting

    * Document static submodal asset loading exception

    * Remove legacy asset anti-cache handling
anonymoususer72041 added a commit to anonymoususer72041/OpenCATS that referenced this pull request Apr 22, 2026
commit edf5d0f
Author: anonymoususer72041 <247563575+anonymoususer72041@users.noreply.github.com>
Date:   Wed Apr 22 19:59:58 2026 +0200

    Use stricter assertions in tests

commit 8597922
Author: anonymoususer72041 <247563575+anonymoususer72041@users.noreply.github.com>
Date:   Wed Apr 22 19:50:31 2026 +0200

    Centralize PHPUnit test bootstrap

commit 0393e63
Author: anonymoususer72041 <247563575+anonymoususer72041@users.noreply.github.com>
Date:   Wed Apr 22 19:44:48 2026 +0200

    Clean up PHPUnit configuration

commit dd9b184
Author: anonymoususer72041 <247563575+anonymoususer72041@users.noreply.github.com>
Date:   Wed Apr 22 19:36:22 2026 +0200

    Refactor consecutive mock expectations

commit b60e11a
Author: anonymoususer72041 <247563575+anonymoususer72041@users.noreply.github.com>
Date:   Wed Apr 22 19:30:42 2026 +0200

    Replace deprecated mock builder methods

commit 3580471
Author: anonymoususer72041 <247563575+anonymoususer72041@users.noreply.github.com>
Date:   Wed Apr 22 19:27:17 2026 +0200

    Use expectException in CompanyRepositoryTest

commit 9474ef7
Author: anonymoususer72041 <247563575+anonymoususer72041@users.noreply.github.com>
Date:   Wed Apr 22 19:22:28 2026 +0200

    Replace deprecated regex assertions in tests

commit 6361194
Author: anonymoususer72041 <247563575+anonymoususer72041@users.noreply.github.com>
Date:   Wed Apr 22 19:13:19 2026 +0200

    Escape activity notes before applying nl2br (opencats#751)

    The remaining note rendering paths are now aligned with the safer pattern already used elsewhere in the codebase: nl2br(htmlspecialchars($notes, ENT_QUOTES | ENT_SUBSTITUTE, HTML_ENCODING))

commit d642ff0
Author: anonymoususer72041 <247563575+anonymoususer72041@users.noreply.github.com>
Date:   Wed Apr 22 19:08:54 2026 +0200

    fix: add file-based cache busting for JavaScript and stylesheet assets (opencats#749)

    * Add file-based asset versioning helper

    * Switch JavaScript and stylesheet includes to file-based cache busting

    * Document static submodal asset loading exception

    * Remove legacy asset anti-cache handling
anonymoususer72041 added a commit to anonymoususer72041/OpenCATS that referenced this pull request Apr 23, 2026
commit edf5d0f
Author: anonymoususer72041 <247563575+anonymoususer72041@users.noreply.github.com>
Date:   Wed Apr 22 19:59:58 2026 +0200

    Use stricter assertions in tests

commit 8597922
Author: anonymoususer72041 <247563575+anonymoususer72041@users.noreply.github.com>
Date:   Wed Apr 22 19:50:31 2026 +0200

    Centralize PHPUnit test bootstrap

commit 0393e63
Author: anonymoususer72041 <247563575+anonymoususer72041@users.noreply.github.com>
Date:   Wed Apr 22 19:44:48 2026 +0200

    Clean up PHPUnit configuration

commit dd9b184
Author: anonymoususer72041 <247563575+anonymoususer72041@users.noreply.github.com>
Date:   Wed Apr 22 19:36:22 2026 +0200

    Refactor consecutive mock expectations

commit b60e11a
Author: anonymoususer72041 <247563575+anonymoususer72041@users.noreply.github.com>
Date:   Wed Apr 22 19:30:42 2026 +0200

    Replace deprecated mock builder methods

commit 3580471
Author: anonymoususer72041 <247563575+anonymoususer72041@users.noreply.github.com>
Date:   Wed Apr 22 19:27:17 2026 +0200

    Use expectException in CompanyRepositoryTest

commit 9474ef7
Author: anonymoususer72041 <247563575+anonymoususer72041@users.noreply.github.com>
Date:   Wed Apr 22 19:22:28 2026 +0200

    Replace deprecated regex assertions in tests

commit 6361194
Author: anonymoususer72041 <247563575+anonymoususer72041@users.noreply.github.com>
Date:   Wed Apr 22 19:13:19 2026 +0200

    Escape activity notes before applying nl2br (opencats#751)

    The remaining note rendering paths are now aligned with the safer pattern already used elsewhere in the codebase: nl2br(htmlspecialchars($notes, ENT_QUOTES | ENT_SUBSTITUTE, HTML_ENCODING))

commit d642ff0
Author: anonymoususer72041 <247563575+anonymoususer72041@users.noreply.github.com>
Date:   Wed Apr 22 19:08:54 2026 +0200

    fix: add file-based cache busting for JavaScript and stylesheet assets (opencats#749)

    * Add file-based asset versioning helper

    * Switch JavaScript and stylesheet includes to file-based cache busting

    * Document static submodal asset loading exception

    * Remove legacy asset anti-cache handling
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