YUI editor: Version detection not working
toddgeist - February 23, 2009 - 01:18
| Project: | Wysiwyg |
| Version: | 6.x-2.x-dev |
| Component: | Editor - YUI Rich Text Editor |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed |
Description
Downloaded and installed the YUI and markitup, neither loaded. I got errors looking for the README files in each folder. These files where not in the downloads from either YUI or markitup. I created them and placed the version number inside hoping it would fullfill the requirements but it did not.
TinyMCE is working just fine though!
Thanks
Todd

#1
The README file is needed to determine the version of the YUI and its location was changed to "releasenotes/README.base". This patch will help.
#2
#3
The patch works for me:
after applying the patch to the 6.x-2.x-dev version of Wysiwyg API the YUIeditor v2.7.0 installs without problems.
#4
The same solution works for markitup, too
I opened a new thread for the markitup solution here: #385736: markItUp: Wrong editor library location
#5
Version detection WFM with YUI 2.70b, but Editor is not loading... :-/
#6
Please test attached patch.
#7
#8
d.o eated my comment :-(. New patch as the one above does not work and stops processing on the first copyright line with 2009 inside. I have added the version in front and now it WFM.
/*Copyright (c) 2009, Yahoo! Inc. All rights reserved.
Code licensed under the BSD License:
http://developer.yahoo.net/yui/license.txt
version: 2.7.0
*/
#9
Aside - do we already have a case for this error that prevents loading of the editor?
YAHOO.widget.Editor is not a constructorhttp://localhost/drupal6/sites/all/modules/wysiwyg/editors/js/yui.js?2
Line 10
#10
Follow-up #390224: YAHOO.widget.Editor is not a constructor
#11
Committed to all branches.
#12
Automatically closed -- issue fixed for 2 weeks with no activity.
#13
This still doesn't work, for wysiwg 6.x-2.0 using YUI editor 2.8.0r4.
The problem appears to be the version check regex in wysiwyg_yui_version() (yui.inc); it does not allow for 'r' in the version string.
<?php$library = $editor['library path'] . '/editor/editor.js';
$library = fopen($library, 'r');
$max_lines = 10;
while ($max_lines && $line = fgets($library, 60)) {
if (preg_match('@version:\s([0-9r\.]+)$@', $line, $version)) {
fclose($library);
return $version[1];
}
$max_lines--;
}
?>
'@version:\s([0-9\.]+)$@'is at fault. I personally just changed it to'@version:\s([0-9r\.]+)$@'but I don't think that's a future-proof fix.HTH
#14
@Mike_Waters,
I would greatly appreciate your explanation as to why '@version:\s([0-9\.]+)$@' is at fault and why it is not future-proof.
Your solutions seems to have done the trick for me. However, i would still appreciate an explanation.
Thanks,
Tom
#15
that regex only allows for digits and a dot (.) to appear in the version string (e.g. 2.70). The current yui editor version has an 'r' in it (stands for 'revision'; ex. 2.70r4 for revision 4 of version 2.70), and so the regex test failed and the version was not detected. adding 'r' to the regex allowed the version to be properly detected. This is not an optimal solution however; if yahoo decided to add a new characteer to the revision string, version detection would break again. for example, a beta release might be called 2.70b5; this string would not be detected by the regex. that is why my fix is not future proof, and so i did not submit a patch. HTH
#16
Marking this as active again, as the problem have resurfaced again after the r* version. Had the same problem here: #581236: The version of YUI editor could not be detected.
#17
Marked #581236: The version of YUI editor could not be detected. a duplicate of this.
Looking at older releases of YUI, it seems they just append a, b or r# so I think we'd be pretty safe with
'@version:\s([0-9abr\.]+)$@'. What do you think?#18
Please just remove the trailing $ in the regex.
"2.70r4" will then be "2.70", regardless of a, b, r, foo. I hope and guess that "2.70" is the official version, and "r4" is just an incremental build number, and the API will keep the same within "2.70".
If that assumption is not the case, then we probably need
([0-9\.-])(a-z)?([0-9\.-])?, and potentially, we need to translate the optional character in the middle into "alpha" (a), "beta" (b), or nothing (r) to make it compatible to PHP's version_compare().2.70 => 2.70 (major release)2.70a2 => 2.70-alpha-2 (second alpha BEFORE major release)
2.70b1 => 2.70-beta-1 (first beta after alphas BEFORE major release)
2.70r4 => 2.70.4 (minor release 4 AFTER major release)
version_compare() already performs this logic, but requires certain strings to my knowledge. (I may be mistaken though)
#19
Good point Sun. We will most likely never need that detailed info about the version in use to be able to determine if a plugin or setting etc should be available to the user.
Hmm, after some reading, it seems they "may" change the API even in beta releases. But I highly doubt they'll change the initialization and other parts we're relying on that easily.
#20
Version 2.8.0r4 is out now and does not work with this module due to this bug
#21
I just got 2.8.0r4 to work by following http://drupal.org/comment/reply/380586/2094274#comment-2044722
#22
Yes, here is the simple change (hack) needed for the latest YUI editor to load.
#23
Committed to all branches. Thanks for reviewing, testing and patching!
This should be in the -dev snapshots within a few hours.
#24
how to apply the patch please ?
#25
@aiphe, http://drupal.org/patch/apply
The patch only removes the $ at the end of the regular expression, so it's just as easy to apply it by hand.
Note that if you're using the -dev version, you do not need to apply the patch if you have the latest snapshot as this fix is now in it.
#26
thanks for help
you're speaking the wysiwig version ?
#27
Yes
#28
@Mike_Waters
This fix worked fr me - thanks!
This is on line 72 of wysiwyg/editors/yui.inc
jdw
#29
Automatically closed -- issue fixed for 2 weeks with no activity.