Closed Bug 615787 Opened 14 years ago Closed 14 years ago

Document._clean_category() without an ID updates all docs without parents :(

Categories

(support.mozilla.org :: Knowledge Base Software, task, P1)

x86
macOS

Tracking

(Not tracked)

VERIFIED FIXED

People

(Reporter: rbillings, Assigned: jsocol)

References

Details

(Keywords: dataloss)

Articles are created with 'troubleshooting', as we migrated articles. For unknown reasons the categories are flipping. At last count all articles had been flipped to the 'Navigation' category.
Priority: -- → P1
Now everything has moved to Troubleshooting.
On support-stage, everything is in Troubleshooting. Trying to find a way to switch it all somewhere else.
Summary: Production randomly changing KB article categories → Document._clean_category() without an ID updates all docs without parents :(
master: https://github.com/jsocol/kitsune/commit/0403ec
2.3.x: https://github.com/jsocol/kitsune/commit/d960727
Status: NEW → RESOLVED
Closed: 14 years ago
Resolution: --- → FIXED
For posterity:

In Document._clean_category() we call something like

  self.translations.all().update(category=self.category)

Unfortunately, when you call that on an unsaved article, the SQL it generates to get translations.all() is something like: "SELECT id, ... WHERE parent_id IS NULL". So it was changing all documents without a parent, which is 1) all of English, and 2) any docs in other languages that aren't translations.

This sucks. It's dataloss, but maybe we can get close to correct with a big-ol-SQL file doing some updates. We still have Paul's migration data, we should be able to do something like pull out ID and Category and run it as an update. Filing a new bug for that.

Any articles created last night after the migration will have to be manually moved back.
Keywords: dataloss
... I feel so... betrayed... Django should warn about this ... at least in their documentation. Maybe they do and we all missed it.
Verified creating a new document with a non-default category did not switch existing US documents without a parent.
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.