Item12629: add a flag to suppress auto-update of spam patterns

pencil
Priority: Normal
Current State: Closed
Released In: n/a
Target Release:
Applies To: Extension
Component: AntiWikiSpamPlugin
Branches: trunk
Reported By: MichaelDaum
Waiting For:
Last Change By: GeorgeClark
Currently, the plugin checks the remote site for updates to the spam patterns before saving a topic or uploading an attachment. This might result in these actions to time out when the site is temporarily disconnected from the internet or the remote site is down for some other reasons.

Instead, it would be nice to only perform these automatic maintenance steps offline using a cron job.

The patch below disables the calls to _downloadRegexUpdate() in the critical code paths. Either that or the plugin should provide a switch to disable these calls.

Here's the intended change:

New config param:

# **BOOLEAN**
# Enable automatic maintenance of spam signatures. You will need to install a cronjob to update
# spam signatures regularly (See the documentation).
# *WARNING*: As the update process happens as part of a save or upload action downloading and merging
# signatures could cause timeouts and failures of operation. Please only enable when maintenance using
# a cronjob isn't possible.
$Foswiki::cfg{Plugins}{AntiWikiSpamPlugin}{AutoUpdateSignatures} = $FALSE;

And its use:

--- lib/Foswiki/Plugins/AntiWikiSpamPlugin/Core.pm      (revision 17040)
+++ lib/Foswiki/Plugins/AntiWikiSpamPlugin/Core.pm      (working copy)
@@ -26,7 +26,7 @@
     _getPluginPrefs();    # Process preference settings for the plugin
 
     _writeDebug("beforeSaveHandler( $_[2].$_[1] ) ");
-    _downloadRegexUpdate();
+    _downloadRegexUpdate() if $Foswiki::cfg{Plugins}{AntiWikiSpamPlugin}{AutoUpdateSignatures};
     $hits = 0;
     _checkText( $_[2], $_[1], $_[0] );
     return;
@@ -65,7 +65,7 @@
         }
     }
 
-    _downloadRegexUpdate();
+    _downloadRegexUpdate() if $Foswiki::cfg{Plugins}{AntiWikiSpamPlugin}{AutoUpdateSignatures};
     $hits = 0;
     _checkText( $_[2], $_[1], $text );
     return;

-- MichaelDaum - 04 Nov 2013

 
Topic revision: r6 - 25 Apr 2014, GeorgeClark - This page was cached on 25 Jul 2016 - 22:07.

The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License