Hello guys,
I‘m not sure, if this issue was solved before?
I have a lot of old posts / wiki articles using titles like …
#test ##test ###test
As you might know, a few versions earlier this year, someone changed the behavior how to interpret these titles. Currently, the output isn’t one of these shiny markdown titles with bold text …
test
… instead, it‘s just …
#text
##test
###test
How can I automatically fix this issue for all old articles and add the missing space between the hashtags and title text?
Will need to figure out how it came to be before it can be fixed.
If you have the Data Explorer plug-in installed that might help in figuring out what happened. You could also check out the Action Logs for the OP to see if it had been put into needs approval / Akismet queues, Flagged etc.
(1) may I ask you: How do I use the data explorer? I‘ve never been worked with it before. Which queries can I use to identify the issue?
(2) Action log: Which events are suspicious?
(3) Akismet: Nothing in the queue.
(4) Console output: Why are you thinking there is a post without topic? I didn’t read anything like that? Why is the rake task saying the first method „acting_user“ is undefined?
The way I use the Data Explorer plugin is I have a query named “test” that I use for “alpha” queries and when I find one I like rename it to something more descriptive and save it then create another “test”.
To the right of the input area there is a list of Discourse tables. They can be expanded to show field names with their data types.
I have limited experience with different databases, so my SQL isn’t so bad. But I still check the postgreSQL documentation often
IMHO the plugin does a great job of letting you know when something is wrong with the query syntax. And it has safety built in in case you run a resource hungry query. However, similar to poor regex, you need to get things right. As an analogy, if you tell it “I wants watere” it will give you “plural used incorrectly, no such thing as watere” messages, but if you tell it “I want water” when you want bread, it will happily give you water.
I’m in the habit of explicitly SELECTing the fields I want so I don’t know if the “*” wildcard will work, but it may. eg.
SELECT COUNT(id)
FROM posts
WHERE topic_id IS NULL
When I try to open them, I‘m getting the message: The site ist not existing or private. And nearly everyone has <p>...</p> in common. That‘s intressting, cause I‘ve never put html code into these posts.
What is the best option:
Can I recover / repair them? It seems the content is still available.
If not, how can I delete them manually / automatically?
Now you only have the one problem left… You have a post, or posts, that have incorrect topic_id field set to a number that doesn’t correspond to a valid topic, or a topic that is abnormal.
If the topic_id is invalid, then you have data inconsistencies in your database, which may trip up your other stuff in the future. You really need to get to the bottom of this.
If the topic_id points to a valid topic, then it is simply something that the rake task hasn’t handled, which is safe.
Your screenshot gives the impression that only “About the category” topics are affected. Did you delete them at some point in time? I just gave it a try and it looks like deleting those topics isn’t possible anymore. Maybe it was in the past and there was a bug…
If you really want those posts gone, you could delete them in the Rails console (rails c inside the Docker container). This should work:
Post.where("NOT EXISTS (SELECT 1 FROM topics WHERE posts.topic_id = topics.id)").delete_all
No, it’s definitely not a problem with the rake task. The referenced topic IDs simply do not exist anymore.