Update warning message for file system operations#2636
Update warning message for file system operations#2636dd32 wants to merge 1 commit intoWordPress:developfrom
Conversation
Update the message to indicate that WP_Filesystem should not be used for general file IO.
|
@dd32 Thanks for the PR. I'm in two minds about this. The new text:
... would leave users with an inactionable warning - if a file operation is rightfully used, but it's not an upgrade routine, what to do ? This is counter to the principle of PHPCS (everything should be fixable, automatically or manually). There is some precedent for inactionable warnings in WPCS, but only for security related issues, not for anything else and inactionable warnings is one of the biggest sources of irritation for end-users of WPCS. So, that leaves us with a conundrum.... is there any auto-detection which can be done to limit when the warning is shown to only actionable situations ? On another, very loosely related note - does the FileSystem interact with the PHP OpCache and if so, how ? and will the change in PHP 8.5 of OpCache becoming a non-optional part of PHP have any impact ? |
I agree. I initially came here to suggest that the rule be removed entirely.
The list of functions is what caused me to change tact from These functions can be used properly: This warning has caused a lot of people to switch from These probably shouldn't be needed: These I'm on the rails about, and err towards allow (at least for writable)
I don't really think so, it's probably possible, but I can't imagine it's worth it.
No. However, the Upgrader (which uses Filesystem) does. See |
Update the message to indicate that WP_Filesystem should not be used for general file IO.
Description
The coding standards suggest using WP_Filesystem instead of all file-operations, which often sends developers down a path that they really shouldn't have.
This just clarifies that perhaps they shouldn't perform file operations, and to use WP_Filesystem for upgrade-routines (Which the classes are intended for).
This might get some pushback from some people who feel WP_Filesystem should be used if it exists, but it's an abstraction that applies for a constantly reducing set of sites, which run on read-only filesystems and require FTP to interact with the WordPress files.
Generally, WP_Filesystem either uses direct IO, or, FTP which requires interactive prompting, which most plugins/themes that use WP_Filesystem are not handling anyway.
I will note it's possible for WP_Filesystem to be configured with hard-coded credentials, but that's even more rare.
Pushing people onto this class just doesn't benefit anyone.
I would almost suggest that the mention of WP_Filesystem should be removed entirely, and this just be left as a "You really shouldn't do file operations if this is running often" type warning.
Suggested changelog entry
Related issues/external references
Fixes #