I have installed Drupal 7 using the Acquia stack and have also installed the WYSIWYG module.

When I enter the WYSIWYG configuration I click the link to the CKEditor website, download the module and install in the following location as instructed on the WYSIWYG config page:

sites/all/libraries/ckeditor

Now when I refresh the page I get the message "The version of CKEditor could not be detected." Has anyone experienced this on Drupal 7 and know what needs fixing?

Thanks

Comments

Fixed by installing previous version 3.5.3

Same error... guess I'll try your fix. Seems like there should be a better way though.

In .../modules/wysiwyg/editors/ckeditor.inc change line 68 from

while ($max_lines && $line = fgets($library, 140)) {

to

while ($max_lines && $line = fgets($library)) {

Thanks azupan, this did the trick for me! :-)

Great patch -thanks!

Thank you , work me too.

Thanks for the patch, worked like a charm.

I have tried everything, I have tried with 3.6 and the patch with no effect, I have used 3.5.3 with no effect, I even tried using the patch proved above to no effect, I just cannot seem to get an editor library working with wysiwyg

I had the same problem and I could not apply the patch because I had no editors folder in the wysiwyg folder. I installed the 7.x-2.x-dev wysiwyg and all seems to be working now.

emk

This worked for me as well. Please consider filing an issue for the WYSIWYG module with a patch.

I'm using WYSIWYG 7.x-2.0 and CKEDITOR 7.x-1.x-dev.

Cheers,
Kieran

Kieran Lal

Above solution by azupan worked for me too....I was using WYSIWIG 6.x-2.3.....thanks

solution worked for me also - this added to the module yet? If not, should be.

Shivnibble: The Ultimate Brady Experience

this thing worked for me.. http://www.laan-info.dk/

Please, do NOT use both wysiwyg.module and ckeditor.module, it is unsupported and will cause conflicts. All you need is either wysiwyg.module or ckeditor.module, and of course the CKEdtitor library.

And no, this patch won't get into the module. If the second argument to fgets says 140, you are using an old version of Wysiwyg module. It should say 500.

Thanks for the patch, worked like a charm.

Thanks a lot azupan for this easy simple and working solution ;)
++
Wysiwyg 7.x-2.0
CKEditor 3.6

Worked for me too, thanks.

No new version to fix this yet?

Thanks! :)

_____________________________________________
Coding is like a box of chocolates!...

openSUSE 12.1
NVIDIA GeForce 9500 GT
Intel(R) Core(TM)2 Quad CPU Q9550 @ 2.83GHz

That work for me! in Drupal 7

Website Designer (Drupal Themer)
Extensive professionals
info@extensiveprofessionals.com

AZUPAN!!

FOR THE WIN BROTHER.

Nice patch.

FYI,
This issue was fixed long ago in the latest Wysiwyg releases. (It may arise again if CKEditor drastically modifies its files, but then we probably need a different fix.)
I would not recommend to completely remove the last argument in the function call since that means the entire CKEditor file is read into the server's memory, on every page load where the editor should appear. That's just a waste of memory. Increase it a bit instead until the error goes away. Then it'll just read the beginnings of each line until it finds CKEditor's version number.
(The line holding the version string in the minified variant of CKEditor holds the entire script!)

The edit to the WYSIWYG module ckeditor.inc file works with D6.22 and CKeditor 3.6.1 as well.

I've submitted a patch against the wysiwyg module (7.x-2.x-dev) here: http://drupal.org/node/1283274, as proposed by azupan

Doka

Azupan's workaround worked for me in Wysiwg 7.x-2.0 with Drupal 7.12 and the very latest CKeditor

I haven't been through all the threads. Just as a reminder (just because I tend to do the same mistake all over again) :

  • Install WYSIWYG in sites/all/modules : http://drupal.org/project/wysiwyg
  • DO NOT Install Ckeditor module, as reminded above
  • Install Ckeditor library in sites/all/modules : http://ckeditor.com/download (see the first download proposition under "Fully functional, open source editor, with source code included"

This in case you're using WYSIWYG Module. Otherwise, just use the Ckeditor Module alone.

Don't you just wish you could "Like" posts :)

Thanks

In .../modules/wysiwyg/editors/ckeditor.inc change line from function wysiwyg_ckeditor_version($editor)

if (preg_match('@version:\'(?:CKEditor )?([\d\.]+)(?:.+revision:\'([\d]+))?@', $line, $version)) {

to

if (preg_match('@version:\"(?:CKEditor )?([\d\.]+)(?:.+revision:\"([\d]+))?@', $line, $version)) {

This changes version number search from single quotes version: '4.0' to double quotes version "4.0"

It worked for me on Drupal 7.17 and wysiwyg 7.x-2.2

This worked for me
wysiwyg-7.x-2.2 and CKeditor 4.0 full
Thanks again

This fixed it for me too, thanks! (Drupal 7.17, wysiwgy 7.x-2.2, ckeditor 4.0)

This worked for me on Drupal 6.26 CKEditor 4.0 Full

--
www.richardhare.com
@richardhare

I'm sure this had saved me from hours of agony. Thanks!

it works great. Thanks !

worked good on recent drupal 7 with ckeditor 2-dev

For me i needed to fix the revision matching as it seems to be alphanumeric now

// version:"4.0.1",revision:"d02739be4b"
(preg_match('@version:\"(?:CKEditor )?([\d\.]+)(?:.+revision:\"([\da-z]+))?@', $line, $version))

Alex

This fix worked for me having just downloaded the latest version of CKEditor as per the WYSIWYG instructions.

Also worked for me. @ line 81 :-D

Thanks for this Alex. Your matching code works for me, having just downloaded current version (May 2013) of WYSIWYG module and the CKEditor.

Using wysiwyg 7.x-2.2 and ckeditor 4.1.1

This worked! Thanks!

Thanks! Just started using Drupal and didn't realize I'd be modifying code so fast...

Cliff

alexPalumbo's augmented fix here, which was intended to accommodate CKEditor 4.01 is still working like a charm for version 4.3.0 almost one year later! Way to go Alex! Thanks!

********
Jimbobwe

Drupal 7.26
WYSIWYG 7.x-2.2
CKEditor 4.3.3.7841b02

Thanks Alex!!!

I am humble.

This worked for me, and I can at least use CKEditor now. But I am getting another error message in Administration>Configuration>Content Authoring:

Notice: Undefined offset: 2 in wysiwyg_ckeditor_version() (line 85 of /home/content/c/l/i/cliffskier/html/phpapps/drupal/sites/all/modules/wysiwyg/editors/ckeditor.inc).

Hi there, I got the same error message were you able to find the solution?

Notice: Undefined offset: 2 in wysiwyg_ckeditor_version() (line 85 of /homepages/8/d479514218/htdocs/drupal-7.22/sites/all/modules/wysiwyg/editors/ckeditor.inc).

I too received an error

Notice: Undefined offset: 2 in wysiwyg_ckeditor_version() (line 85 of /homepages/27/d480673492/htdocs/modules/wysiwyg/editors/ckeditor.inc).

Has anyone found a fix for this error / why is this happening?
Thanks for the fix though!

I removed the error by changing the line:

return $version[1] . '.' . $version[2];

to:

return $version[1] ;

...you likely haven't pasted the code in correctly. I had the same issue until I finally just hand-typed the updated portion of the code snippet into the ckeditor.inc file instead of pasting over the entire expression. Idunno, but once I did that it worked. Just a thought...

********
Jimbobwe

Thanks, worked for me, too.

Kubilay E.
PHP / iOS Developer
http://kubilayerdogan.net

Thanks! Really helps with 4+ versions

Worked for me too!!
wysiwyg 7.x-2.2 and ckeditor4.0.1

this worked for me! thanks for this.

PJ McGhee

I'm using WYSIWYG 7.x-2.2 with CKeditor v 4.1.1 and was running into the same error. This patch worked for me, so thanks sakseiw!

This change to ckeditor.inc worked for me, but...

WYSIWYG then threw a PDO Exception error on Table not found. I had to uninstall and reenable which made CKEditor work.

Tom Stermitz, Denver/Ft Collins Colorado
NoCo Internet

Thanks

It worked for me as well.

this is great fix that solved the issue. drupal 7.22 with ckeditor 4.1.1.5 now working fine.

Thanks! It works.

kanenas.net
News & Ideas About Programming

sakseiw it worked
WYSIWYG 7.x-2.2
CKEeditor 4.2
Drupal 7.22

nice! fixed it for me, as well. Thanks.

Thanks a lot. It also worked for me on drupal 7.24.26 wysiwyg module 7.x-2.2 . I installed ckeditor version 4.3.1. Additionally I also installed ckeditor module version no. 7. x-1.13. Thanks a lot again

It works!
this worked for me, Drupal_7.24 + CKEditor_4.3.1_standard

This fixed for me too. Thanks!

Sam

Tnx!

This worked for me too with :

Core 7.27 - Wysiwyg 7.x-2.2 - CKeditor 4.3.4

Van Der Biest Wim

http://wpr-design.com

That's rocks ! Thank you DSG !

In case you get a warning at the top saying that index 2 of $version doesn't exist, change the return of function wysiwyg_ckeditor_version($editor) to:

return isset($version[2])?$version[1] . '.' . $version[2]:$version[1];

Instead of changing match code in ckeditor.inc file, you can just help to find what the file is looking for, which is quite easy to do:

Open file ckeditor.js library ( sites/all/libraries/ckeditor/ckeditor.js )
At the very top of this file you will see the comment lines, such as:

/*
Copyright (c) 2003-2012, CKSource - Frederico Knabben. All rights reserved.
For licensing, see LICENSE.html or http://ckeditor.com/license
*/

Just add to this comment a new line with details about version, so the comment will be:

/*
Copyright (c) 2003-2012, CKSource - Frederico Knabben. All rights reserved.
For licensing, see LICENSE.html or http://ckeditor.com/license
  version:'CKEditor 4.0 SVN',revision:'769d96134b'
*/

Version and revision details you will find somewhere at the beginning of js code, right beneath the comment, something like this:

var b={timestamp:"CAPD",version:"4.0",revision:"769d96134b"...

* do not change anything in the code.

That's it. Just reload the wysiwyg profile page ( admin/settings/wysiwyg/profile )

Thanks!

Thanks jack-pl - that solution worked for me.

I provide Drupal, Drupal Commerce and CiviCRM development services for customers in New Zealand and beyond

Perfect fix, thank you. Works like a charm.

I hate with a passion solutions that alter drupal. Thanks.

Thank you, solved the issue for me too. Thanks for the advice.

merci!
TY

I don't understand wat's behind this, but it works. Thanks for sharing !

Great catch but oh what a terrible thing to have to do.

This worked perfectly!

Big ups and Kudos Jack. Like a charm.
Anyone mentioned this to the guys from CKEditor yet? Future fix?

Cheers.

Thanks Jack!

I'm using WYSIWYG 7.x-2.2 and CKEDITOR 7.1.1 Full.
I downloaded the ckeditor_4.1.1_full from http://ckeditor.com/download

BTW inside the /var/www/html/sites/all/libraries/ckeditor/ckeditor.js the line that you find the version is:
{var a={timestamp:"D3NA",version:"4.1.1",revision:"5a2a7e3",

Rgrds,

MTCNA, MBA, MSc, BEng HONS
Member of AWMN

works like a charm

SUN's

As it seems to be an ongoing issue even now, the solution proposed by @jack-pl is the most pragmatic. Given that the WYSIWYG module simply looks for a the version in a Doc Comment string (much like the libraries module), adding in a comment with the version string is sensible. Why? ... because the CKEDITOR library is updated infrequently and manually, whereas automatic updates of the WYSIWYG module will eventually happen and break the solution(unless it takes account of this issue), by which time most of us will have forgotton (well I will anyway) and will arrive back here looking for the same fix.

Yes, unfortunately it's true. My solution is only for those people which aren't familiar with PHP or just don't want change anything in php files. The main disadvantage of this issue is an obligation to repeat the same action for each library update.

Changing a regular expression within php file doesn't guarantee anything, and in all probability sooner or later a new php code will be required, so the issue will be ongoing anyway.

At least the Drupal upgrade process doesn't require that the libraries are updated generally, whereas it does for the module, so your fix for the library part of the equation should last longer and cause less headache.

I applied this patch for the latest full version 4.2 but I am getting following error message. It still seems to be working though.
Notice: Undefined offset: 2 in wysiwyg_ckeditor_version() (line 85 of /home/example/public_html/sites/all/modules/wysiwyg/editors/ckeditor.inc).

Thank you Alex, however I am experiencing the same error message as cmwelding, will any dire effect arise If I choose to ignore the error message?

Hello, I found a solution here https://drupal.org/node/1883456 and it worked fine!

Thanks, jack-pl. This is the better solution.

http://geradezu.dk - Beratung und Gestaltung im Bereich online Präsenz

This worked for me, thanks!

As a side note: how do you even come up with a solution like that? I'm by no means a Drupal guru, but I wouldn't have thought of something like that myself in a 1000 years.

Kathelijne

Worked for me, using CKEditor 4.3.1 Standard.

Spanners
--
Follow me on Twitter - http://twitter.com/spanners80

Worked very well. Thank You

thanks a lot!

Done.
Thank you Alex.

Details :
When I get error “The version of CKEditor could not be detected.2 whiel editing wysywig profiles in content authoring / admin > configuration > wyswig profiles:

In .../modules/wysiwyg/editors/ckeditor.inc change line 68 from
while ($max_lines && $line = fgets($library, 140)) {
to
while ($max_lines && $line = fgets($library)) {

Further description :
And no, this patch won't get into the module. If the second argument to fgets says 140, you are using an old version of Wysiwyg module. It should say 500.

This issue was fixed long ago in the latest Wysiwyg releases. (It may arise again if CKEditor drastically modifies its files, but then we probably need a different fix.)
I would not recommend to completely remove the last argument in the function call since that means the entire CKEditor file is read into the server's memory, on every page load where the editor should appear. That's just a waste of memory. Increase it a bit instead until the error goes away. Then it'll just read the beginnings of each line until it finds CKEditor's version number.

Now ,this is the final hack :

(The line holding the version string in the minified variant of CKEditor holds the entire script!)
and then I tried :
In .../modules/wysiwyg/editors/ckeditor.inc change line from function wysiwyg_ckeditor_version($editor)
if (preg_match('@version:\'(?:CKEditor )?([\d\.]+)(?:.+revision:\'([\d]+))?@', $line, $version)) {
to
if (preg_match('@version:\"(?:CKEditor )?([\d\.]+)(?:.+revision:\"([\d]+))?@', $line, $version)) {
This changes version number search from single quotes version: '4.0' to double quotes version "4.0"
It worked for me on Drupal 7.2, ckeditor_4.1.1_standard, and wysiwyg-7.x-2.2

Thanks a ton to Alex.

Let me knwo if there are any oher amendments you suggest.

Applied @dipali Patch and it worked.

JadH

Since revision codes can be alphanumeric, an additional change is needed for scanning the revision field (\w instead of \d, e.g. to work with 4.1.2.d6f1e0e). The snippet below consolidates the single/double quote fix with alphanumeric revision codes:

if (preg_match('@version:[\'"](?:CKEditor )?([\d\.]+)(?:.+revision:[\'"]([\w]+))?@', $line, $version))

@venkatperi thanks, that worked great.

Well done - that works great in Drupal 7 with latest ckeditor

Technical Director & Senior Software Engineer,
based in Cambridge, England.

Works great in Drupal 7 and CKEditor 4.2.f74e558

Thanks!

sorry for asking, I am new to drupal, Please where do i paste this code?

In the file: .../modules/wysiwyg/editors/ckeditor.inc at about line 81

replace

if (preg_match('@version:\'(?:CKEditor )?([\d\.]+)(?:.+revision:\'([\d]+))?@', $line, $version)) {

with

if (preg_match('@version:[\'"](?:CKEditor )?([\d\.]+)(?:.+revision:[\'"]([\w]+))?@', $line, $version)) {

Cameron Auber

AuDe Byte Hosting
Director

Web: www.audebyte.com.au
Email: info@audebyte.com.au
Facebook: www.facebook.com/AuDeByteHosting
Twitter: www.twitter.com/AuDeByteHosting

Thanks @audebytehosting! CKEditor 4.2.1 works for me now!

Thanks @audebytehosting! Works for me too! v4.2.1 @ line 81

This needs to rolled into the production version of this module. This issue has been a problem for too long.

Maybe I'm daft, but I've changed line 81 to the code shown and I still get the error.

Thanks @audebytehosting this fixed it for me too.

I love drupal, and I thank you!
zestux freelance web designer in Limousin France

This worked for me, CKeditor is now detected, but it won't load in my text area's.
I configured all text formats to use CKeditor but still it won't show the buttons.
The text area does get the ckeditor css though and the top-bar but no buttons.

I fixed this. None of the buttons where enabled in CKeditor configuration.

Any suggestions?

My current drupal installation:
Drupal 7.23
CKeditor 4.2 revision f74e558
WYSIWYG 7.x-2.2

you have probably worked this out ....if not ...you need to edit the profile ....and add the buttons

look for "Buttons and plugins" then put a tick in the box for each button you would like to appear in the editor.

when you edit the profile...don't forget to enable the profile that you would like it to be on.

I love drupal, and I thank you!
zestux freelance web designer in Limousin France

Kudos to all the ideas and quick fixes, but this is maddening. My files are a mess. Time to dump everything and start over - again. Is there actually a solution? Is this the REAL wonderful world of Drupal? Some of us aren't looking to make money off of Drupal. We just want a site. Coding is no problem, well, except for here. Did CK editor hit the market before it was ready? Not hating - just saying. I've given this issue three days of my life and there's no reward. lol

Johnny

Hi @EkkoJohnny, I'm sorry to hear about your trouble. CKEditor certainly is among the "funny" ones. However, Wysiwyg module on the latest Drupal 7 release and a CKEditor (full version recommended, currently I'm using 4.1.0.80) in sites/all/libraries/ckeditor does the trick for me at several installations. After doing what jack-pl suggests, anyway. Then, of course, assigning the editor to text formats at /admin/config/content/wysiwyg and configuring the editor at e.g. /admin/config/content/wysiwyg/profile/filtered_html/edit.

Good luck! At some point, there will be a reward, I promise.

http://geradezu.dk - Beratung und Gestaltung im Bereich online Präsenz

audebytehosting's solution still works for me with CKEditor 4.3.0.d2184ac and Drupal 7.22

Thank you SO MUCH for this fix! I'd been fiddling with this thing for several hours! I really wish the troubleshooting documentation on the developer's site was a little more accommodating, given that this is a pretty huge issue if you want to use the @font-your-face module, which requires Wysiwyg, and in combination with that, if you also want to use the latest and greatest version of CKEditor, *not* using Wysiwyg really isn't an option.

BTW, I realize that this thread has become pretty long in the tooth, and that there have been numerous fixes suggested here to solve this issue since the thread began in May of 2011. A lot of the fixes seemed to work for a time before other code changes in one of the modules ended up braking things again. However, I wanted to note that while alexPalumbo's post from nearly a year ago was to accommodate version 4.01 of CKEditor, I've just applied it to version 4.3.0.d2184ac and it still worked like a charm (I'm currently using Drupal 7.24, BTW). So hopefully this means that the patch will hold together for quite sometime to come.

Thanks again to Alex, and to all the rest'a you brainiacs out there as well, helpin' us newbs out in our time of greatest need. :)

********
Jimbobwe

CKEditor 4.3.3.7841b02
Drupal 7.26

Thanks