[Koha-devel] Disabling multiple submission on search form

BOUIS Sonia sonia.bouis at univ-lyon3.fr
Mon Feb 22 11:37:02 CET 2016


Hi,
Thanks for your help Frédéric. Here are some details and answers about our problem.
As Arthur explained, we can see a real correlation between requests repeated in koha_opac_access.log and the CPU load to 100% which blocks totally Koha.
We are not sure that this behavior is only due to a repeated click on 'go' button, but perhaps it's due to a prolonged press on the "enter" key, or to some old or dirty keyboard where enter key is stuck with an undetermined substance (I don't want to know which one..)

So, for the moment we have had jquery code in opacuserjs :

// multi soumission Enter
var submitted;
$('#translControl1').bind('keyup',function() {
    submitted = false;
});  
$('#translControl1').bind('keydown',function(event) {
       code = event.keyCode||event.which||event.charCode||event.char||0;
       if(code == 13) {
           if (submitted == false) {
               submitted = true;		   
               $('#searchform').submit();
           } else {
	       event.preventDefault();
	       event.returnValue = false;
               return false;
           }
       }
});


But, you said that it could make sense to integrate this in koha code. If this is not added in masthead.inc (in the very button element), do you mean it would be necessary to add it at the page level and in which include file ? 
Thanks in advance,

Sonia


  

-----Message d'origine-----
De : SUZUKI Arthur 
Envoyé : jeudi 18 février 2016 11:20
À : Frédéric Demians
Cc : koha-devel at lists.koha-community.org; koha-devel at nongnu.org; CROUZET Olivier; BOUIS Sonia
Objet : RE: [Koha-devel] Disabling multiple submission on search form

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 : frederic.demians at gmail.com [mailto:frederic.demians at gmail.com] De la part de Frédéric Demians Envoyé : jeudi 18 février 2016 09:14 À : SUZUKI Arthur Cc : koha-devel at lists.koha-community.org; koha-devel at nongnu.org; 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.


More information about the Koha-devel mailing list