WordPress.org

Make WordPress Core

Opened 12 years ago

Closed 12 years ago

Last modified 12 years ago

#3882 closed defect (bug) (fixed)

An error commented in forums: tinyMCE not defined

Reported by: josegonzalez Owned by: ryan
Milestone: 2.2 Priority: normal
Severity: normal Version: 2.1.2
Component: TinyMCE Keywords:
Focuses: Cc:

Description (last modified by foolswisdom)

Some versions of PHP like mine have a problem with the php function realpath. Its a buggy function and for this reason some users experiment a frustration beacuse the visual editor included with wordpress (tinyMCE) is not working properly. The small editor toolbar does not appear when you want to create or modify a document and the visual editor option is activated for the user.

I modified the file tiny_mce_gzip.php and I send it to you. The new substitution function is call real_path and is a copy of an example that appears in www.php.net.

I hope this report is usefull for every wordpress user and as a suggestion I think that in future releases of this gorgeus blog software it could be appear in the administration panel a checkbox in Options->Write with the subject "buggy realpath function". If you check this option wordpress will use an alternative function.

Attachments (2)

tiny_mce_gzip.php (11.4 KB) - added by josegonzalez 12 years ago.
3882.diff (4.3 KB) - added by foolswisdom 12 years ago.
trunk diff based on josegonzalez attached tiny_mce_gzip.php

Download all attachments as: .zip

Change History (37)

#1 in reply to: ↑ description ; follow-up: @foolswisdom
12 years ago

  • Milestone set to 2.2

Replying to josegonzalez:

Some versions of PHP like mine have a problem

What version of PHP is that?

Is there links you can provide for background information about the problem?

@foolswisdom
12 years ago

trunk diff based on josegonzalez attached tiny_mce_gzip.php

#2 @Otto42
12 years ago

Not sure about what the problem is, but that real_path function in the diff is ripped straight from the comments on PHP.net: http://php.net/realpath

#3 in reply to: ↑ 1 @alexrabe
12 years ago

Replying to foolswisdom:

Is there links you can provide for background information about the problem?

I had a similar problem with some users of my plugins, the reason is based also on the realpath problem and a TinyMCE failure :

a.) If you add a external plugin to TinyMCE the ($_GET['plugins']) contains a empty field at the end : (inlinepopups, autosave, spellchecker, paste, wordpress,). Note the "," at the end.

FYI : A external plugin is added with a hyphen

array_push($plugins, '-mypluginname');

b) The OpenBSD contain a bug as explained in http://php.net/realpath : On BSD systems realpath doesn't fail if only the last path component doesn't exist, while other systems will return FALSE.

So it happend that

TinyMCE_echo(file_get_contents($pluginFile));

is executed and look for a empty $pluginFile and return so a error, which halted TinyMCE

#4 @alexrabe
12 years ago

Today I figure out that also a Linux/Debian (PHP 4.4.5) contains the realpath problem.

This small test didn't return a FALSE :

$x = realpath('/bad/path'); var_dump($x);

A workaround in tiny_mce_gzip.php for the realpath problem could be :

$plugins = explode(",", $plugins);
foreach ($plugins as $plugin) {
	if ($plugin != '') {
		$pluginFile = real_path("plugins/" . $plugin . "/editor_plugin" . $suffix . ".js");
		/* WP $languageFile = realpath("plugins/" . $plugin . "/langs/" . $lang . ".js"); WP */

		if ($pluginFile)
			TinyMCE_echo(file_get_contents($pluginFile));

		/* WP if ($languageFile) WP */
		TinyMCE_echo(wp_tinymce_lang("plugins/" . $plugin . "/langs/%s.js")); // WP
	} //avoid realpath problem
}

#5 @alexrabe
12 years ago

  • Milestone changed from 2.2 to 2.1.3
  • Priority changed from low to normal

This small issue affected the most popular plugins for Video/Image Integration in TinyMCE : Imagemanager, Anarchy Video Player, Vipers Video Quicktags, wordTube, myGallery.

A bugfix/workaround should not shifted to 2.2

#7 @ryan
12 years ago

The latest tinyMCE and tinyMCE Compresser are here. Looking at the latest compressor, it looks like they fixed this in their getFileContents() wrapper. We need to merge in the latest compressor code and use getFileContents in the WP specific code we've added.

#8 @alexrabe
12 years ago

Yes, this update of tinyMCE fix the BSD / realpath problem.
Thanks, Ryan

#9 @g30rg3x
12 years ago

  • Keywords needs-patch added

Did someone will patch this or someone its working with them????

I have the same problem with:
PHP Version 5.0.4
Apache/2.0.54 (On Fedora)
And other several host...
There is a real solution to the problem????

#10 @g30rg3x
12 years ago

  • Version changed from 2.1.1 to 2.1.2

#11 @ihad
12 years ago

This is a bug introduced with WP 2.1.2.
TinyMCE will display erratic behavior and stick to Code view on the write page in various situations on various systems. It is probably linked to one of the below errors.

"Firebug" log for: /wp-admin/post-new.php

syntax error
<!DOCTYPE html PUBLIC "-W3CDTD XHTML 1.0 TransitionalEN" "http://www.w3.or...
post-new.php (line 1)

realTinyMCE is not defined
onLoad()tiny_mce_gzip.php (line 43)
tinyMCE = realTinyMCE;
tiny_mce_gzip.php (line 43)

#12 @ihad
12 years ago

Addendum:

When autosave is triggered from the write (post-new.php) page, the following error occurs (in WP 2.1.2, does not happen with WP 2.1.1 or prior versions):

tinyMCE.getInstanceById is not a function

var rich = ((typeof tinyMCE != "undefined") && tinyMCE.getInstanceById('content...

autosave-js.php (line 99)

#13 @ihad
12 years ago

Addendum #2:

When trying to switch editor views the following error occurs in WP 2.1.2:

switchEditors is not defined
onclick(click clientX=0, clientY=0)
post-new.php (line 1)

The "Visual" Tab cannot be clicked at all and the "Code" tab when clicked produces the above error.

#14 @ihad
12 years ago

Just FYI
Using the here attached tiny_mce_gzip.php file produces the following errors in 2.1.2:

tinyMCE is not defined
tinyMCE.init(initArray);
tiny_mce_config.php (line 36)

tinyMCE is not defined
post-new.php (line 377)

#15 @ryan
12 years ago

  • Owner changed from anonymous to ryan

#16 @ryan
12 years ago

(In [5108]) Update to latest tinyMCE compressor. Simplify MCE language loading. see #3882

#17 @ryan
12 years ago

Committed updated tiny_mce_gzip.php to trunk. Let's see if that helps.

#18 @ihad
12 years ago

applied the tiny_mce_gzip.php from the trunk to the 2.1.2 install. the errors are the same.
have not tried with the latest nightly build though.

#19 @ryan
12 years ago

(In [5114]) Fallback to loading english for tinyMCE if requested locale is not there. see #3882

#20 @g30rg3x
12 years ago

The problem persist...
Error: realTinyMCE is not defined
Archivo Fuente: [HOST]/[PATH]/wp-includes/js/tinymce/tiny_mce_gzip.php?ver=20070326
Línea: 43

tested with the latest svn build (2.2-bleeding)

#21 @ryan
12 years ago

The patch should fix the realpath problem. I don't know about the rest.

#22 @g30rg3x
12 years ago

well i have been testing and seems to be a problem related with Firefox, because under IE 7 and Opera 9.10 the RTE goes very well...

#23 @foolswisdom
12 years ago

  • Description modified (diff)

#24 @g30rg3x
12 years ago

  • Keywords 2nd-opinion added; needs-patch removed

finnally fixed, after houndred of differente scenarios and tests y finally get to solve the problem... the problem its not on server side its client side...
There is a problem with JavaScript and firefox some strange situation that i couldnt figure out, but the only solution that i found its to reinstall from zero firefox... this solves magically all realTinyMCE its not defined

#25 @wpuser2
12 years ago

  • Keywords 3nd-opinion added; 2nd-opinion removed

My story: moved WP installation to new php (4.4.2 via fastcgi), and got the realtinymce error. I also noted another error, bold_img : \"bold.gif\", illegal char. This aborted further javascript processing, causing the later realTinyMCE error to occur.

It seems my new php escaped the quotation marks! I modified ./wp-includes/js/tinymce/langs/en.js to use single quotes instead of double quotes, and it worked:

bold_img : 'bold.gif',
italic_img : 'italic.gif',
underline_img : 'underline.gif',

Does this solve the problem for the rest of you?

Is there a reason to have double quotes instead of single quotes?

Regards

#26 @Otto42
12 years ago

It looks like the problem may be that you have PHP's "magic_quotes_runtime" enabled.

en.js is pulled through the tiny_mce_gzip.php file, for translation purposes. If PHP has magic_quotes_runtime on, it will escape the quotes (although I thought it should escape single quotes too).

Try adding set_magic_quotes_runtime(0); to /wp-includes/js/tinymce/tiny_mce_gzip.php and see if that makes any difference.

#27 @g30rg3x
12 years ago

  • Keywords 2nd-opinion added; 3nd-opinion removed

after some research (sorry for being so late, but the research take me a lot of time, so i almost forget to visit the wordpress trac) i found a problem and a solution

Like i say before i tested under firefox, Internet explorer and opera and only firefox has the problem so after a "from-zero" install, the problem completely disappear but after a i install my extensions the problem comes back, obviously i uninstall one-by-one and discover that actually the extension "NoScript" was the problem, because even the site is in "allow/trusted site list" or much major problem even with "globally allowed" turned on, we don't get the RTE and we see the error "realTinyMCE its not defined".
So after many test and scenarios i contacted the NoScript Development team and after so many more test and mails we found that the error actually is that noscript doesn't process well dynamically generated scripts (like tiny_mce_gzip.php), obviously this well fixed some days ago and now this fix is in "1.1.4.7rc2 (070409)"
NoScript Development version

So for all people that use "NoScript extension" i recommend trying to use the latest development version and see if this fixed the problem, for me this obviously fixed completly any problem on any of the three milestones avalible on wordpress...

Props goes to Giorgio Maone (NoScript Chief Developer)

#28 @foolswisdom
12 years ago

  • Milestone changed from 2.1.4 to 2.2

#29 @rob1n
12 years ago

  • Resolution set to fixed
  • Status changed from new to closed

The original issue (and some others) have been fixed. Please open other tickets for separate issues.

#30 @welcomb
12 years ago

How is this fixed? I'm testing it on a Wordpress 2.1.3 upgrade with no plugins activated and the problem still exists. I tried using IE7 and it also has the realTinyMCE undefined. So it's not just a Firefox problem.

My host is using PHP 4.4.2. Might that be a cause?

#31 @welcomb
12 years ago

btw, my PHP doesn't suffer from the realpath bug documented here: http://bugs.php.net/bug.php?id4552

#32 @foolswisdom
12 years ago

welcomb, the milestone is 2.2, so it is fixed in the development branch.

#33 follow-up: @welcomb
12 years ago

funny... I thought I downloaded the latest branch from the SVN. I'll try again. Thanks.

#34 in reply to: ↑ 33 ; follow-up: @g30rg3x
12 years ago

  • Keywords 2nd-opinion removed

Replying to welcomb:

funny... I thought I downloaded the latest branch from the SVN. I'll try again. Thanks.

you should try with opera too, if opera came with the same problem well your problem its server related (not client) try the Otto42 advice

#35 in reply to: ↑ 34 @welcomb
12 years ago

Replying to g30rg3x:

Replying to welcomb:

funny... I thought I downloaded the latest branch from the SVN. I'll try again. Thanks.

you should try with opera too, if opera came with the same problem well your problem its server related (not client) try the Otto42 advice

I tried Opera and the same problem persist. "magic_quotes_runtime" is off on my server (I checked with phpinfo) and to be sure I also added the line as Otto42 advised.

I'm also getting illegal character ? on line 2 of tiny_mce_gzip.php in Firebug.

Note: See TracTickets for help on using tickets.