Ready to get started?Download WordPress


WP Smush.it
[resolved] Bug Report: @rename on Windows (8 posts)

  1. iporter
    Posted 12 months ago #

    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 http://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);


    P.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 http://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?



  2. Mike
    WPMU DEV Support Staff
    Posted 11 months ago #

    Hi @iporter

    Well spotted, fewer people use Windows servers which is why this probably hasn't been identified until now.

    I've given our developers a heads up so hopefully they will implement this.

    Thank you very much for the in depth description and for providing a solution!

    WPMU DEV Support Staff
    Plugin Author

    Posted 11 months ago #


    Thanks for the code snippet on the rename. I agree. Part of the issue with Windows is not being able to rename across partitions.

    also thanks for the notes on the code related to the str_replate logic. Ive done away with all that cruft. Basically, the plugins should spin through the media attachments and work under any path. These is some funky left over code that limits the image to be within certain paths which in my option is wrong. So now the plugin (in beta) takes the URL and Path of the original image and simply uses that.

    I don't have access to a Windows system. Any chance of getting you to review the beta?

  4. iporter
    Posted 11 months ago #

    For sure, and you're welcome - happy to be able to help. How do I download it, is it in SVN? I see v1.6.5, which is what I have installed.

  5. Mike
    WPMU DEV Support Staff
    Posted 11 months ago #

    Hi @iporter

    The latest version has now been uploaded, its and you can grab it here:

    Please report back and let us know how you get on as most of us are using Linux based servers and can't test these things!

    WPMU DEV Support Staff
    Plugin Author

    Posted 11 months ago #

    Hey again.

    Thanks again, we've release that version as per Mikes post.

    If you need anything else, please let us know.

    Take care.

  7. iporter
    Posted 10 months ago #

    Hi Mike, apologies for the delay. I've just downloaded version and can confirm that your updates have solved this problem.


  8. Mike
    WPMU DEV Support Staff
    Posted 10 months ago #

    Brilliant, thank you for letting us know!


You must log in to post.

About this Plugin

About this Topic


No tags yet.