Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.Sign up
Create "cache" folder if it doesn't exist before trying to write to it #21952
This fixes this issue:
Steps to reproduce the issue
Result before PR
Sites breaks. Goes blank.
With error reporting on, throws error:
Result after PR
Joomla creates "cache" folder if it doesn't exist
Now, of course there is no reason why one should delete the cache folder but it can happen by accident or for whatever other reason. The principle that Joomla doesn't check if the folder is there or not (and breaks the site if it's not) before trying to write to it is wrong.
This is the wrong place to be doing this type of thing. A check for platform support shouldn't have side effects, in this case the side effect is creating the directory.
This type of directory creation is better suited in com_config when the global configuration is saved (which, we already do except for trying to (re-)create the core cache directory).
TBH, the more I think about this the more I think this particular
Taking some inspiration from https://github.com/joomla-framework/cache/blob/2.0-dev/src/Adapter/File.php
@mbabker Thanks for the comment. Deleting the method solves the issue too. Updated.