wp-kumonosu のAkismet filter が利いてない

2007年9月19日

WordPress を 2.1.x 系統にアップグレードした際に、同梱のAkismet プラグインが2.x にバージョンアップしたせいか、wp-kumonosu のAkismet filter が動作しなくなっていることに頭を悩ませていました。

一念発起、ソースを追ってみたら、wp-kumonosu 0.48 内の関数kumonosu_akismet_filter にて、Akismet プラグインの中にすでに存在しない関数ksd_auto_check_comment を呼び出しているのが問題の模様。関数の存在チェックで常にfalse が返る訳なので、その後のAkismet filter は動作しようがない、のかな?
同等の動作をするっぽい関数akismet_auto_check_comment をakismet.php 内で見つけたので、これを利用すればいいのかな?

ということで、投げやりなパッチ

 $ diff -c wp-kumonosu.php.org wp-kumonosu.php
*** wp-kumonosu.php.org 2007-04-18 17:35:00.000000000 +0900
--- wp-kumonosu.php     2007-04-18 17:34:41.000000000 +0900
***************
*** 904,916 ****
  }
  
  add_action('preprocess_comment', 'kumonosu_akismet_filter', 1);
! if(function_exists('ksd_auto_check_comment')) {
!       remove_action('preprocess_comment', 'ksd_auto_check_comment', 1);
  }
  
  function kumonosu_akismet_filter($comment) {
        
!       if(!function_exists('ksd_auto_check_comment'))
                return $comment;
        
        $wpKumonosu = & new WpKumonosu();
--- 904,916 ----
  }
  
  add_action('preprocess_comment', 'kumonosu_akismet_filter', 1);
! if(function_exists('akismet_auto_check_comment')) {
!       remove_action('preprocess_comment', 'akismet_auto_check_comment', 1);
  }
  
  function kumonosu_akismet_filter($comment) {
        
!       if(!function_exists('akismet_auto_check_comment'))
                return $comment;
        
        $wpKumonosu = & new WpKumonosu();
***************
*** 926,932 ****
        }
        
        if($do_akismet) {
!               $comment = ksd_auto_check_comment($comment);
        }
        
        return $comment;
--- 926,932 ----
        }
        
        if($do_akismet) {
!               $comment = akismet_auto_check_comment($comment);
        }
        
        return $comment;

自サイト内のTrackback はしっかりとデバッグログに記録されていたから、動作するようになったのは間違いなさそうですが、しばらくはこれで様子見です。