[5.1] Migrating Joomla\CMS\Filesystem\Folder::exists() to is_dir()
Summary of Changes
We are migrating away from the Joomla\CMS\Filesystem classes to the framework Filesystem classes. This PR replaces all occurences of Joomla\CMS\Filesystem\Folder::exists() with is_dir(). The former method does not exist in the framework class, mainly because it is an unnecessary wrapper for the later. Where necessary, an import for Joomla\Filesystem\Path has been added and unnecessary ones removed. All the existing imports to Joomla\CMS\Filesystem\Path are changed to the framework package in another PR.
Joomla\Filesystem\Path::clean() should be used when the given path can not be 100% assumed to be safe, for example when the path is coming from some outside input. That method will make sure that a path will have the systems directory separator and not contain double slashes or double backslashes.
Testing Instructions
Codereview
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
It would be helpful for extension developers when you can write a couple of words in the pr description why you have used Path::clean.
Done.
I fixed the merge conflict but I'm not 100% sure if it make sense, since now we call is_dir(Path::clean()) before we just call Folder::exists() which implicit called Path::clean() for 3rd party developer it's possible that they forget or ignore the Path::clean() which might be an issue?
The nice thing is, that we are not changing third party code, but just our core code. After this change, third party code will still behave the same. 😉
The Codestyle error reported here is unrelated to this PR.
I have tested this item :white_check_mark: successfully on 58f6055724a9da2faec4320d31b47b114a9edd79
This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/40131.
Thx