Word Replacements: entering a string with HTML will reset all replacements
How to reproduce:
- On a single language site, go to Administer > Customize data and screen > Word Replacements
- Enter a few replacements, it doesn't matter if they are valid.
- Save, so far so good.
Then add a new replacement with html: <p>test</p>
, and click save.
Result: word replacements table will be completely empty.
I debugged a bit and this is because CRM_Core_BAO_WordReplacement.php::getConfigArraysAsAPIParams()
uses unserialize
on the strings that are stored in civicrm_domain
(ugh). The unserialize fails because of the HTML, so it returns FALSE, and the function ends up returning an empty array, which is then used to re-populate the civicrm_word_replacement
table.