לא ניתן למחוק נושא בלי קטגוריה

יש לי נושא במסד הנתונים שלנו עם category_id של קטגוריה שנמחקה על ידי מישהו. אני יכול לפתוח את הנושא הזה ישירות עם המזהה שלו:
url: …/t/3

בטבלת הנושאים (topics) למזהה (id) = 3 יש קטגוריה (category) = 4. אבל הקטגוריה הזו נמחקה ולא נמצאת בטבלת הקטגוריות (categories). הצלחתי למחוק הרבה מהנושאים האבודים האלה. אבל הנושא הזה לא עובד, מכיוון שהמאפיינים סגור (closed) וארכיון (archived) הם true.

אם אני בוחר בתפריט המוקפץ “מחק לצמיתות” (Permanently Delete) את הנושא הזה, אני מקבל הודעת שגיאה:
“אירעה שגיאה: לנושא זה יש פוסטים שלא נמחקו. נא למחוק אותם לצמיתות לפני מחיקת הנושא לצמיתות.” (An error occurred: This topic has undeleted posts. Please permanently delete them before permanently deleting the topic.)

יש רעיון איך להוסיף קטגוריה פיקטיבית עם מזהה 4 למסד הנתונים או למחוק את הנושא האבוד הזה?

I think that’s the About topic for the General category?. Normally the about topics would be undeletable in the UI.

Is there a reason you want to delete this one completely?

לייק 1

מכיוון שהקטגוריה הזו לא זמינה יותר, מה יותר חשוב: הקישור לכל הקטגוריות בסרגל הצדדי כבר לא עובד.
אם אני מנסה לפתוח …/categories אני מקבל הודעת שגיאה: “שגיאה משהו השתבש.” ובמסוף הדפדפן מוצגת הודעת שגיאה:

Uncaught TypeError: i is null
    reason binary.js:7
    l item.js:166
    get topic.js:1017
    ee upload.js:65
    get topic.js:1017
    get topic.js:1017
    eM topic.js:1017
    s backup-codes.js:33
    n backup-codes.js:33
    Z upload.js:65
    T backup-codes.js:33
    evaluate backup-codes.js:33
    _execute backup-codes.js:33
    execute backup-codes.js:33
    rerender backup-codes.js:33
    render theme-setting.js:6
    _renderRoots theme-setting.js:6
    tA backup-codes.js:33
    _renderRoots theme-setting.js:6
    _renderRootsTransaction theme-setting.js:6
    _revalidate theme-setting.js:6
    invoke client-error-handler.js:88
    flush client-error-handler.js:88
    flush client-error-handler.js:88
    _end client-error-handler.js:88
    end client-error-handler.js:88
    _run client-error-handler.js:88
    run client-error-handler.js:88
    d bookmark.js:114
    Ember 2
    _join client-error-handler.js:88
    join client-error-handler.js:88
    p bookmark.js:114
    h bookmark.js:114
    $ topic.js:1017
    trigger composer-action-title.js:62
    transitionStarted add-translation.js:27
    loading ace-editor.js:176
    D upload.js:65
    triggerEvent upload.js:65
    trigger form-template-validation.js:54
    _handleSlowTransition upload.js:65
    invoke client-error-handler.js:88
    flush client-error-handler.js:88
    flush client-error-handler.js:88
    _end client-error-handler.js:88
    end client-error-handler.js:88
    _runExpiredTimers client-error-handler.js:88
    setTimeout handler*setTimeout client-error-handler.js:88
    _installTimerTimeout client-error-handler.js:88
    _later client-error-handler.js:88
    later client-error-handler.js:88
    T bookmark.js:114
    _triggerAction form-template-validation.js:54
    click form-template-validation.js:54
binary.js:7
Uncaught TypeError: i is null
    reason binary.js:7
    l item.js:166
    get topic.js:1017
    ee upload.js:65
    get topic.js:1017
    get topic.js:1017
    eM topic.js:1017
    s backup-codes.js:33
    n backup-codes.js:33
    Z upload.js:65
    T backup-codes.js:33
    evaluate backup-codes.js:33
    _execute backup-codes.js:33
    execute backup-codes.js:33
    rerender backup-codes.js:33
    render theme-setting.js:6
    _renderRoots theme-setting.js:6
    tA backup-codes.js:33
    _renderRoots theme-setting.js:6
    _renderRootsTransaction theme-setting.js:6
    _revalidate theme-setting.js:6
    invoke client-error-handler.js:88
    flush client-error-handler.js:88
    flush client-error-handler.js:88
    _end client-error-handler.js:88
    end client-error-handler.js:88
    _run client-error-handler.js:88
    run client-error-handler.js:88
    d bookmark.js:114
    success base.js:71
    l loader.js:1286
    fireWith loader.js:1286
    jQuery 4
    a base.js:71
    e named-references.js:49
    e named-references.js:49
    A base.js:71
    _findCategoriesAndTopics item.js:166
    k named-references.js:49
    w named-references.js:49
    invoke client-error-handler.js:88
    flush client-error-handler.js:88
    flush client-error-handler.js:88
    _end client-error-handler.js:88
    end client-error-handler.js:88
    _runExpiredTimers client-error-handler.js:88
    setTimeout handler*setTimeout client-error-handler.js:88
    _installTimerTimeout client-error-handler.js:88
    _later client-error-handler.js:88
    later client-error-handler.js:88
    T bookmark.js:114
    _triggerAction form-template-validation.js:54
    click form-template-validation.js:54

TypeError: t.category_list.categories is undefined
s form-template-validation.js:54
categoriesFrom form-template-validation.js:54
_findCategoriesAndTopics item.js:166
k named-references.js:49
w named-references.js:49
invoke client-error-handler.js:88
flush client-error-handler.js:88
flush client-error-handler.js:88
_end client-error-handler.js:88
end client-error-handler.js:88
_run client-error-handler.js:88
run client-error-handler.js:88
d bookmark.js:114
success base.js:71
l loader.js:1286
fireWith loader.js:1286
jQuery 4
a base.js:71
e named-references.js:49
e named-references.js:49
A base.js:71
_findCategoriesAndTopics item.js:166
k named-references.js:49
w named-references.js:49
invoke client-error-handler.js:88
flush client-error-handler.js:88
flush client-error-handler.js:88
_end client-error-handler.js:88
end client-error-handler.js:88
_runExpiredTimers client-error-handler.js:88
setTimeout handler*setTimeout client-error-handler.js:88
_installTimerTimeout client-error-handler.js:88
_later client-error-handler.js:88
later client-error-handler.js:88

2 לייקים

נשמע שמישהו מחק את הקטגוריה כשיש בה נושאים איכשהו? זה לא אמור לקרות. אני חושב שתצטרך לעשות משהו כמו

rails c
c=Category.last; # or some other way to get a category) (או דרך אחרת להשיג קטגוריה)
Topic.where(category_id: 4).update_all(category_id: c.id)

אם קטגוריית ה-General שלך נמחקה בבטחה דרך ממשק המשתמש, אז צפוי שנושא ה-

לייק 1

This seems not to work:

discourse(prod)> Topic.where(category_id: 4).update_all(category_id: 20)
=> 0
discourse(prod)> Topic.where(id: 3).update_all(category_id: 20)
=> 0

And in Data Explorer I get:

Select id, closed, archived, title,category_id
from topics
where id = '3'

result:
id 	closed 	archived 	title 	category_id
3 	true 	true 	Über die Kategorie Team 	4

Hmm. I thought your broken topic had category_id of 4.

That was my best guess. If you have a budget you might ask for help in Marketplace. I think you’ll need someone to get into rails to see if they can figure it out.

לייק 1

Marketplace is always an option, especially if it’s urgent. :heart:

Though a bit more detail here might help jimmy up a community response. :crossed_fingers:

You both seem confident that the root cause is this topic. If data explorer can find it then you should be able to find it in the rails console. If you can find it then you should be able to use post_destroyer on it and delete it from there?

(Though slightly hesitant to recommend it as I’ve not quite connected up the dots to where the issue is)

3 לייקים

כן, במסוף רובי אני יכול לראות את הנושא:

result = ActiveRecord::Base.lease_connection.exec_query('SELECT id, category_id FROM topics WHERE id = 3')
result.rows
=\> [[3, 4]]

אבל ב-Topic אין כלום

Topic.where(id: 3)
=\> []

as you can see, finding is possible. But I have no idea of the Ruby syntax to delete exactly this one table entry.

Hmm. :thinking: It is unusual to be able to find it one way and not the other.

The rails console can be a bit of a sharp knife so it’d be best to figure out what exactly has gone wrong just to minimise any accidents/knock on effects.

How was this category deleted in the first place?

(Just in case the issue isn’t caused by this stray topic, I’ll throw in the basics of checking safe mode and seeing if there’s any more info about the error in your YourSite/logs page too)

Though I don’t know if your data is in a state where the category delete catch-all could help? Bulk delete all topics in a category

Good question. It was done some years ago by an other admin.

Meanwhile I deleted this topic direct in rails console with:

result = ActiveRecord::Base.lease_connection.exec_delete('DELETE FROM topics WHERE id = 3')

After this, topic is deleted :grinning_face:

לייק 1

And that solved your wonky category link in the sidebar too?

It’s interesting that it’s only just showing a problem now when it had been happily deleted for a number of years.

If you figure out the connection let me know. :slight_smile:

לייק 1

לצערי, זה לא פותר את השגיאה עם קישור הקטגוריה. אבל הבעיה עם הפוסט שלא ניתן למחיקה נפתרה לעת עתה. בעיית הקטגוריה גם היא לא מתועדת ביומן. אני אטפל בזה בימים הקרובים.

לייק 1

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.