DHolloran/WPMultiFileUploader

Image files not processing on complete - using some kind of timeout

Opened this issue · 4 comments

Hello,

First, thank you for the great plugin. We appreciate your work immensely.

Here's the issue we are seeing. If we upload a PDF (or any non-image file), when the file completes it's upload, the UI is updated immediately so the user receives prompt confirmation that the upload was successful.

However, when we upload a PNG (or any other image file), the upload completes very fast, like with the PDF, however, the UI does not update. It continues to show the spinner and say "Processing". It appears as though approx 30 seconds later, via means of a javascript timer, the UI is updated notifying the user that the upload has processed successfully.

1.) Is that by design?
2.) If not, can you think of anything we can do to fix it?

Thanks again. If you'd like to email directly I'm avail at dave@glowhorn.com and willing to runs tests to help the cause.

Thx..Dave

I debugged the issue as far as I could, and learned that at this line:
i.onreadystatechange = M(e, i); (fineuploader.min.js line 894)

the onreadystatechange handler is assigned, however it never actually gets called when I upload image files (it does get called when uploading a PDF or DOC). Any ideas? I have some programming skills, but this code is brand new and hard for me to debug. Any help is much appreciated.

Thanks

It is definitely not by design, are you using the default implementation or have you changed some of the optional parameters? Also I'm curious what the Ajax response is returning in chrome at least I'm sure other tools can do it there is a network tab and if you find the last request to admin-Ajax.php and see what the response is. If it is 0 or some sort of a PHP error then that might be an issue. I'll try to look into as well

Hi, Thanks for the prompt reply. I took your advice and used Chrome Dev
Tools. Doing so, I realized that the POST took over 1 minute when sending
an image. So it turns out the callback was working fine, and the delay was
on the server side. After tracing code paths etc I finally narrowed it
down to this code:

file: classes/class-wpmfu-file-upload-handler.php

--code begin--
public function add_attachment( $url, $filepath )
{
$meta = $this->create_image_sizes( $filepath );
$wp_upload_dir = wp_upload_dir();
$filename = str_replace( $wp_upload_dir['url'] . '/', '',
$url );
$wp_filetype = wp_check_filetype(basename($filename), null
);

            $attachment = array(
                     'guid' => $url,
                     'post_mime_type' => $wp_filetype['type'],
                     'post_title' => preg_replace('/\.[^.]+$/', '',

basename($filename)),
'post_content' => '',
'post_status' => 'inherit'
);

            $attach_id = wp_insert_attachment( $attachment, $url );

            // you must first include the image.php file
            // for the function wp_generate_attachment_metadata() to

work
/*skip this - takes 1 minute for images
require_once( ABSPATH . 'wp-admin/includes/image.php' );
$attach_data = wp_generate_attachment_metadata( $attach_id,
$url );
$attach_data['sizes'] = $meta;
wp_update_attachment_metadata( $attach_id, $attach_data );
*/

            return $attach_id;
    } //add_attachment()

--code end--

For some reason, the call into the WP core function
[wp_generate_attachment_metadata] always takes more than 1 minute with
images. This, of course, led me to believe the problem is in my WP
installation and not this plugin. But running other tests, like uploading
files from the Admin Dashboard, all worked very fast, and they execute that
same WP core code.

So, I'm left scratching my head. But, by commenting those lines out, I'm
up and running without any noticeable loss of functionality, so I think I
am good to go on my project. But I still wanted to share all of this with
you, in case it somehow helps. My only guesses/thoughts would be this - Is
your plugin perhaps adding additional thumbnail sizes or image filters
somewhere, that would add a large burden on the core WP file uploader?

Anyways, that's it for me. Thanks again for the prompt reply.

Thanks,
Dave

On Mon, Sep 30, 2013 at 4:17 PM, Danny Holloran notifications@github.comwrote:

It is definitely not by design, are you using the default implementation
or have you changed some of the optional parameters? Also I'm curious what
the Ajax response is returning in chrome at least I'm sure other tools can
do it there is a network tab and if you find the last request to
admin-Ajax.php and see what the response is. If it is 0 or some sort of a
PHP error then that might be an issue. I'll try to look into as well


Reply to this email directly or view it on GitHubhttps://github.com//issues/15#issuecomment-25414631
.

What version number are you on? That looks totally different than the current release should it should have a check to see if it is an image before trying to generate attachment meta data. Also did you mean it takes 1 minute for images or for other files, you said initially that images where instant if it is the non image files upgrading to 1.1.3 should fix the issue