pyrocms/pyrocms — pull request #2826 by chrisfranson (2013-06-25 02:17:53+00:00)
Title: When saving keywords, delete existing applied keywords first

#### Issue
Currently, when saving a stream that has a **Keywords** field, the old hash for the stream row remains in the **keywords_applied** table. So the **keywords_applied** table can get filled up with rows containing meaningless hashes which no longer reference a row.

#### Proposed Solution
In the **pre_save** method of **field.keywords.php**, check if the row being saved already exists, and if so, delete any existing applied keywords.

#### Remaining Issues
If the saving process fails at some point after **pre_save** for the Keywords field, but before the new set of keywords is applied, the existing applied keywords will be lost.