WordPress Problem: Post content disappear

This is the oddest thing I’ve ever seen on WordPress. Here’s my problem:
I have a whole ton of text. But the last few lines I have this:

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.

IF I add this line next (without the quotes)…

“I try to keep anybody from having to go back and fix anything so it makes them have to play it now, you know?”

The entire body of the post disappears. Only the title shows up. If I remove that line, the text comes back. If I add “asdf”, the body stays. If I add a random line, the body disappears. I thought maybe it was a phantom html tag hidden in there or something, so I copied and pasted into notepad to clear any potential underlying formatting and it’s still doing it. I’ve never seen anything like it. I’ve been poking at this thing for hours. I even tried moving the entire contents to a new post. No dice. I erased and rewrote the entire offending section and then some… nothing. We’ve got several hundred posts and this has never happened. There’s a good 20 blockquotes in this post and everything works fine.

Causes

Most common – Some vaguely written function hooking into the the_content filter. Also note,

  • Output of the_excerptwas ok.
  • Problem appeared in all the themes, including the wp3.0 default twentyten, so problem is probably not related to a theme.

Apache and HTTP POST limits

In all but a few cases, WordPress runs under a LAMP, WAMP or MAMP environment, which all have in common that Apache is the HTTP daemon that serves the PHP pages of WordPress. Apache has limits, but they are few:

  • Apache limits internal redirects. Redirects are used with friendly and permanent urls in WordPress. The limit is defaulted to a maximum of 10 redirects on the same server. Surpassing this limit will show up in the logs as an error. See LimitInternalRecursion directive.
  • You can limit the length of the request body. The default is unlimited, however. Unlimited in this sense means 2GB which in practice means that you cannot upload files larger then 2GB. See LimitRequestBody directive for details.
  • There’s a fixed limit for XML Request Bodies. This is the body that’s used for XMLHttpRequests and this method is heavily used by the WordPress page editor and others to send intermediate updates to the server (to prevent work loss). The maximum here defaults 1000000 bytes, which is close to 1 MB. It is possible that posts exceed this limit, though unlikely. In my case, I wasn’t even close. See LimitXMLRequestBody directive for details.
  • There are other limits, like the limiting the size or the amount of HTTP headers through LimitRequestFieldSize/LimitRequestLine (both default 8190 bytes per header value/line) and LimitRequestFields (default 100 HTTP headers) but these have little to do with the issue at hand.
  • By default, Apache is not limited to the amount of memory it can consume, but you can configure this differently on a per thread basis.

PHP limits for HTTP Post and file uploads

Where Apache has its limits set very wide (and righteously so, it must support many types of server software), PHP is must trickier when it comes to limits. As it turns out, the following limits apply to a default PHP installation:

  • The maximum time a script can take to respond is 30 seconds by default. You can set the variable max_execution_time in php.ini.
  • The maximum time a script can spend in gathering request data (related to upload time from client to server) is 60 seconds, it can be set with max_input_time.
  • Any script can consume 128MB as a limit, but multiple requests and scripts together can add to that limit unlimited.
  • Upload file size is limited to 2MB by default. This is not very much, but does not interfere with large HTTP POST requests. Set the upload_max_filesize setting to change this.
  • HTTP POST size is by default maximum 8MB. It is unlikely that I reached that limit (the size of the POST was about 25kB). You can change this setting by editing post_max_size in php.ini.
  • There are other limits that deal, for instance, with database persistence. By default, all these limits are set to no limit.

[adsense ad_client=ca-pub-0297902515090400 ad_slot=5761360564 width=468 height=60]

Debugging and Solutions

  • Deactivating plugins one by one is the most widely suggested solution in the interwebs. Well, you can always try that out. But I didn’t want to disable/enable plugins one by one. First, it takes too much time, is boring and I always forget to enable a plugin or two and scratch my head for hours why something isn’t working.
  • Check your JavaScript code, it may be the cause if the website has the .js files compressed, decode it then try again.
  • In some cases, the visual editor cause errors, disable it via profile page. May be your plugins also make this happen, you need change to default theme then disable all your plugin installed.
  • Using the line remove_filter(‘wpautop’) you can remove the wpautop filter altogether. Some people prefer this as it gives them more control over the whitespace handling of a post. Removing this filter has the effect that whitespace becomes insignificant and that you’ll have to add paragraph…tags yourself for inserting whitelines.
  • This fix feels for me like using a bulldozer for hoeing your garden. This fix has so many nasty side effects that all my existing posts become illegible and that’s not really what we’re after here…
  • I’ve read on the WordPress Support forum then found some answers about it. Add [php light=”true” padlinenumbers=”false”]define( ‘CONCATENATE_SCRIPTS’, false );[/php]to wp-config.php, may be it works well or upload fresh WordPress files again, do not upgrade automatic.
  • A few other reasons to think the problem is in the file .htaccess, you try to delete it and use WordPress to create this file again.
  • You can delete all files in wordpress/wp-includes/js/tinymce folder then upload fresh files in WordPress v2.8, may be it fixed.
  • If using Gears, disable it and re-enable it again then clear the browser cache.
  • In many discussions in the WordPress Support forum, many people have solved the problem by turning off the plugins using Google API
  • The largest cause of the problem is handled HTML of TinyMCE in WordPress, it’s my problem, the resolution is simply to switch to use KCEditor while waiting for this issue is resolved in the next version of WordPress.
  • Checking the entire content and looking for [...], sometimes the cause of this problem is shortcode. If you look through the code, there’s been some thought about using double [[ and ]], but this has never been applied throughout all the code. Someone thought to come up with a plugin No Short Code which adds a new shortcode that disables the shortcode inside, but unfortunately, that only works occasionally and it doesn’t work at all from the editor
  • Reading on about this issue you may have encountered that some people consider the [ caption ] shortcode to be the problem. By not using them (and painfully typing in the HTML code by hand) they get around this bug. But the bug could easily occur in any other situation using shortcode.

Conclusion

This was just a single bug and it showed me some of the inner workings of WordPress. I haven’t gone too deep into the details this time as I just wanted to provide a little context to the problem. This look at the code hasn’t made me any more enthusiastic, but I’ll continue using it (using is different then building it) as it is definitely one of the best in its kind in spite of its shortcomings. Hopefully those who face similar circumstances can solve this problem without loss of time as me

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.