[6.0] Language cache error handling improvement
Pull Request for Issue # .
Summary of Changes
This PR improves the robustness of Joomla’s language cache handling. Currently, if a language cache file is only partially written (e.g., due to low disk space, write interruption, or unexpected I/O failure), the corrupted cache file will remain on disk. On the next request, Joomla attempts to include this broken file, which may lead to PHP errors, warnings, or unexpected behavior.
This PR introduces safer handling of such scenarios by:
- Removing the corrupted cache file immediately when the write operation fails, ensuring Joomla does not load an invalid cache file in future requests.
- Logging the failure so administrators can see errors from log if needed.
Testing Instructions
I could not find an easy way to make this operation fail on normal condition. So you can just perform simple test below:
- Use Joomla 6.0
- Apply patch
- Delete language cache folder (administrator\cache\language)
- Access to your site again, make sure there is no error
- Check language cache folder (administrator\cache\language) and make sure the cache files still being created as before.
Actual result BEFORE applying this Pull Request
Works, with potential errors if cache file is partially written
Expected result AFTER applying this Pull Request
Works, no potential errors
Link to documentations
Please select:
-
[ ] Documentation link for docs.joomla.org:
-
[x] No documentation changes for docs.joomla.org needed
-
[ ] Pull Request link for manual.joomla.org:
-
[x] No documentation changes for manual.joomla.org needed
I have tested this item :white_check_mark: successfully on 7fa9554ef7b4efd9507ce35a4f12c896d3588c13
I have successfully tested this.
(In case this is important (I doubt it): when going back into the backend and clicking around, the number of cache files that come back into the administrator/cache/language directory is not always the same initially...) most of the time it's 78 or 90, but sometimes its 58, and eventually climbs up to 120.
This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/46545.