CKEditor is missing when editing a page, but works fine when creating a new page On our drupal 7 site, we have CKEditor installed. It works fine when creating new content, but it doesn't activate properly when you go to edit the same page later. It acts like there is no editor installed and just gives a standard textbox with source.

If I click "Edit Summary", it will usually show up for the summary textbox (though not always).

Why isn't CKEditor showing up for the Body textbox?

Note that I am not selecting "switch to plain text editor". If I do, and if I see CKEditor on "Edit Summary", then clicking "switch to plain text editor" does properly hide the CKEditor for the Summary textfield. Clicking "switch to rich text editor" also restores CKEditor for the Summary, but the main Body textbox still acts like it uses a plain text editor.

New Page - CKEditor Showing




Edit Page - CKEditor Missing




Edit Page Summary - CKEditor Showing (but still missing for the body textbox - not shown in screenshot)





Edit: More details on the exact problem
I found that the reason a New Page loads ckeditor, while editing does not, is because the textbox is empty. If I add text to the new page, switch to 'plain text editor', then try to switch back to 'rich text editor', then CKEditor does not load.

Similarly, if I clear out the data in the textbox while editing a page, and switch text editors, CKEditor loads up.

There is a 500 error being returned, causing CKEditor to not load. When there is text, switching to 'rich text editor' causes an AJAX call to the server to validate or otherwise process the textbox data. Since it fails, CKEditor never loads.

But if there is nothing in the textbox, the AJAX call never happens (and thus no 500 is returned), so CKEditor loads up just fine. This is also why CKEditor loads in the Summary: it has no data.
The solution, in my situation, was two-fold.

Multiple CKEditor versions in different locations

First, the main reason was due to having multiple versions of CKEditor installed in different locations.

When you install the CKEditor module, you must also download the actual CKEditor code separately. It can be installed within the modules/ckeditor folder or in libraries. I had updated the module as well as the code, but the old version persisted in the libraries folder. Sometimes CKEditor would load, and other times it wouldn't. Likely it was due to one CKEditor library loading first.

Removing all duplicate references and clearing the cache worked. CKEditor loaded again on most of our sub-sites.

Buggy code on server causing a 500 error

The second problem was due to faulty php code on one of our subsites. For some reason, an unrelated page included other PHP and was somehow being called when CKEditor made the AJAX call to the server. The server responded with a 500 error, and the error logs shows that this unrelated page was somehow being called and failing.

I took out the reference to the buggy code, and CKEditor worked again for that page.

I still have no idea how that code was being called. It was a simple page with a single line of php, including a different file. Yet CKEditor failed to load on every page within the subsite, not just that page. I chalk it up to lacking enough understanding of Drupal internals.