TinyMCE changed the way its version is written in tinymce.js. They added spaces around the "=" of "majorVersion=", and split majorVersion and minorVersion on two lines. The fgets, and the preg_match, in editors/tinymce.php, are now unable to get the version number.

Patch included.

tinymce.js remains unmodified on this part on 6.x-2.x-dev and 7.x-3.x-dev, so I suppose those version are affected too… and can get the patch applied, too.

Comments

twod’s picture

Thank you for reporting and patching this! I didn't even know there was a new version up yet. Yes, all the versions of Wysiwyg currently use the same editor implementations. I'll test this ASAP. Only comment I have for now is whether it would be more appropriate to use \s instead of just a space?

sun’s picture

Status: Active » Needs work
+++ modules/wysiwyg/editors/tinymce.inc	Sat Dec 26 16:39:25 2009
@@ -83,10 +83,10 @@
-  $line = fgets($script, 80);
+  $line = fread($script, 80);

I don't see why we would want to change this - please revert.

+++ modules/wysiwyg/editors/tinymce.inc	Sat Dec 26 16:39:25 2009
@@ -83,10 +83,10 @@
   // 2.x: this.majorVersion="2";this.minorVersion="1.3"
   // 3.x: majorVersion:'3',minorVersion:'2.0.1'

We want to append another example for the new version string (just copy + paste), so we can track back the origins of this regular expression later.

+++ modules/wysiwyg/editors/tinymce.inc	Sat Dec 26 16:39:25 2009
@@ -83,10 +83,10 @@
-  if (preg_match('@majorVersion[=:]["\'](\d).+?minorVersion[=:]["\']([\d\.]+)@', $line, $version)) {
+  if (preg_match('@majorVersion *[=:] *["\'](\d).+?minorVersion *[=:] *["\']([\d\.]+)@s', $line, $version)) {

Like TwoD already mentioned, we should use \s* instead of a space.

This review is powered by Dreditor.

guillaume.outters’s picture

Status: Needs work » Closed (fixed)

Wow, forget everything I said. I was using tinymce's source version (that is, before being whitespace-compacted). This explains all those spaces, and newlines, I encountered mysteriously.

Sorry for the time loss… I'll try to submit something useful next time.

twod’s picture

No worries. In the future we want to let users chose which editor library variant to load, which would be useful when debugging etc. When that gets in, documentation on this issue will be really nice to have.

guillaume.outters’s picture

StatusFileSize
new808 bytes

No worries. […] documentation on this issue will be really nice to have.

Wow (twice)… I couldn't have expected a more optimist and nice reaction than yours. In fact, I hadn't even imagined one could react this way. Thanks!

So, in case tiny_mce_src.js ever get used (this time intentionally…), I polish the patch (spaces, comment, and the fread for that _src.js has a newline between major and minor version).

twod’s picture

Always nice when people want to help! =) Thanks again for the patches.

@sun, fgets stops at newlines, fread doesn't. However, according to http://se.php.net/manual/en/function.fread.php we should also use the 'b' (binary) option to fopen or we may encounter problems on Windows platforms.

sun’s picture

The consideration for using fgets() was to stop a newlines, to not read more lines of a file than we want.

None of the files we want to parse are binary files... did I overlook something important on that page?

Please re-open this issue if you think there's room for investigation.

guillaume.outters’s picture

No, no need to reopen: the current implementation is correct, and does not require the fread. But we were discussing its necessity in the "you know one day we will allow routing to tiny_mce_src.js instead of tiny_mce.js" case: in the _src.js file, the version number is effectively cut in half by a newline.

sun’s picture

Title: TinyMCE 3.2.4.1 not detected » Source download package variant of TinyMCE not detected
Version: 6.x-2.0 » 6.x-2.x-dev
Priority: Normal » Minor
Status: Closed (fixed) » Active
Issue tags: +Libraries

oh, I see! Now I feel dumb. Sorry for not recognizing this detail!

That's indeed a problem, and wasn't the case in earlier versions of TinyMCE. Damn. This hardens the migration to Libraries API, and I'm not sure how a keep-it-simple regex/solution could be able to parse the version info in both cases -- without introducing a separate version parsing function for library variants.

Tagging with global d.o Libraries tag. (you need to remove the project name from the URL to see all issues)

jimmb’s picture

Hello, I'm not a programmer and as such cannot follow much of what's said in this thread. But I just downloaded the latest source version of TinyMCE (Version: 3.3b1) for the 6.x-2.0 version of WYSIWYG.

After I placed the latest TinyMCE into the /sites/all/libraries directory, Drupal wasn't able to detect it. So I'm not sure what to do at this point. Any advice (tailored to a non-programmer) would be much appreciated!

Thanks,

Jim

twod’s picture

That is an unrelated issue, which I'm currently working on. For a quick workaround, either download the previous release (recommended) or change the value on line 86 in wysiwyg/editors/tinymce.inc from 80 to 100, and remove line 21 from editors/js/tinymce-3.js. You won't get the new 'Advanced Lists' plugin, and you should NOT enable the 'Safari' compatibility plugin. This version of TinyMCE is still in Beta, since they've changed a lot internally. I will open a new issue about this shortly.

twod’s picture

Umm guys, aren't we missing something?
@guillaume.outters, am I correct when guessing that you renamed tiny_mce_src.js to tiny_mce.js in order to use the source version?

wysiwyg_tinymce_version($editor) only looks at tiny_mce.js, and the source variant is always located in tiny_mce_src.js, meaning that even if we add an option to change the variant to load, the actual file looked in for version info will stay the same.

The file header can be different for each of the variants (normal/minified, _src, _dev), so it makes sense to only look at one of those files to simplify the version parsing. As we encourage users not to edit or [re]move any files in the library folders after extracting them, this should also be safe to do regardless of which version the user actually wants to use. (I doubt anyone will complain about the few extra kb of diskspace 'wasted' by leaving tiny_mce.js in there if they only want to use tiny_mce_src.js).

So, is this a non-issue?

sun’s picture

Status: Active » Closed (won't fix)

erm, sure, we at least can defer worrying about that entire topic to when we support different library variants in the first place. ;)

See #374391: Allow to configure editor library variant to load

guillaume.outters’s picture

@TwoD: you're correct about my unorthodox file renaming.

On the plus side, we now know that the TinyMCE src variant will work with only a filename switch and not so much modifications in Wysiwyg.

jhans’s picture

Hi

I detected the problem today but after patching the include file problem persits. I have not really knowledge about php but after investigating the tiny_mce.js file I recognized 80 characters are not enough to get major and minor version. I changed the number of characters from 80 to 100 and now it runs. The minor version ends at character 91.

Best regards
Joachim

sjovanig’s picture

Status: Closed (won't fix) » Active

Hi,

Problem still exists with WYSIWYG 6.x-2.1 and TinyMCE 3.9.2.

To fix it, I had to increase from 100 to 200 bytes at line 87 in file editors/tinymce.inc.

Regards.

twod’s picture

Status: Active » Closed (won't fix)

Please check with the latest -dev before reporting issues like this. The problem was fixed a while ago using that very same solution in #695398: Support for TinyMCE 3.3.
This applies to all TinyMCE variants, not just the Source variant.

felipesluz’s picture

Tank´s "lesergi" ..........