Bug Report: @rename on Windows
-
Hi, not sure if this is the appropriate place to file a bug report – let me know if not.
Line 386 of wp-smushit.php is ‘@rename( $temp_file, $file_path );’. Apparently this function doesn’t always work on Windows, and the result should be tested and if not successful, use copy()/unlink() instead – see https://php.net/manual/en/function.rename.php.
A such, I’ve had to replace it with the following, but it took a while to figure out why smushit was reporting nothing but success yet the files weren’t getting any smaller!
$success = @rename( $temp_file, $file_path ); if (!$success) { copy($temp_file, $file_path); unlink($temp_file); }
Thanks,
IainP.S. Also, more of an edge case but a bug nonetheless – the condition on line 321
if ( 0 !== stripos(realpath($file_path), realpath(ABSPATH)) ) {
doesn’t accommodate installations in which the core files are stored in a subdirectory (useful when working with svn externals – see https://ottopress.com/2011/creating-a-wordpress-site-using-svn/). I’ve had to change this to
if ( 0 !== stripos(realpath($file_path), str_replace('/core', '', realpath(ABSPATH))) ) {
for my needs, but this only works for my choice of directory name – perhaps you understand the required fix?Thanks.
- The topic ‘Bug Report: @rename on Windows’ is closed to new replies.