-
Notifications
You must be signed in to change notification settings - Fork 193
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
Remove the publishing step when trying to republish HTML attachments for unpublished documents #8780
Remove the publishing step when trying to republish HTML attachments for unpublished documents #8780
Conversation
94af7ed
to
bc60706
Compare
…for unpublished documents The publishing of the HTML attachment could leave the document in a bad state and especially dangerous around sensitive documents where they should be unpublished, but are then inadvertently published during the republishing process. We should be able to reapply the redirects for unpublishing without the need to publish the document first. Withdrawn document process has been left as is for the moment.
bc60706
to
630ab47
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few comments for your consideration - sorry we didn't get a chance to pair on this as there is definitely enough complexity in this small PR to warrant it. Maybe let's jump on a call to discuss. Pretty sure everything is correct anyway but just want to confirm my understanding.
unpublish_if_required | ||
if Edition::PRE_PUBLICATION_STATES.include?(edition.state) | ||
update_draft(update_type: "republish") | ||
elsif edition.unpublishing && edition.withdrawn? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would just edition.withdrawn?
be sufficient? I don't think you can have a withdrawn edition without an unpublishing... 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yup I can apply this
do_publish("republish") | ||
discard_drafts(deleted_html_attachments) | ||
withdraw | ||
elsif edition.unpublishing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similarly we could use edition.unpublished?
here, I think
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yup I can apply this
publication = create(:unpublished_publication_in_error_no_redirect) | ||
PublishingApiWorker.any_instance.expects(:perform).never | ||
call(publication) | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm personally not a huge fan of tests that test something doesn't happen, or at least not beyond an initial TDD cycle. Theoretically the set of things we could test don't happen is infinite so I always feel a bit dubious about it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In a documentation sense that we explicitly want to call out that publishing "should not" happen, then I think it should be tested for things that we definitely do not want to happen otherwise bad things happen. To prevent in the future if people do add that functionality back in, they can see the test and thing "hmm do i really want to do this"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair enough, I don't feel too strongly about it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll feel a good bit safer once this is deployed 🚀
Up to you if you want to do anything with the conditionals, I don't feel strongly about those either
From further discussion in chats with @ryanb-gds, I think it would be good to merge this as is without the conditionals refactor to check state of edition instead of looking at the unpublishing association. We can have that done separately in another PR case it does have an impact |
The publishing of the HTML attachment could leave the document in a bad state and especially dangerous around sensitive documents where they should be unpublished, but are then inadvertently published during the republishing process.
We should be able to reapply the redirects for unpublishing without the need to publish the document first.
Withdrawn document process has been left as is for the moment.
https://trello.com/c/e75Mp1Ap/2301-investigate-if-we-can-avoid-temporary-publishing-of-html-attachments-during-republishing-of-unpublished-edition
Follow these steps if you are doing a Rails upgrade.