Note to WordPress plugin developers: use the
pre_comment_approved filter with caution if there is a chance that Akismet will be active on sites using your plugin.
There is a long standing bug in WordPress, which is that a self-referential call to
remove_filter breaks the filter — any functions that had been scheduled to run after the one being removed will not be called.
Unfortunately, this is exactly what Akismet does in the
akismet_result_spam function — it tries to remove its own hook. The result is that whenever Akismet identifies a comment as spam, any functions hooked to the
pre_comment_approved hook with priority greater than the default (10), will silently fail to execute.
As an aside, there are other, simpler ways to ensure that a function runs only once — static or class variables, for example.