FIXED?: Must refresh page to delete a post
-
Cleaning up after Paula, ran into this:
https://meta.discourse.org/t/must-refresh-page-to-delete-a-post/28191?u=boomzilla
I've found that sometimes I cannot delete a post in a topic until I refresh the page. This just happened to me here. Screenshot of chrome's (Linux, Version 42.0.2311.135 (64-bit)) console with the error:
-
It looks like there's a problem with the code we use to prevent deletes from happening in /t/1000:
//prevent delete of posts in the 1000 thread $("document").ready(function(){( function(){ var b=Discourse.PostMenuView.prototype.clickDelete, a=function(a){ if(1E3==a.topic_id) return $("#discourse-modal #modal-alert") .html( "<img style='padding:10px;' src='/uploads/default/8214/16c00f5bd6b57125.png'/>Press <kbd>ctrl + w</kbd> to delete anyway?"), $("#discourse-modal h3").html( "Please do not delete posts from the 1000 thread. Edit your post, or flag it for moderator attention to hide content. Thanks"), $("#discourse-modal").modal("show"),!1; b.apply(this,arguments)}; Discourse.PostMenuView.reopen({clickDelete:a}); Discourse.PostMenuView.prototype.clickDelete=a})()});
Seems like the
b.apply()
call errors out. Anyone have any ideas?
-
Calling this in
$("document").ready()
might be too early if last refresh was while not in a topic? Guessing here, I'm about to go to bed.If anyone wants to check this out overnight try plugging it into
Ember.View.Reopen
as a test? Sure it triggers damned often, but it would confirm or dispute this idea.Also, you might want to page @Monarch as well, he's very proficient with Ember hackery.
-
Also, you might want to page @Monarch as well, he's very proficient with Ember hackery.
I happened to write that code too ;) I wasn't able to produce an error by deleting a post in the 1000, tested on safari/mac
@boomzilla can you provide steps
-
This error happens outside of /t/1000. I notice it especially in article threads while cleaning up after Paula. But I've tested in other places, too.
-
Calling this in $("document").ready() might be too early if last refresh was while not in a topic? Guessing here, I'm about to go to bed.
Put the code, bare, in
</body>
(i.e., afterDiscourse.start()
). It should work then.
-
Well...now I'm getting this again. Same error.
I think this is the first time I've tried this post beta 9. Not completely sure.
-
I think your problem mentioned here:
Discourse won't let me delete either of these duplicate posts.
...is what this topic was about. Check your js console next time to see if you get the sort of errors I put in the OP. @riking had a suggestion that worked to make sure this thing was added at the right time, but a recent upgrade seems to have outsmarted him on that front.
Not sure what the solution is. We might just need to turn off the delete prevention and rely on users to notice someone trying to delete a post.
-
I forgot we even had that prevention.
Is there a point at which a deletion is not reversible - or can it always be reversed by someone with the right powers?
-
A moderator should be able to restore stuff. No post is actually deleted from the DB from what I've seen.
And it's actually easy for me or @PJH to use a backed up DB copy to look for something that got user-deleted way back in /t/1000.
-
No post is actually deleted from the DB from what I've seen.
It isn't - at least not through the software.
-
The only way through the UI to delete a record (for most tables) is to perform a restore.
-
Now that's some out of the box thinking.
-
-
More specifically...
- take & download a backup
- edit the backup files
- upload the modified backup
- restore the modified backup
Which does imply some level of malicious intent.
-
I was thinking to just restore to a backed up version before the post (edit, etc) was made. It's so much easier!