? .kdev4
? 719616-flag-anonymous_cleanup.patch
? 719616-flag-anonymous_cleanup.patch.1
? 719616-flag-count.patch
? 798152-flag_comment_link.patch
? 813342-flag-anonymous_cleanup.patch
? flag-DRUPAL-6--2.kdev4
? flag-devel_generate.patch
Index: flag.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/flag/flag.inc,v
retrieving revision 1.1.2.30.2.25
diff -u -p -r1.1.2.30.2.25 flag.inc
--- flag.inc	10 May 2010 04:05:28 -0000	1.1.2.30.2.25
+++ flag.inc	30 May 2010 16:27:46 -0000
@@ -198,6 +198,7 @@ class flag_flag {
         'flag' => array(DRUPAL_AUTHENTICATED_RID),
         'unflag' => array(DRUPAL_AUTHENTICATED_RID),
       ),
+      'session_api_cleanup' => TRUE,
     );
 
     // Merge in options from the current link type.
Index: flag.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/flag/flag.module,v
retrieving revision 1.11.2.72.2.40
diff -u -p -r1.11.2.72.2.40 flag.module
--- flag.module	10 May 2010 04:05:28 -0000	1.11.2.72.2.40
+++ flag.module	30 May 2010 16:27:46 -0000
@@ -522,17 +522,26 @@ function flag_user($op, &$edit, &$accoun
  * Clear out anonymous user flaggings during Session API cleanup.
  */
 function flag_session_api_cleanup($arg = 'run') {
+  // Get all flags which should be truncated.
+  $flags = flag_get_flags();
+  $fids = array();
+  foreach ($flags as $flag) {
+    if (!empty($flag->session_api_cleanup)) {
+      $fids[] = $flag->fid;
+    }
+  }
+
   // Session API 1.1 version:
   if ($arg == 'run') {
     $result = db_query("SELECT fc.sid FROM {flag_content} fc LEFT JOIN {session_api} s ON (fc.sid = s.sid) WHERE fc.sid <> 0 AND s.sid IS NULL");
     while ($row = db_fetch_object($result)) {
-      db_query("DELETE FROM {flag_content} WHERE sid = %d", $row->sid);
+      db_query('DELETE FROM {flag_content} WHERE sid = %d AND fid IN (' . implode(',', $fids) . ')', $row->sid);
     }
   }
   // Session API 1.2+ version.
   elseif (is_array($arg)) {
     $outdated_sids = $arg;
-    db_query('DELETE FROM {flag_content} WHERE sid IN (' . implode(',', $outdated_sids) . ')');
+    db_query('DELETE FROM {flag_content} WHERE sid IN (' . implode(',', $outdated_sids) . ') AND fid IN (' . implode(',', $fids) . ')');
   }
 }
 
