/[drupal]/contributions/modules/akismet/akismet_cron.inc
ViewVC logotype

Diff of /contributions/modules/akismet/akismet_cron.inc

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.4 by drewish, Fri Jun 1 21:41:17 2007 UTC revision 1.5 by drewish, Mon Mar 24 23:31:16 2008 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id: akismet_cron.inc,v 1.3 2006/12/31 23:49:25 eaton Exp $  // $Id: akismet_cron.inc,v 1.4 2007/06/01 21:41:17 drewish Exp $
3    
4  /**  /**
5   * Shutdown function executed at cron time.   * Shutdown function executed at cron time.
6   */   */
7  function akismet_cron_shutdown() {  function akismet_cron_shutdown() {
8    watchdog('cron', t('Akismet cron started at %time.', array('%time' => format_date(time(), 'custom', 'H:i:s'))));    watchdog('cron', 'Akismet cron started at %time.', array('%time' => format_date(time(), 'custom', 'H:i:s')));
9    
10    // Expired content spam that we have to remove from each content repository.    // Expired content spam that we have to remove from each content repository.
11    $expired_content_spam = array('nids'=>array(), 'cids'=>array());    $expired_content_spam = array('nids'=>array(), 'cids'=>array());
# Line 15  function akismet_cron_shutdown() { Line 15  function akismet_cron_shutdown() {
15    // Retrieve the list of expired content spam, based on the age specified in the settings panel.    // Retrieve the list of expired content spam, based on the age specified in the settings panel.
16    $expire_spam_age = variable_get('akismet_remove_spam_age', 259200);    $expire_spam_age = variable_get('akismet_remove_spam_age', 259200);
17    if ($expire_spam_age > 0) {    if ($expire_spam_age > 0) {
18      $result = db_query('SELECT content_type, content_id FROM {akismet_spam_marks} WHERE spam_created < %d', time() - $expire_spam_age);      $result = db_result(db_query('SELECT content_type, content_id FROM {akismet_spam_marks} WHERE spam_created < %d', time() - $expire_spam_age));
19      if (db_num_rows($result)) {      while ($s = db_fetch_object($result)) {
20        while ($s = db_fetch_object($result)) {        $key = ($s->content_type == 'node' ? 'nids' : 'cids');
21          $key = ($s->content_type == 'node' ? 'nids' : 'cids');        $expired_content_spam[$key][] = $s->content_id;
22          $expired_content_spam[$key][] = $s->content_id;        $obsolete_spam_marks[$key][] = $s->content_id;
         $obsolete_spam_marks[$key][] = $s->content_id;  
       }  
23      }      }
24    }    }
25    
# Line 30  function akismet_cron_shutdown() { Line 28  function akismet_cron_shutdown() {
28    // so that may lead to orphans in the 'spam marks' table.    // so that may lead to orphans in the 'spam marks' table.
29    // This is why this cron task is being more complex that it could really be. Anyway, these    // This is why this cron task is being more complex that it could really be. Anyway, these
30    // queries shouldn't be too heavy.    // queries shouldn't be too heavy.
31    $result = db_query('SELECT s.content_id FROM {akismet_spam_marks} s LEFT JOIN {node} n ON s.content_id = n.nid WHERE s.content_type = \'node\' AND n.nid IS NULL');    $result = db_result(db_query('SELECT s.content_id FROM {akismet_spam_marks} s LEFT JOIN {node} n ON s.content_id = n.nid WHERE s.content_type = \'node\' AND n.nid IS NULL'));
32    if (db_num_rows($result)) {    while ($s = db_fetch_object($result)) {
33      while ($s = db_fetch_object($result)) {      if (!in_array($s->content_id, $obsolete_spam_marks['nids'])) {
34        if (!in_array($s->content_id, $obsolete_spam_marks['nids'])) {        $obsolete_spam_marks['nids'][] = $s->content_id;
         $obsolete_spam_marks['nids'][] = $s->content_id;  
       }  
35      }      }
36    }    }
37    $result = db_query('SELECT s.content_id FROM {akismet_spam_marks} s LEFT JOIN {comments} c ON s.content_id = c.cid WHERE s.content_type = \'comment\' AND c.cid IS NULL');    $result = db_result(db_query('SELECT s.content_id FROM {akismet_spam_marks} s LEFT JOIN {comments} c ON s.content_id = c.cid WHERE s.content_type = \'comment\' AND c.cid IS NULL'));
38    if (db_num_rows($result)) {    while ($s = db_fetch_object($result)) {
39      while ($s = db_fetch_object($result)) {      if (!in_array($s->content_id, $obsolete_spam_marks['cids'])) {
40        if (!in_array($s->content_id, $obsolete_spam_marks['cids'])) {        $obsolete_spam_marks['cids'][] = $s->content_id;
         $obsolete_spam_marks['cids'][] = $s->content_id;  
       }  
41      }      }
42    }    }
43    
# Line 115  function akismet_cron_shutdown() { Line 109  function akismet_cron_shutdown() {
109    if ($clear_cache) {    if ($clear_cache) {
110      akismet_clear_cache();      akismet_clear_cache();
111    }    }
112    watchdog('cron', t('Akismet cron completed at %time.', array('%time' => format_date(time(), 'custom', 'H:i:s'))));    watchdog('cron', 'Akismet cron completed at %time.', array('%time' => format_date(time(), 'custom', 'H:i:s')));
113  }  }

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.5

  ViewVC Help
Powered by ViewVC 1.1.3