Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix deleted milestone bug #1942

Merged
merged 3 commits into from
Jun 17, 2017
Merged

Conversation

ethantkoenig
Copy link
Member

@ethantkoenig ethantkoenig commented Jun 12, 2017

Fixes a bug where viewing an issue from a deleted milestone resulted in a 500 (because comments from that issue would still refer to the deleted milestone, which gitea would then try to load).

When deleting a milestone, delete all comments referencing that milestone.
Introduce "ghost" milestones (similar to "ghost" users) to fix the problem.

@lunny lunny added this to the 1.2.0 milestone Jun 12, 2017
@lunny lunny added the type/bug label Jun 12, 2017
@lunny
Copy link
Member

lunny commented Jun 14, 2017

Why delete these comments? Maybe just set milestone_id to zero?

@tboerger tboerger added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Jun 14, 2017
@ethantkoenig
Copy link
Member Author

@lunny Setting MilestoneID to 0 won't fix the problem, as long as the comment exists, we will try to load milestone comment.MilestoneID and get an error

@bkcsoft
Copy link
Member

bkcsoft commented Jun 15, 2017

Just don't load the milestones instead? 😖 Deleting all comments on issue where the milestone doesn't exist is not the solution...

@bkcsoft
Copy link
Member

bkcsoft commented Jun 15, 2017

Why does the comments even link to milestones in the first place?! 😂

@ethantkoenig
Copy link
Member Author

ethantkoenig commented Jun 15, 2017

To be clear, the "comments" that are being deleted are not comments that users write, but instead things like
image

The comments table contains both "normal" comments that users write, and notification-like things (milestone add/removed, label add/removed, etc.). This only removes the notification-like things referencing deleted milestones.

@bkcsoft
Copy link
Member

bkcsoft commented Jun 15, 2017

Right, personally I'd just replace 1.2.0 with <deleted> (or similar) whenever we can't find the milestone we're looking for (similar to a Ghost User)

@ethantkoenig
Copy link
Member Author

@lunny @bkcsoft Updated to use "ghost" milestones instead of deleting comments.

@lafriks
Copy link
Member

lafriks commented Jun 15, 2017

When build is fixed than LG-TM

@ethantkoenig
Copy link
Member Author

Rebased to re-run CI

func NewGhostMilestone() *Milestone {
return &Milestone{
ID: -1,
Name: "Deleted",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be translatable

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@ethantkoenig
Copy link
Member Author

ethantkoenig commented Jun 15, 2017

FWIW, we currently set comments' LabelID field to 0 when a label is deleted, which is effectively equivalent to deleting the comment (the comment is never displayed again).

@ethantkoenig
Copy link
Member Author

CI build keeps failing due to locking in make test-sqlite 😢

@lunny
Copy link
Member

lunny commented Jun 16, 2017

@ethantkoenig I restarted it and LGTM

@tboerger tboerger added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Jun 16, 2017
@@ -228,28 +228,22 @@ func (c *Comment) LoadLabel() error {
func (c *Comment) LoadMilestone() error {
if c.OldMilestoneID > 0 {
var oldMilestone Milestone
has, err := x.ID(c.OldMilestoneID).Get(&oldMilestone)
has, err := x.ID(c.OldMilestoneID).Get(oldMilestone)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be &oldMilestone

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lunny Fixed

@lafriks
Copy link
Member

lafriks commented Jun 16, 2017

LGTM

@tboerger tboerger added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Jun 16, 2017
@lunny lunny merged commit 8fc6474 into go-gitea:master Jun 17, 2017
@ethantkoenig ethantkoenig deleted the fix/delete_milestone branch June 17, 2017 15:54
lunny pushed a commit to lunny/gitea that referenced this pull request Aug 13, 2017
* Fix deleted milestone bug

* Use locale for ghost milestone name

* Fix pointer bug
@lunny lunny added backport/done All backports for this PR have been created backport/v1.1 labels Aug 13, 2017
andreynering pushed a commit that referenced this pull request Aug 13, 2017
* Fix deleted milestone bug

* Use locale for ghost milestone name

* Fix pointer bug
@go-gitea go-gitea locked and limited conversation to collaborators Nov 23, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
backport/done All backports for this PR have been created lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. type/bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants