[aur-dev] [PATCH 1/2] Create missing foreign key for comments
Signed-off-by: Marcel Korpel <marcel.korpel@gmail.com> --- schema/aur-schema.sql | 1 + 1 file changed, 1 insertion(+) diff --git a/schema/aur-schema.sql b/schema/aur-schema.sql index 3aef7a3..444cb5e 100644 --- a/schema/aur-schema.sql +++ b/schema/aur-schema.sql @@ -261,6 +261,7 @@ CREATE TABLE PackageComments ( INDEX (UsersID), INDEX (PackageBaseID), FOREIGN KEY (UsersID) REFERENCES Users(ID) ON DELETE SET NULL, + FOREIGN KEY (EditedUsersID) REFERENCES Users(ID) ON DELETE SET NULL, FOREIGN KEY (DelUsersID) REFERENCES Users(ID) ON DELETE CASCADE, FOREIGN KEY (PackageBaseID) REFERENCES PackageBases(ID) ON DELETE CASCADE ) ENGINE = InnoDB; -- 2.4.5
Signed-off-by: Marcel Korpel <marcel.korpel@gmail.com> --- upgrading/4.1.0.txt | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 upgrading/4.1.0.txt diff --git a/upgrading/4.1.0.txt b/upgrading/4.1.0.txt new file mode 100644 index 0000000..7862030 --- /dev/null +++ b/upgrading/4.1.0.txt @@ -0,0 +1,9 @@ +1. Add a timestamp for comment editing/deletion and an ID of the last user +who edited a comment: + +---- +ALTER TABLE PackageComments + ADD COLUMN EditedTS BIGINT UNSIGNED NULL DEFAULT NULL, + ADD COLUMN EditedUsersID INTEGER UNSIGNED NULL DEFAULT NULL, + ADD FOREIGN KEY (EditedUsersID) REFERENCES Users(ID) ON DELETE SET NULL; +---- -- 2.4.5
Due to the use of html_format_username() the username was set to "None" if the user was deleted, causing the condition of an empty username never being met. Fixed with an extra variable that stores the formatted username. Signed-off-by: Marcel Korpel <marcel.korpel@gmail.com> --- web/template/pkg_comments.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/web/template/pkg_comments.php b/web/template/pkg_comments.php index e86db3b..3c2db72 100644 --- a/web/template/pkg_comments.php +++ b/web/template/pkg_comments.php @@ -17,13 +17,13 @@ $count = pkgbase_comments_count($base_id, $include_deleted); <?php while (list($indx, $row) = each($comments)): ?> <?php - $row['UserName'] = html_format_username($row['UserName']); + $formatted_username = html_format_username($row['UserName']); $row['DelUserName'] = html_format_username($row['DelUserName']); $row['EditUserName'] = html_format_username($row['EditUserName']); ?> <h4 id="comment-<?= $row['ID'] ?>"<?php if ($row['DelUsersID']): ?> class="comment-deleted"<?php endif; ?>> <?php if ($row['UserName']): ?> - <?= __('%s commented', $row['UserName']) ?> + <?= __('%s commented', $formatted_username) ?> <?php else: ?> <?= __('Anonymous comment') ?> <?php endif; ?> -- 2.4.5
participants (1)
-
Marcel Korpel