diff --git a/Rocksolid_Light/rocksolid/lib/thread.inc.php b/Rocksolid_Light/rocksolid/lib/thread.inc.php index 0082ba9..b5969c5 100644 --- a/Rocksolid_Light/rocksolid/lib/thread.inc.php +++ b/Rocksolid_Light/rocksolid/lib/thread.inc.php @@ -95,16 +95,21 @@ function thread_cache_save($headers, $group) $database = $spooldir . '/' . $group . '-data.db3'; $table = "threads"; if ($dbh = threads_db_open($database, $table)) { - $drop = 'DROP TABLE IF EXISTS '. $table; + $drop = 'DROP TABLE IF EXISTS threads'; $drop_stmt = $dbh->prepare($drop); + $insert_sql = 'INSERT INTO ' . $table . '(headers) VALUES(?)'; + $insert_stmt = $dbh->prepare($insert_sql); + + $dbh->beginTransaction(); $drop_stmt->execute(); - $dbh = null; - $dbh = threads_db_open($database, $table); - $sql = 'INSERT INTO ' . $table . '(headers) VALUES(?)'; - $stmt = $dbh->prepare($sql); - $stmt->execute([ + $dbh->exec("CREATE TABLE IF NOT EXISTS $table( + id INTEGER PRIMARY KEY, + headers TEXT, + unique (headers))"); + $insert_stmt->execute([ serialize($headers) ]); + $dbh->commit(); $dbh = null; } } diff --git a/Rocksolid_Light/rocksolid/newsportal.php b/Rocksolid_Light/rocksolid/newsportal.php index 3cf3e6e..fe0b200 100644 --- a/Rocksolid_Light/rocksolid/newsportal.php +++ b/Rocksolid_Light/rocksolid/newsportal.php @@ -1498,8 +1498,6 @@ function threads_db_open($database, $table = "threads") id INTEGER PRIMARY KEY, headers TEXT, unique (headers))"); - $stmt = $dbh->query('CREATE INDEX IF NOT EXISTS id_headers on ' . $table . '(headers)'); - $stmt->execute(); return ($dbh); } @@ -1823,7 +1821,8 @@ function add_to_history($group, $number, $msgid, $status, $statusdate, $statusre $history_dbh = null; } -function clear_history_by_group($group) { +function clear_history_by_group($group) +{ global $spooldir; $history = $spooldir . '/history.db3'; $history_dbh = history_db_open($history);