Open flack opened 1 week ago
Hello @flack ,
do you know of a simple check from the command line if I'm affected too?
So I've debugged this a bit further, the problem comes from here:
WP_Filesystem()
returns false, because there are no FTP settings. I have define('FS_METHOD', 'direct');
in my wp-config.php
, but I had it at the end of the file. When I move the line to be above require_once( ABSPATH . 'wp-settings.php' )
, the problem disappears.
I haven't checked too deeply, but it seems wrong to use $wp_filesystem
here, because why would you want to load local config files over FTP? $file_path
is a complete local path at this point, so you might as well just use file_get_contents
.
@saddy001 so I guess you would be affected if your wp-config
is missing the define('FS_METHOD', 'direct');
line or has it in the wrong place
Hi @flack & @saddy001
Thanks for the bug report. Actually, We are force to use WordPress file system. As per WordPress coding standards we must avoid use of file_get_content that's why we made changes.
The issue you are facing We will try to re create it and get back to you.
@Sanjeevsetu well, it uses file_get_contents
either way, see
(and in their version it's even a bit unsafer I'd say, because they suppress errors)
or if you want to use WP API, you could try this:
$filesystem = new WP_Filesystem_Direct( true );
$filesystem->get_contents($path)
also, see
https://github.com/WordPress/WordPress-Coding-Standards/pull/1374
WP coding standard allows file_get_contents
for local files, only for URLs it's not allowed. So if you get a warning, it's probably a bug in the code analyzer
Since updating to 2.4.11, I get out of memory errors in my dev environment, I have temporarily removed my memory limit and profiled this shortly with XDebug, which showed that the function
wpm_local_file_get_contents
is called 314820 times during a single request.I've added a
var_dump
inWPM_Config::parse_config_files
and that shows that the list of config files is growing with each call, because it keeps adding the same file over and over again, e.g.:Not sure how this is actually supposed to work (there's not really any useful commit messages...), but something seems broken.
(Tested on PHP 8.3.6)