You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spamassassin.apache.org by he...@apache.org on 2022/05/02 14:56:24 UTC

svn commit: r1900481 - in /spamassassin/trunk: lib/Mail/SpamAssassin/Plugin/DecodeShortURLs.pm sql/decodeshorturl_mysql.sql sql/decodeshorturl_pg.sql

Author: hege
Date: Mon May  2 14:56:24 2022
New Revision: 1900481

URL: http://svn.apache.org/viewvc?rev=1900481&view=rev
Log:
Fix logic: Compare TTL to created field, otherwise entry might not never expire and update itself.

Modified:
    spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/DecodeShortURLs.pm
    spamassassin/trunk/sql/decodeshorturl_mysql.sql
    spamassassin/trunk/sql/decodeshorturl_pg.sql

Modified: spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/DecodeShortURLs.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/DecodeShortURLs.pm?rev=1900481&r1=1900480&r2=1900481&view=diff
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/DecodeShortURLs.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/DecodeShortURLs.pm Mon May  2 14:56:24 2022
@@ -379,7 +379,7 @@ sub initialise_url_shortener_cache {
       # Maintaining index for cleaning is likely more expensive than occasional full table scan
       #$self->{dbh}->do("
       #  CREATE INDEX IF NOT EXISTS short_url_modified
-      #    ON short_url_cache(modified)
+      #    ON short_url_cache(created)
       #");
       $self->{sth_insert} = $self->{dbh}->prepare("
         INSERT INTO short_url_cache (short_url, decoded_url, created, modified)
@@ -391,11 +391,11 @@ sub initialise_url_shortener_cache {
       ");
       $self->{sth_select} = $self->{dbh}->prepare("
         SELECT decoded_url FROM short_url_cache
-        WHERE short_url = ? AND modified >= strftime('%s','now') - $conf->{url_shortener_cache_ttl}
+        WHERE short_url = ? AND created >= strftime('%s','now') - $conf->{url_shortener_cache_ttl}
       ");
       $self->{sth_delete} = $self->{dbh}->prepare("
         DELETE FROM short_url_cache
-        WHERE modified < strftime('%s','now') - $conf->{url_shortener_cache_ttl}
+        WHERE created < strftime('%s','now') - $conf->{url_shortener_cache_ttl}
       ");
     };
     if ($@) {
@@ -431,11 +431,11 @@ sub initialise_url_shortener_cache {
       ");
       $self->{sth_select} = $self->{dbh}->prepare("
         SELECT decoded_url FROM short_url_cache
-        WHERE short_url = ? AND modified >= UNIX_TIMESTAMP() - $conf->{url_shortener_cache_ttl}
+        WHERE short_url = ? AND created >= UNIX_TIMESTAMP() - $conf->{url_shortener_cache_ttl}
       ");
       $self->{sth_delete} = $self->{dbh}->prepare("
         DELETE FROM short_url_cache
-        WHERE modified < UNIX_TIMESTAMP() - $conf->{url_shortener_cache_ttl}
+        WHERE created < UNIX_TIMESTAMP() - $conf->{url_shortener_cache_ttl}
       ");
     };
     if ($@) {
@@ -471,11 +471,11 @@ sub initialise_url_shortener_cache {
       ");
       $self->{sth_select} = $self->{dbh}->prepare("
         SELECT decoded_url FROM short_url_cache
-        WHERE short_url = ? AND modified >= CAST(EXTRACT(epoch FROM NOW()) AS INT) - $conf->{url_shortener_cache_ttl}
+        WHERE short_url = ? AND created >= CAST(EXTRACT(epoch FROM NOW()) AS INT) - $conf->{url_shortener_cache_ttl}
       ");
       $self->{sth_delete} = $self->{dbh}->prepare("
         DELETE FROM short_url_cache
-        WHERE modified < CAST(EXTRACT(epoch FROM NOW()) AS INT) - $conf->{url_shortener_cache_ttl}
+        WHERE created < CAST(EXTRACT(epoch FROM NOW()) AS INT) - $conf->{url_shortener_cache_ttl}
       ");
     };
     if ($@) {

Modified: spamassassin/trunk/sql/decodeshorturl_mysql.sql
URL: http://svn.apache.org/viewvc/spamassassin/trunk/sql/decodeshorturl_mysql.sql?rev=1900481&r1=1900480&r2=1900481&view=diff
==============================================================================
--- spamassassin/trunk/sql/decodeshorturl_mysql.sql (original)
+++ spamassassin/trunk/sql/decodeshorturl_mysql.sql Mon May  2 14:56:24 2022
@@ -7,4 +7,4 @@ CREATE TABLE `short_url_cache`
   PRIMARY KEY (`short_url`)
 ) ENGINE = InnoDB;
 -- Maintaining index for cleaning is likely more expensive than occasional full table scan
--- ALTER TABLE `short_url_cache` ADD INDEX `short_url_modified` (`modified`);
+-- ALTER TABLE `short_url_cache` ADD INDEX `short_url_created` (`created`);

Modified: spamassassin/trunk/sql/decodeshorturl_pg.sql
URL: http://svn.apache.org/viewvc/spamassassin/trunk/sql/decodeshorturl_pg.sql?rev=1900481&r1=1900480&r2=1900481&view=diff
==============================================================================
--- spamassassin/trunk/sql/decodeshorturl_pg.sql (original)
+++ spamassassin/trunk/sql/decodeshorturl_pg.sql Mon May  2 14:56:24 2022
@@ -7,4 +7,4 @@ CREATE TABLE short_url_cache (
   PRIMARY KEY (short_url)
 );
 -- Maintaining index for cleaning is likely more expensive than occasional full table scan
--- ALTER TABLE short_url_cache ADD INDEX short_url_modified (modified);
+-- ALTER TABLE short_url_cache ADD INDEX short_url_created (created);