-
-
Notifications
You must be signed in to change notification settings - Fork 494
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
WP.AlternativeFunctions: Add more functions to filesystem functions list #1265
Conversation
Will make it easier to see changes.
These functions were in the `VIP.FileSystemWritesDisallowed` sniff, and it seemed like a good idea to add them here as well.
Just wondering: Do all those PHP functions actually have sister-methods within the WP FileSystem ? If not, we'd just be confusing people. Other than that, I'd want to think a bit more about legitimate use-cases not to use the WP FileSystem (other than the overhead) for any of these functions. If there are legitimate use-cases, we should probably be a bit wary of adding these functions. |
Here is a quick comparison of the functions and methods that provide direct analogs:
I think that for many of the remaining ones, a similar effect can still be achieved, but not necessarily in exactly the same way (e.g.,
I'm honestly not exactly sure when |
Agreed, info on that is very inconsistent - which is why we end up using it for almost all things. Just because WPCS is constantly nagging. However, I never understood what the problem is exactly with |
While Saying that, for a custom plugin that isn't distributed, where the filesystem is known and managed correctly, using the native PHP would seem more beneficial. Perhaps these checks could be added in, but with a custom property that could turn them off en masse (instead of whitelist flag lots of lines)? |
@GaryJones thanks for taking the time to add a detailed explanation 👍 But as far as I know Edit: From what I see there were lots of issues in PHP versions 4.x but that's no longer the case in PHP 5.2+ |
Although I've used the WP_Filesystem API, I've not really looked into the internals of too much - but https://www.sitepoint.com/introduction-to-the-wordpress-filesystem-api/ has an explanation of why, as does https://codex.wordpress.org/Filesystem_API - it seems it's more about file ownership from a security perspective, rather than just making the file-writing work. |
For writing I agree 100%!! |
@GaryJones The current implementation allows for that already through the |
Just a quick note here - Using
|
Ouch, this PR has been open way too long. Looking at it now, I believe the following actions are needed:
As @JDGrimes isn't active anymore in the WPCS sphere, the above action list is up for grabs for anyone who wants to work on it. |
@jrfnl I will take a look and create a PR |
While looking at
VIP.FileSystemWritesDisallowed
I saw that it listed a lot more functions than were here. I think most of them rightly belong on this list as well. The only ones I'm not sure about arefputcsv()
,symlink()
(WP_FileSystem
doesn't support symlinks), andtempnam()
. I've gone ahead and added them, but everyone is welcome to weigh in if they think they don't belong here.Incidentally, the group name is
filesystem_read
, even though filesystem write functions were included as well. I assumed that was for back-compat, so I've left it.For easier review, the first commit reorders the existing list alphabetically, the second commit adds the new functions.