Hefta-Gaub Development Blog

April 24, 2007

The Case of the Disappearing TinyMCE

I’ve been having off and on problems with my TinyMCE rich text editor disappearing from WordPress… At first it seemed very random, sometimes it was there sometimes it wasn’t. Then it seemed like the problem went away, as in TinyMCE didn’t go away, and then the problem came back, as in TinyMCE was nowhere to be found.

Well, this weekend I finally figured out at least one thing that would cause this problem to happen.

Apparently one of my plugins was outputting an extra couple lines of non-php at the end of the file. Although this seems like a perfectly innocuous thing it causes big trouble for TinyMCE specifically the gzip support built in to the wordpress/tinyMCE integration.

So imagine this…

<?php
/***************************************
* Example of PHP that does nothing, except
* break TinyMCE.
*
* Notice that after the 'end php tag' there are
* two blank lines.
****************************************/
?>
 
 

These two extra lines will break TinyMCE. I haven’t found a minimal reproduce case yet, but I am sure this is related to the call to ob_start(“ob_gzhandler”); This sort of makes sense in that ob_start() is a relatively sensitive function insofaras you can’t call echo or other functions that output to the main output stream from within a callback function, but we’re not really doing that. I suspect there is some kind of a bug in ob_start() or in the ob_gzhandler handler that doesn’t like these kind of non-PHP outputs in the middle of a PHP stream.

Another case I found which creates this same behavior is…

<?php
/***************************************
* Example of PHP that does nothing, except
* break TinyMCE
*
* Notice that a single space outside of the
* php context.
****************************************/

?> <?php

?>

Anyway, if you see your TinyMCE disappearing on you, then it may be that you have a plugin with a couple extra blank lines at the end of the file outside the context of the PHP script processor.

Advertisements

8 Comments »

  1. I too am still having this problem and I thought it was due to my plugins, and went through one by one each of the plugin files in the Plugin Editor and found that quite a few of my plugins had spaces after ?> And attempted fixing that. After deleting the extra line(s), I ran into odd 503 error problems, and my TinyMCE is still playing Houdini.

    It seems like I might have no other choice than to re-install and re-do all of the plugins, as my TinyMCE has completely vanished.

    Comment by Rebecca — May 6, 2007 @ 1:53 pm

  2. Rebecca,

    Sorry to hear you have a problem with TinyMCE. I will admit there are other cases that would likely cause TinyMCE to misbehave… but this was the case I found.

    Also, it seems strange to me that this bug occurs, there really isn’t any reason why a blank line should cause a problem to the JavaScript of the compression routines that use ob_start(”ob_gzhandler”);

    I think doing a clean install, and eliminating plugins is a good way to debug the problem.

    Good Luck.

    -Brad

    Comment by zappoman — May 6, 2007 @ 5:21 pm

  3. Don’t know if this helps, but I just had the same problem on two of my blogs. It happened just after I changed my options (under Admin>Users>Edit), which I thought was suspicious. Sure enough – when I checked my profile under Admin>Users>Edit>Your Profile, the “Use the visual editor when writing” checkbox had somehow become unchecked. I re-checked this box, clicked Update Profile, and TinyMCE returned…

    Comment by Matt — May 7, 2007 @ 10:25 pm

  4. thanks a lot. I am having these problems as well. will look into it. thanks for the tips.

    also:

    when those buttons are gone, the only way to get them back is to switch theme’s for me.

    Comment by Marco Raaphorst — June 22, 2007 @ 12:46 pm

  5. […] 23rd, 2007 · No Comments I found this solution. Extra lines after the php-end seems to be the source of the […]

    Pingback by TinyMCE buttons got lots in WPMU 1.2.1 « wphacker — June 23, 2007 @ 8:13 am

  6. I’m having the same problem whit aditional empty lines all around wpmu. The tinyMCE disapears and the RSS broken down.

    I supose that the problem could be cause for FTP clients that adds that lines. So now i’m going to probe reinstalling WPMU whit a different FTP client.

    Any additional suggestion?

    Comment by Diego Herrera — July 18, 2007 @ 12:43 am

  7. Yeap the problem was the extra lines, For solutionate that problem you must be sure that you ftp client or web development tool (like dreamweaver in my case) use the same “Line break type” is diferent in windows and linux.

    Comment by Diego Herrera — July 18, 2007 @ 9:45 pm

  8. […] If you dont have the knowledge of installing the scripts you want on your website, we offer fast installation of CGI scripts. Read More… […]

    Pingback by Cgi script installation service — September 17, 2012 @ 12:39 pm


RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Create a free website or blog at WordPress.com.

%d bloggers like this: