mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
Store current date and time when deleting comments
Instead of modifying EditedTS when a comment is deleted, use a separate field DelTS. Use this field to determine whether a comment has been deleted, instead of checking DelUsersID which might be unset when the corresponding user is deleted. Fixes FS#47362. Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
This commit is contained in:
parent
9abd44671d
commit
51407d4a29
4 changed files with 36 additions and 22 deletions
|
@ -21,7 +21,7 @@ function pkgbase_comments_count($base_id, $include_deleted, $only_pinned=false)
|
|||
$q = "SELECT COUNT(*) FROM PackageComments ";
|
||||
$q.= "WHERE PackageBaseID = " . $base_id . " ";
|
||||
if (!$include_deleted) {
|
||||
$q.= "AND DelUsersID IS NULL";
|
||||
$q.= "AND DelTS IS NULL";
|
||||
}
|
||||
if ($only_pinned) {
|
||||
$q.= "AND NOT PinnedTS = 0";
|
||||
|
@ -53,7 +53,7 @@ function pkgbase_comments($base_id, $limit, $include_deleted, $only_pinned=false
|
|||
|
||||
$dbh = DB::connect();
|
||||
$q = "SELECT PackageComments.ID, A.UserName AS UserName, UsersID, Comments, ";
|
||||
$q.= "PackageBaseID, CommentTS, EditedTS, B.UserName AS EditUserName, ";
|
||||
$q.= "PackageBaseID, CommentTS, DelTS, EditedTS, B.UserName AS EditUserName, ";
|
||||
$q.= "DelUsersID, C.UserName AS DelUserName, ";
|
||||
$q.= "PinnedTS FROM PackageComments ";
|
||||
$q.= "LEFT JOIN Users A ON PackageComments.UsersID = A.ID ";
|
||||
|
@ -62,7 +62,7 @@ function pkgbase_comments($base_id, $limit, $include_deleted, $only_pinned=false
|
|||
$q.= "WHERE PackageBaseID = " . $base_id . " ";
|
||||
|
||||
if (!$include_deleted) {
|
||||
$q.= "AND DelUsersID IS NULL ";
|
||||
$q.= "AND DelTS IS NULL ";
|
||||
}
|
||||
if ($only_pinned) {
|
||||
$q.= "AND NOT PinnedTS = 0 ";
|
||||
|
@ -918,7 +918,7 @@ function pkgbase_delete_comment() {
|
|||
if (can_delete_comment($comment_id)) {
|
||||
$q = "UPDATE PackageComments ";
|
||||
$q.= "SET DelUsersID = ".$uid.", ";
|
||||
$q.= "EditedTS = UNIX_TIMESTAMP() ";
|
||||
$q.= "DelTS = UNIX_TIMESTAMP() ";
|
||||
$q.= "WHERE ID = ".intval($comment_id);
|
||||
$dbh->exec($q);
|
||||
return array(true, __("Comment has been deleted."));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue