Open nymwo opened 1 month ago
@nymwo is your database also hosted on Windows? The synonyms content comes from the post_content
of a CPT called ep-synonym
, and is saved by the handle_update_synonyms
method. Can you check exactly where that \r\n
becomes \n
?
It has been 3 days since more information was requested from you in this issue and we have not heard back. This issue is now marked as stale and will be closed in 3 days, but if you have more information to add then please comment and the issue will stay open.
Yes, the database is on Windows.
This is what is sent when i press "Save changes" on the synonym admin page:
{"mode":"simple","solr":"# Defined synonyms.\n\nTest, Try\n\n# Defined hyponyms.\n\nblue => blue, aqua, azure, cerulean, cyan, ultramarine\n\n# Defined replacements.\n\nsupposably => supposedly\nflustrated => flustered, frustrated\nintensive purposes => intents and purposes\n"}
Though minified, I can see that synonyms-script.js
joins the lines with "\n" when constructing the "solr" parameter. Changing that to use PHP_EOL might fix this.
It has been 3 days since more information was requested from you in this issue and we have not heard back. This issue is now marked as stale and will be closed in 3 days, but if you have more information to add then please comment and the issue will stay open.
@nymwo do you want to craft a PR with that change? Thanks!
I'm not sure where it makes sense to make the change. If not passing PHP_EOL to the JS script, maybe there should be a line break fix here:
or here:
Describe the bug
The Synonym feature doesn't work when hosted on Windows.
In wp-content\plugins\elasticpress\includes\classes\Feature\Search\Synonyms.php we can se that the synonyms are separated (explode) by PHP_EOL, which is \r\n on Windows:
But it looks like $this->get_synonyms_raw() always returns a string with synonyms separated by \n. On Linux, PHP_EOL is defined as \n, so this issue does not appear when running on that OS.
Changing PHP_EOL to "\n" resolves the issue on Windows.
Steps to Reproduce
Screenshots, screen recording, code snippet
No response
Environment information
No response
WordPress and ElasticPress information
No response
Code of Conduct