Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.1] Migrating Joomla\CMS\Filesystem\Folder::exists() to is_dir() #40131

Merged
merged 16 commits into from
Mar 2, 2024

Conversation

Hackwar
Copy link
Member

@Hackwar Hackwar commented Mar 16, 2023

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:

  • No documentation changes for docs.joomla.org needed

  • Pull Request link for manual.joomla.org:

  • No documentation changes for manual.joomla.org needed

@laoneo
Copy link
Member

laoneo commented Mar 19, 2023

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.

@Hackwar
Copy link
Member Author

Hackwar commented Mar 19, 2023

Done.

@MacJoom MacJoom self-assigned this Mar 22, 2023
@Hackwar Hackwar added the bug label Apr 8, 2023
@laoneo laoneo changed the base branch from 4.4-dev to 5.0-dev April 14, 2023 12:05
@laoneo laoneo changed the title [4.4] Migrating Joomla\CMS\Filesystem\Folder::exists() to is_dir() [5.0] Migrating Joomla\CMS\Filesystem\Folder::exists() to is_dir() Apr 14, 2023
@laoneo laoneo removed the PR-4.4-dev label Apr 14, 2023
@laoneo laoneo mentioned this pull request Apr 18, 2023
4 tasks
@Hackwar Hackwar closed this Apr 18, 2023
@laoneo laoneo added the b/c break This item changes the behavior in an incompatible why. HEADS UP label Apr 18, 2023
@Hackwar Hackwar reopened this Apr 18, 2023
…sdir

# Conflicts:
#	administrator/components/com_admin/script.php
#	plugins/editors/tinymce/src/PluginTraits/DisplayTrait.php
@HLeithner
Copy link
Member

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?

@Hackwar
Copy link
Member Author

Hackwar commented Sep 2, 2023

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. 😉

@Hackwar
Copy link
Member Author

Hackwar commented Sep 2, 2023

The Codestyle error reported here is unrelated to this PR.

@HLeithner HLeithner added Feature and removed bug labels Oct 5, 2023
@HLeithner HLeithner changed the base branch from 5.0-dev to 5.1-dev October 5, 2023 10:27
@HLeithner HLeithner changed the title [5.0] Migrating Joomla\CMS\Filesystem\Folder::exists() to is_dir() [5.1] Migrating Joomla\CMS\Filesystem\Folder::exists() to is_dir() Oct 5, 2023
@HLeithner HLeithner added the Maintainers Checked Used if the PR is conceptional useful label Oct 5, 2023
@Hackwar Hackwar removed the b/c break This item changes the behavior in an incompatible why. HEADS UP label Nov 3, 2023
@Fedik
Copy link
Member

Fedik commented Feb 25, 2024

I have tested this item ✅ successfully on 58f6055


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/40131.

@Hackwar Hackwar added the RTC This Pull Request is Ready To Commit label Feb 26, 2024
@bembelimen bembelimen self-assigned this Mar 1, 2024
@bembelimen bembelimen merged commit 6e89391 into joomla:5.1-dev Mar 2, 2024
3 of 4 checks passed
@bembelimen
Copy link
Contributor

Thx

@joomla-cms-bot joomla-cms-bot removed the RTC This Pull Request is Ready To Commit label Mar 2, 2024
@bembelimen bembelimen added this to the Joomla! 5.1.0 milestone Mar 2, 2024
@Quy Quy mentioned this pull request Mar 3, 2024
@Hackwar Hackwar deleted the 4.4-filesystem-isdir branch March 4, 2024 17:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants