#1 February 2, 2015 2:20pm

varavin
Member
Registered: June 19, 2014
Posts: 3

TinyMCE applies to random fields on localhost

Every time I open a module item for editing on local server (Windows 7), TinyMCE applies randomly to various fields. Here are some screenshots of what I see if I open the editing form and hit F5. With enough luck you may even see TinyMCE applied to Date field:

http://i59.tinypic.com/v4w8ao.jpg
http://i58.tinypic.com/8ycpyr.jpg
http://i61.tinypic.com/2s63rpf.jpg

The bug is browser-independent - chrome, ff, ie, even old opera 12. Everything is fine on a shared hosting, though, so it's not much of a problem, but still a bit inconvenient... Any ideas?

Offline

#2 February 2, 2015 3:04pm

timbuckingham
Administrator
From: Baltimore, MD
Registered: April 2, 2012
Posts: 974

Re: TinyMCE applies to random fields on localhost

Can you view source and email me the code for a few different instances? What server setup are you using?

Thanks,
Tim

Offline

#3 February 25, 2015 1:10pm

randyhook
Member
Registered: February 25, 2015
Posts: 6

Re: TinyMCE applies to random fields on localhost

I actually found a bug which is causing this to occur. Each field is given a unique id via the uniqid() php function. Sometimes the field creation process happens so fast that uniqid() does not actually create something unique. Therefore, two or more fields receive the same id which messes up the javascript.

The statement in question is in two places:
Line 61 of core/admin/auto-modules/forms/_form.php
Line 52 of core/admin/ajax/pages/get-template-form.php

It looks like this:
$field["id"] = uniqid("field_");

To fix the problem, I initiated a counter called $fCounter before the foreach loop that this statement is in, then modified the statement to the following:
$field["id"] = uniqid("field_") . $fCounter++;

So simply appending a new number to each field's id took care of the problem.

Offline

#4 February 25, 2015 1:27pm

timbuckingham
Administrator
From: Baltimore, MD
Registered: April 2, 2012
Posts: 974

Re: TinyMCE applies to random fields on localhost

Thanks for tracking down that bug, Randy! Are you running into this on a Windows environment or in a *NIX environment as well?
Reading into the uniqid docs on php.net it looks like Cygwin implementations of PHP are going to have the current BigTree uniqid implementation fail since we're not requesting additional entropy.

It probably makes sense to generate a random namespace once before we start drawing a form and then use your field counter method, that way we don't have to call uniqid but have a pretty good chance of not having an ID collision with anything else on the page due to the random character nature of uniqid.

Offline

Board footer

Powered by FluxBB

The Discussion Forum is not available on displays of this size.