This concerns a problem at my blog.
My provider recently required me to upgrade from PHP 5.2 to PHP 5.4. This in turn required me to update WordPress.
Ever since the dual update, all line breaks in comments are rendering as “rn”, so that if you type this:
Hi
<br><br>
Hello
what gets rendered is
HirnHello
If I edit comments to repair them, all of the line breaks I enter are converted back to “rn” as soon as I hit “save”.
A temporary rollback to PHP 5.2 had no effect on this problem.
I briefly thought I could solve the problem by updating my theme (K2). This did not solve the problem and created a slew of new (unrelated) problems, so I’ve rolled back that update.
Browsing around this site, I see a few scattered references to this and similar problems, but no indication that it’s ever been common and nothing that appears to be a solution.
Can someone guess what’s causing this, and even better, how to fix it?
Update: I found a file called wp-comments-post.php
, which contains the following line:
$comment_content = ( isset($_POST['comment']) ) ? trim($_POST['comment']) : null;
I wrapped the trim($_POST['comment'])
inside a nl2br()
, and this helped a bit. Instead of rendering as
HirnHello
it now renders as
Hi<br>
rn<br>
rnHello
(or something like that; I might have forgotten how many rn
‘s show up).
This is progress, but I’d still like to get rid of the rn
‘s. Presumably I can use str_replace
? But I am an amateur and am not sure of the syntax. My first few guesses didn’t work.
Meanwhile, I still want to know why this problem arose in the first place.