snipe / banbuilder

Composer package for censoring profanity in web applications, forums, etc.
http://www.banbuilder.com
327 stars 99 forks source link

Maximum execution time of 30 seconds exceeded #28

Open stefanoortisi opened 8 years ago

stefanoortisi commented 8 years ago

I'm using banbuilder in my Laravel 5 app. When I try to run the censorString method I get the following error:

FatalErrorException in CensorWords.php line 181: Maximum execution time of 30 seconds exceeded

This is the code generating the error:

Validator::extend('filter_bad_words', function($attribute, $text, $parameters) {            

  $censor = new \Snipe\BanBuilder\CensorWords;
  $langs = array('it');
  $badwords = $censor->setDictionary($langs);
  $string = $censor->censorString($text);

  return sizeof( $string[ 'matched' ] ) <= 0;
});

Is the only solution increase the maximum execution time allowed?

stefanoortisi commented 8 years ago

I found the problem: if I run PHP 7.0 the scripts doesn't complete and gets the maximum execution time error. If I run PHP <= 5.6, the scripts does work fine.