Manually bump the post_edited field.

This commit is contained in:
flash 2018-12-30 18:23:55 +01:00
parent e1e84c43c0
commit cbca1911cb
2 changed files with 25 additions and 2 deletions

View file

@ -0,0 +1,20 @@
<?php
namespace Misuzu\DatabaseMigrations\RevertAutoEditMark;
use PDO;
function migrate_up(PDO $conn): void
{
$conn->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`;
");
}

View file

@ -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();
}