Disabling multiple submission on search form

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Disabling multiple submission on search form

SUZUKI Arthur

Hello,

We are facing the following problem on our installation of Koha.

Some impatient users tends to click several times on the “Go” button of the search form on OPAC.

Probably in a desperate hope that this will speed up the whole process.

However the result is quite opposite, as Zebra is then queried multiple times which increases the server cpu load, until it reach 100% and cause Denial of Service (boooh…)

 

We had the idea of disabling the “searchsubmit” button upon first click.

This is done by adding onclick=”this.disabled=true;” after “id=searchsubmit” in masthead.inc.

Here is a SED command to make it easier.

 

sed -i -e 's/id="searchsubmit"/id="searchsubmit" onclick="this.disabled=true; this.form.submit(); return true;"/' src/koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead.inc

 

Did any of you already faced similar problems?

Any other ideas or implementation are welcome!

 

Arthur SUZUKI

Service informatique des bibliothèques

bIBLIOTHÈQUES UNIVERSITAIRES

Université Jean Moulin Lyon 3

6 Cours Albert Thomas - B.P. 8242 – 69355 Lyon Cedex 08

ligne directe : +33 (0)4 78 78 79 16 | http://bu.univ-lyon3.fr

 

L'Université Jean Moulin est membre fondateur de l'Université de Lyon

 


_______________________________________________
Koha-devel mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/koha-devel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Disabling multiple submission on search form

SUZUKI Arthur

ERRATUM:

You should add onclick="this.disabled=true; this.form.submit(); return true;" as stated in the Sed command.

If missing “this.form.submit(); return true;” the trick works only in Firefox and IE (screw you Google…).

Best regards,

 

Arthur SUZUKI

Service informatique des bibliothèques

bIBLIOTHÈQUES UNIVERSITAIRES

Université Jean Moulin Lyon 3

6 Cours Albert Thomas - B.P. 8242 – 69355 Lyon Cedex 08

ligne directe : +33 (0)4 78 78 79 16 | http://bu.univ-lyon3.fr

 

L'Université Jean Moulin est membre fondateur de l'Université de Lyon

 

 

 

De : SUZUKI Arthur
Envoyé : lundi 15 février 2016 10:55
À : '[hidden email]'; '[hidden email]'
Cc : BOUIS Sonia; CROUZET Olivier
Objet : Disabling multiple submission on search form

 

Hello,

We are facing the following problem on our installation of Koha.

Some impatient users tends to click several times on the “Go” button of the search form on OPAC.

Probably in a desperate hope that this will speed up the whole process.

However the result is quite opposite, as Zebra is then queried multiple times which increases the server cpu load, until it reach 100% and cause Denial of Service (boooh…)

 

We had the idea of disabling the “searchsubmit” button upon first click.

This is done by adding onclick=”this.disabled=true;” after “id=searchsubmit” in masthead.inc.

Here is a SED command to make it easier.

 

sed -i -e 's/id="searchsubmit"/id="searchsubmit" onclick="this.disabled=true; this.form.submit(); return true;"/' src/koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead.inc

 

Did any of you already faced similar problems?

Any other ideas or implementation are welcome!

 

Arthur SUZUKI

Service informatique des bibliothèques

bIBLIOTHÈQUES UNIVERSITAIRES

Université Jean Moulin Lyon 3

6 Cours Albert Thomas - B.P. 8242 – 69355 Lyon Cedex 08

ligne directe : +33 (0)4 78 78 79 16 | http://bu.univ-lyon3.fr

 

L'Université Jean Moulin est membre fondateur de l'Université de Lyon

 


_______________________________________________
Koha-devel mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/koha-devel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Disabling multiple submission on search form

Frédéric Demians
In reply to this post by SUZUKI Arthur
> Some impatient users tends to click several times on the “Go” button of the
> search form on OPAC. Probably in a desperate hope that this will speed up
> the whole process.

> However the result is quite opposite, as Zebra is then queried multiple
> times which increases the server cpu load, until it reach 100% and cause
> Denial of Service (boooh…)

Are you sure your users are doing that? Koha server can lag severely for other
reasons...

> We had the idea of disabling the “searchsubmit” button upon first click.
> This is done by adding onclick=”this.disabled=true;” after “id=searchsubmit”
> in masthead.inc.

Rather than modifying direcly masthead.inc, you could do it with a JavaScript
snippet placed in opacuserjs system preference:

$(document).ready(function() {
 $('#searchform').submit(function() {
   $('#searchsubmit').prop('disabled',true).text('searching...');
 });
});

It could make sense to integrate this to Koha code base: open a bug ticket.

_______________________________________________
Koha-devel mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/koha-devel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Disabling multiple submission on search form

SUZUKI Arthur
Hi Frederic,
We are not sure but all those requests from same IP with same query in such a few seconds gives us some confidence in this scenario.
I just opened a bug ticket: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=15855
Attached to it is an extract of koha-opac-access_log for better understanding of the issue.
Also tested your code, works great on Chrome, IE11 and Firefox!
Regards,
Arthur

-----Message d'origine-----
De : [hidden email] [mailto:[hidden email]] De la part de Frédéric Demians
Envoyé : jeudi 18 février 2016 09:14
À : SUZUKI Arthur
Cc : [hidden email]; [hidden email]; CROUZET Olivier; BOUIS Sonia
Objet : Re: [Koha-devel] Disabling multiple submission on search form

> Some impatient users tends to click several times on the “Go” button
> of the search form on OPAC. Probably in a desperate hope that this
> will speed up the whole process.

> However the result is quite opposite, as Zebra is then queried
> multiple times which increases the server cpu load, until it reach
> 100% and cause Denial of Service (boooh…)

Are you sure your users are doing that? Koha server can lag severely for other reasons...

> We had the idea of disabling the “searchsubmit” button upon first click.
> This is done by adding onclick=”this.disabled=true;” after “id=searchsubmit”
> in masthead.inc.

Rather than modifying direcly masthead.inc, you could do it with a JavaScript snippet placed in opacuserjs system preference:

$(document).ready(function() {
 $('#searchform').submit(function() {
   $('#searchsubmit').prop('disabled',true).text('searching...');
 });
});

It could make sense to integrate this to Koha code base: open a bug ticket.
_______________________________________________
Koha-devel mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/koha-devel
Loading...