Unit/System Tests PR-6.2-dev Pending

User tests: Successful: Unsuccessful:

avatar dishu305
dishu305
28 Oct 2026

…fixes #48723)

Summary

This PR fixes a race condition in FileStorage::store() where concurrent requests could read partially written cache files (due to fopen with wb mode truncating the file immediately).

Changes

  • Replaced direct fopen/fwrite logic with an atomic write pattern using a temporary file and rename().
  • Added LOCK_EX to prevent concurrent writes.
  • Added a new Unit Test (FileStorageTest::testStoreUsesAtomicWriteAndCleansUpTempFiles) to verify the atomic behavior and ensure no .tmp files are left behind.

Testing Instructions

  1. Run the new unit test: php libraries/vendor/bin/phpunit tests/Unit/Libraries/Cms/Cache/Storage/FileStorageTest.php
  2. Verify that testStoreUsesAtomicWriteAndCleansUpTempFiles passes with 3 assertions.
  3. (Optional) Simulate high concurrency on a site with File Cache enabled to verify no corrupted cache files are served.

AI Policy

  • I confirm that I have not used AI to generate this code. All code and tests were written manually.
avatar dishu305 dishu305 - open - 28 Oct 2026
avatar dishu305 dishu305 - change - 28 Oct 2026
Status New ⇒ Pending
avatar joomla-cms-bot joomla-cms-bot - change - 28 Oct 2026
Category ⇒ Libraries Unit Tests
avatar dishu305 dishu305 - change - 28 Oct 2026
Labels Added: Unit/System Tests PR-6.2-dev
avatar dishu305
dishu305 - comment - 28 Oct 2026

Hi maintainers,

I wanted to provide an update on the test results. The global CI suite is currently showing pre-existing failures in unrelated components (Date, Form, HTML, MVC tests) due to MockObject_CMSApplicationInterface::getConfig() issues on the base branch. These are not caused by this PR.

To verify that my changes work correctly, I ran the specific test suite for the Cache Storage component locally:

php libraries/vendor/bin/phpunit tests/Unit/Libraries/Cms/Cache/Storage/FileStorageTest.php --filter testStoreUsesAtomicWriteAndCleansUpTempFiles

<img width="430" height="57" alt="Screenshot 2026-10-29 001954" src="https://github.com/user-attachments/assets/97b62614-7584-4e50-ae0b-ee323f317dfc" />
avatar dishu305
dishu305 - comment - 28 Oct 2026

Hi maintainers,

I wanted to provide an update on the test results. The global CI suite is currently showing pre-existing failures in unrelated components (Date, Form, HTML, MVC tests) due to MockObject_CMSApplicationInterface::getConfig() issues on the base branch. These are not caused by this PR.

To verify that my changes work correctly, I ran the specific test suite for the Cache Storage component locally:

php libraries/vendor/bin/phpunit tests/Unit/Libraries/Cms/Cache/Storage/FileStorageTest.php --filter testStoreUsesAtomicWriteAndCleansUpTempFiles

<img width="430" height="57" alt="Screenshot 2026-10-29 001954" src="https://github.com/user-attachments/assets/97b62614-7584-4e50-ae0b-ee323f317dfc" />
avatar dishu305
dishu305 - comment - 28 Oct 2026

Hi maintainers,

I wanted to provide an update on the test results. The global CI suite is currently showing pre-existing failures in unrelated components (Date, Form, HTML, MVC tests) due to MockObject_CMSApplicationInterface::getConfig() issues on the base branch. These are not caused by this PR.

To verify that my changes work correctly, I ran the specific test suite for the Cache Storage component locally:

php libraries/vendor/bin/phpunit tests/Unit/Libraries/Cms/Cache/Storage/FileStorageTest.php --filter testStoreUsesAtomicWriteAndCleansUpTempFiles

<img width="430" height="57" alt="Screenshot 2026-10-29 001954" src="https://github.com/user-attachments/assets/eb19f73f-0f14-4169-8ac2-d4fcdf1e48ed" />
avatar dishu305
dishu305 - comment - 28 Oct 2026

Hi maintainers,

I wanted to provide an update on the test results. The global CI suite is currently showing pre-existing failures in unrelated components (Date, Form, HTML, MVC tests) due to MockObject_CMSApplicationInterface::getConfig() issues on the base branch. These are not caused by this PR.

Screenshot 2026-10-29 001954

To verify that my changes work correctly, I ran the specific test suite for the Cache Storage component locally:

php libraries/vendor/bin/phpunit tests/Unit/Libraries/Cms/Cache/Storage/FileStorageTest.php --filter testStoreUsesAtomicWriteAndCleansUpTempFiles

avatar brianteeman
brianteeman - comment - 28 Oct 2026

That's very strange as the tests are passing on other pull requests

avatar richard67
richard67 - comment - 29 Oct 2026

@dishu305 Please fix the code style errors you can see here: https://github.com/joomla/joomla-cms/pull/48725/changes#diff-3b24c34a3df50b29d31028099185a3d490fb849fa17da32a86c537dc9401dc56

And please add back the AI policy which you have removed from the pull request description template when creating your PR.

Thanks in advance.

avatar tecpromotion tecpromotion - change - 29 Oct 2026
Title
…
Fix: implement atomic write in FileStorage to prevent partial reads
[6.2] Fix: implement atomic write in FileStorage to prevent partial reads
avatar tecpromotion tecpromotion - edited - 29 Oct 2026
avatar joomla-cms-bot joomla-cms-bot - change - 30 Oct 2026
Category Libraries Unit Tests ⇒ Unit Tests
avatar dishu305 dishu305 - change - 30 Oct 2026
The description was changed
avatar dishu305 dishu305 - edited - 30 Oct 2026
avatar brianteeman
brianteeman - comment - 30 Oct 2026

as well as the tests failing this PR now only includes the test - the other changes have been lost

Add a Comment

Login with GitHub to post a comment