Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ajax upload bug (solved) #2610

Closed
tarranjones opened this issue Jan 26, 2015 · 0 comments
Closed

Ajax upload bug (solved) #2610

tarranjones opened this issue Jan 26, 2015 · 0 comments

Comments

@tarranjones
Copy link

issue #2142, issue #2609

short explanation

the timer variable is being overwritten so previous setIntervals cant be stopped resulting in possible multiple infinite loop simultaneously.

long explanation

When the upload button is clicked, a function is set to be fired every 500ms using the setInverval method.
The setInterval method is assigned the variable 'timer'. This will continue to loop until a file has been selected and then 'timer' will be cleared(deleted). If the browsers upload dialog box is closed without selecting a file it still continues to loop.

Every time #button-upload is clicked another setInverval is run meaning there are now multiple loops occurring simultaneously but the latest has been given the same variable name meaning none of the others can now be cleared(deleted).

so once the loop sees that the file has been set then the ajax request is fired and 'timer' is cleared. leaving all previous setinverval methods to to loop infinity but because the a file has been selected it will continue to fire the ajax request resulting in lots of alerts().

Solution

$('#form-upload input[name=\'file\']').trigger('click');

/* new code */ 
if(typeof timer !='undefined'){
    clearInterval(timer);
}
/* new code end */
timer = setInterval(function() {

Affected files

htdocs\opencart-2.0.1.1\admin\view\template\catalog\download_form.tpl
htdocs\opencart-2.0.1.1\admin\view\template\common\filemanager.tpl
htdocs\opencart-2.0.1.1\admin\view\template\extension\installer.tpl
htdocs\opencart-2.0.1.1\admin\view\template\payment\amazon_checkout_order.tpl
htdocs\opencart-2.0.1.1\admin\view\template\sale\customer_form.tpl
htdocs\opencart-2.0.1.1\admin\view\template\sale\order_form.tpl
htdocs\opencart-2.0.1.1\catalog\view\theme\default\template\account\address_form.tpl
htdocs\opencart-2.0.1.1\catalog\view\theme\default\template\account\edit.tpl
htdocs\opencart-2.0.1.1\catalog\view\theme\default\template\account\register.tpl
htdocs\opencart-2.0.1.1\catalog\view\theme\default\template\checkout\guest.tpl
htdocs\opencart-2.0.1.1\catalog\view\theme\default\template\checkout\guest_shipping.tpl
htdocs\opencart-2.0.1.1\catalog\view\theme\default\template\checkout\payment_address.tpl
htdocs\opencart-2.0.1.1\catalog\view\theme\default\template\checkout\register.tpl
htdocs\opencart-2.0.1.1\catalog\view\theme\default\template\checkout\shipping_address.tpl
htdocs\opencart-2.0.1.1\catalog\view\theme\default\template\product\product.tpl

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants