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

djem - February 23, 2009 - 08:45
Assigned to:Anonymous» djem

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.

AttachmentSize
yui.inc_.patch.txt 343 bytes

#2

sun - February 23, 2009 - 13:18
Status:active» needs review

#3

deshilachado - February 27, 2009 - 13:46
Version:6.x-1.0» 6.x-2.x-dev
Status:needs review» reviewed & tested by the community

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

deshilachado - February 27, 2009 - 14:01
Title:can't load YUI markitup» YUIeditor installation: path to readme.txt wrong

The same solution works for markitup, too
I opened a new thread for the markitup solution here: #385736: markItUp: Wrong editor library location

#5

hass - March 2, 2009 - 01:43

Version detection WFM with YUI 2.70b, but Editor is not loading... :-/

#6

sun - March 3, 2009 - 19:03
Assigned to:djem» Anonymous
Status:reviewed & tested by the community» needs review

Please test attached patch.

AttachmentSize
wysiwyg-HEAD.yui-version.patch 1.02 KB

#7

sun - March 3, 2009 - 19:04
Title:YUIeditor installation: path to readme.txt wrong» YUI editor: Version detection not working

#8

hass - March 3, 2009 - 21:58

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
*/

AttachmentSize
wysiwyg_yui_version_detection_bug-D6.patch 1016 bytes

#9

hass - March 3, 2009 - 22:03

Aside - do we already have a case for this error that prevents loading of the editor?

YAHOO.widget.Editor is not a constructor
http://localhost/drupal6/sites/all/modules/wysiwyg/editors/js/yui.js?2
Line 10

#10

hass - March 3, 2009 - 22:32

#11

sun - March 4, 2009 - 11:28
Status:needs review» fixed

Committed to all branches.

#12

System Message - March 18, 2009 - 11:30
Status:fixed» closed

Automatically closed -- issue fixed for 2 weeks with no activity.

#13

Mike_Waters - September 15, 2009 - 17: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

TomSherlock - September 18, 2009 - 14:20

@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

Mike_Waters - September 18, 2009 - 18:53

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

vegardjo - September 19, 2009 - 17:28
Status:closed» active

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

TwoD - September 20, 2009 - 20:06

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

sun - September 20, 2009 - 21:25

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

TwoD - September 20, 2009 - 22:12

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

ac - September 29, 2009 - 10:25

Version 2.8.0r4 is out now and does not work with this module due to this bug

#21

dncceo - October 2, 2009 - 17:33

I just got 2.8.0r4 to work by following http://drupal.org/comment/reply/380586/2094274#comment-2044722

#22

SimonEast - October 23, 2009 - 00:11
Status:active» needs review

Yes, here is the simple change (hack) needed for the latest YUI editor to load.

AttachmentSize
yui_version_number_fix.patch 462 bytes

#23

TwoD - October 23, 2009 - 03:01
Status:needs review» fixed

Committed to all branches. Thanks for reviewing, testing and patching!
This should be in the -dev snapshots within a few hours.

#24

aiphes - October 28, 2009 - 10:58

how to apply the patch please ?

#25

TwoD - October 28, 2009 - 12:22

@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

aiphes - October 29, 2009 - 20:14

thanks for help

if you're using the -dev version

you're speaking the wysiwig version ?

#27

TwoD - October 29, 2009 - 21:41

Yes

#28

boldart - November 6, 2009 - 15:52

@Mike_Waters

This fix worked fr me - thanks!

This is on line 72 of wysiwyg/editors/yui.inc

jdw

#29

System Message - November 20, 2009 - 16:00
Status:fixed» closed

Automatically closed -- issue fixed for 2 weeks with no activity.

 
 

Drupal is a registered trademark of Dries Buytaert.