Hacking, Software

Weird problems: wordpress truncating captions

I woke up this morning to a fresh new problem at work: Wordpres was truncating image captions. Specifically, we have a lot of old content (dating back to 2007!) and therefore old shortcodes, and the old style caption codes (which use caption as an attribute) were getting truncated. They were also showing their opening quote. It was ugly, and it was confusing because I hadn’t touched the server at all in about a week.

I initially suspected an errant plugin, because that’s the cause of 90% of my pain in WordPress. Last night I’d spun up a staging server from a backup, so I had a <24 hour old copy¬†of the server. Our databases are on a separate¬†machine so I refreshed the dev database too.

Irritatingly, everything worked fine on dev. To figure out what was different between the two servers I use rsync (from within the web directory on the dev box)

rsync -avun -e ssh kellbot@production:/path/to/public_html/ .

The -n flag is key because it does a dry run rather than actually copying the files

Among other things, wp-includes/version.php was different. Turns out a security update had been applied automatically (taking us from 3.9.2 to 3.9.3). I updated us to 4.0.1 (uh, yeah been meaning to do that …) and everything was fixed.


1 thought on “Weird problems: wordpress truncating captions”

  1. Hello, I have faced an issue while using Lightbox plugin, where dollar signs & backslashes are truncated in image captions and in order to solve this scenario, I have replaced preg_replace with preg_replace_callback in the function.

Leave a Reply

Your email address will not be published. Required fields are marked *