Fix over-eager deletion with drafts.

Review Request #13905 — Created May 28, 2024 and submitted

Information

Review Board
release-7.x

Reviewers

When I added change descriptions and diffsets to the draft deletion
handler, I wasn't thinking about how we delete the draft after
publishing it. In that case, we've assigned the change description to
the review request, and assigned the diffset to the history, but we
haven't cleared them from the draft object. We were therefore deleting
the data right after we published it.

This change fixes that up to properly check that those objects are no
longer alive.

Unit tests have been added for this case with both of those as well as
file attachments, which didn't have this same problem because of the way
we calculate the file attachment state.

  • Ran unit tests.
  • Published a new review request that included a diff and saw that my
    diff wasn't immediately deleted.
Summary ID
Fix over-eager deletion with drafts.
When I added change descriptions and diffsets to the draft deletion handler, I wasn't thinking about how we delete the draft after publishing it. In that case, we've assigned the change description to the review request, and assigned the diffset to the history, but we haven't cleared them from the draft object. We were therefore deleting the data right after we published it. This change fixes that up to properly check that those objects are no longer alive. Unit tests have been added for this case with both of those as well as file attachments, which didn't have this same problem because of the way we calculate the file attachment state. Testing Done: - Ran unit tests. - Published a new review request that included a diff and saw that my diff wasn't immediately deleted.
59a8cb95c50660ade1ba03302d3c9c0e5b8bd46d
Description From Last Updated

Might as well pull out changedesc here too.

maubinmaubin

Can you pull the diffset out into a local variable? It'll help this read better, and avoids the expense of …

chipx86chipx86

line break before binary operator Column: 9 Error code: W503

reviewbotreviewbot
Checks run (1 failed, 1 succeeded)
flake8 failed.
JSHint passed.

flake8

chipx86
  1. 
      
  2. reviewboard/reviews/signal_handlers.py (Diff revision 1)
     
     
     
     
     
    Show all issues

    Can you pull the diffset out into a local variable? It'll help this read better, and avoids the expense of attribute lookups on models.

    Plus that operator Review Bot complained about.

  3. 
      
maubin
  1. 
      
  2. reviewboard/reviews/signal_handlers.py (Diff revision 1)
     
     
     
    Show all issues

    Might as well pull out changedesc here too.

  3. 
      
david
chipx86
  1. Ship It!
  2. 
      
maubin
  1. Ship It!
  2. 
      
david
Review request changed
Status:
Completed
Change Summary:
Pushed to release-7.x (84c4fe9)