diff --git a/post.php b/post.php index a18633c3..16c6a71d 100644 --- a/post.php +++ b/post.php @@ -909,10 +909,14 @@ elseif (isset($_POST['post'])) { // Handle cyclical threads if (!$post['op'] && isset($thread['cycle']) && $thread['cycle']) { // Query is a bit weird due to "This version of MariaDB doesn't yet support 'LIMIT & IN/ALL/ANY/SOME subquery'" (MariaDB Ver 15.1 Distrib 10.0.17-MariaDB, for Linux (x86_64)) - $query = prepare(sprintf('DELETE FROM ``posts_%s`` WHERE `thread` = :thread AND `id` NOT IN (SELECT `id` FROM (SELECT `id` FROM ``posts_%s`` WHERE `thread` = :thread ORDER BY `id` DESC LIMIT :limit) i)', $board['uri'], $board['uri'])); + $query = prepare(sprintf('SELECT `id` FROM ``posts_%s`` WHERE `thread` = :thread AND `id` NOT IN (SELECT `id` FROM (SELECT `id` FROM ``posts_%s`` WHERE `thread` = :thread ORDER BY `id` DESC LIMIT :limit) i)', $board['uri'], $board['uri'])); $query->bindValue(':thread', $post['thread']); $query->bindValue(':limit', $config['cycle_limit'], PDO::PARAM_INT); $query->execute() or error(db_error($query)); + + while ($dpost = $query->fetch()) { + deletePost($dpost['id'], false, false); + } } if (isset($post['antispam_hash'])) {