diff --git a/database/2018_12_30_171344_revert_auto_edit_mark.php b/database/2018_12_30_171344_revert_auto_edit_mark.php new file mode 100644 index 00000000..f894236b --- /dev/null +++ b/database/2018_12_30_171344_revert_auto_edit_mark.php @@ -0,0 +1,20 @@ +exec(" + ALTER TABLE `msz_forum_posts` + CHANGE COLUMN `post_edited` `post_edited` TIMESTAMP NULL DEFAULT NULL AFTER `post_created`; + "); +} + +function migrate_down(PDO $conn): void +{ + $conn->exec(" + ALTER TABLE `msz_forum_posts` + CHANGE COLUMN `post_edited` `post_edited` TIMESTAMP NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP AFTER `post_created`; + "); +} diff --git a/src/Forum/post.php b/src/Forum/post.php index 43e0ba09..04357a39 100644 --- a/src/Forum/post.php +++ b/src/Forum/post.php @@ -27,7 +27,8 @@ function forum_post_update( int $postId, string $ipAddress, string $text, - int $parser = MSZ_PARSER_PLAIN + int $parser = MSZ_PARSER_PLAIN, + bool $bumpUpdate = true ): bool { if ($postId < 1) { return false; @@ -37,13 +38,15 @@ function forum_post_update( UPDATE `msz_forum_posts` SET `post_ip` = INET6_ATON(:post_ip), `post_text` = :post_text, - `post_parse` = :post_parse + `post_parse` = :post_parse, + `post_edited` = IF(:bump, NOW(), NULL) WHERE `post_id` = :post_id '); $updatePost->bindValue('post_id', $postId); $updatePost->bindValue('post_ip', $ipAddress); $updatePost->bindValue('post_text', $text); $updatePost->bindValue('post_parse', $parser); + $updatePost->bindValue('bump', $bumpUpdate ? 1 : 0); return $updatePost->execute(); }