1

Drupal The version of TinyMCE could not be detected

This is due to the fact that the tinymce.inc file included with the WYSIWYG module is only set to read the first 100 chars of the tiny_mce.js file to find the version number. For the latest version which is at the time of writing 3.3.9.3 stable or 3.4b2 beta and the last couple of minor updates this has been broken. The way around it is to change the tinymce.inc  read limit from 100 chars to 200 chars. To do this replace the code on line 87 from this: $line = fgets($script, 100); to this: $line = fgets($script, 200); alternatively just paste this entire method over the function wysiwyg_tinymce_version($editor) method

/**
* Detect editor version.
*
* @param $editor
*   An array containing editor properties as returned from hook_editor().
*
* @return
*   The installed editor version.
*/
function wysiwyg_tinymce_version($editor) {
$script = $editor['library path'] . '/tiny_mce.js';
$script = fopen($script, 'r');
// Version is contained in the first 200 chars.
$line = fgets($script, 200);
// 2.x: this.majorVersion="2";this.minorVersion="1.3"
// 3.x: majorVersion:'3',minorVersion:'2.0.1'
if (preg_match('@majorVersion[=:]["\'](\d).+?minorVersion[=:]["\']([\d\.]+)@', $line, $version)) {
fclose($script);
return $version[1] . '.' . $version[2];
}
fclose($script);
}

From lines 74 to 95 respectively or download the attached file tinymce unzip and use it to overwrite the exiting one in your /sites/all/modules/wysiwyg/editors/ folder.

Jason Edwards

  • Carlos

    Important! All the file tiny_mce.js content must be in the first line. In my case, after apply format to all folder files by error, the file was in several lines, and wysiwyg_tinymce_version function only reads the first line to find the version. So to solve this problem, check out if all your file content is in the first line!