Last modified: 2014-08-22 09:46:32 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T70556, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 68556 - [Regression] Disabled CodeEditor prevents toolbar functions to work
[Regression] Disabled CodeEditor prevents toolbar functions to work
Status: RESOLVED FIXED
Product: MediaWiki extensions
Classification: Unclassified
CodeEditor (Other open bugs)
unspecified
All All
: High major (vote)
: ---
Assigned To: Derk-Jan Hartman
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2014-07-25 08:57 UTC by Michael M.
Modified: 2014-08-22 09:46 UTC (History)
4 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description Michael M. 2014-07-25 08:57:21 UTC
Steps to reproduce:
1. Open any page CodeEditor works on for editing, e.g. https://de.wikipedia.org/w/index.php?title=Modul:Foo&action=edit&redlink=1
2. Click the icon to disable CodeEditor.
3. Use any function of the toolbar, e.g. insert a special character, or try to search and replace something.

Expected result: The special character should be inserted, search&replace be executed.
Actual result: An error is thrown: TypeError: context.codeEditor is undefined

This might be related to https://gerrit.wikimedia.org/r/139690
Comment 1 Derk-Jan Hartman 2014-07-25 10:50:10 UTC
Are we sure that that is a regression ? Because if a take a peek at textSelection, it seems like it would have done that in the past as well..

Will have to investigate a bit.
Comment 2 Michael M. 2014-07-26 07:52:23 UTC
(In reply to Derk-Jan Hartman from comment #1)
> Are we sure that that is a regression ? Because if a take a peek at
> textSelection, it seems like it would have done that in the past as well..

Yes, I am sure. I have CodeEditor disabled, and use several user scripts that use the textSelection API, and they just broke yesterday.

After a quick look: When you disable CodeEditor, context.$iframe is set to undefined [1], which previously was recognized by textSeclection as to use the default methods, while the mentioned change removed that check. So now the code always tries to call the methods provided by CodeEditor, but these fail when it is disabled.

[1] https://git.wikimedia.org/blob/mediawiki%2Fextensions%2FCodeEditor/56b9e4c350c122e105949b0faefa25f17253335b/modules%2Fjquery.codeEditor.js#L276
Comment 3 Derk-Jan Hartman 2014-07-26 13:23:30 UTC
Bingo got it. Now to find a better way to fix this....
and more importantly.. document it...
Comment 4 Bartosz Dziewoński 2014-07-27 14:40:01 UTC
Was https://gerrit.wikimedia.org/r/#/c/149529/ a fix for this bug?
Comment 5 Derk-Jan Hartman 2014-07-28 19:45:46 UTC
Yuck...

This is really all down to the fact that the textSelection api was once a part of the WikiEditor api.

That separation was never really properly finished and that is why in the CodeEditor this api is now 'mixed' up with the WikiEditor api. Add to this that CodeEditor made it  possible to enable and disable on the fly and you have one big mess...

So this bug is because I failed to realize that the CodeEditor could be disabled in the same session and that this would 'break' the function mapping in:

http://git.wikimedia.org/blob/mediawiki%2Fextensions%2FCodeEditor.git/ad908b2da64da4083e10e391153112978fb9df8f/modules%2Fjquery.codeEditor.js#L517

There we basically assign the 'textSelection' api functions into the WikiEditor api. The disabling works fine for the WikiEditor API functions, because they listen to the conditional in L508, but the textSelection APIs are no longer part of the wikiEditor api's and stuff start breaking.

I'm thus going to reintroduce iframe check and then submit a new patch that does some very simple API registration to replace the textSelection API if a textfield/area wants to do that.
Comment 6 Gerrit Notification Bot 2014-07-28 19:54:50 UTC
Change 150009 had a related patch set uploaded by TheDJ:
jquery.textSelection: re-add iframe check due to regression

https://gerrit.wikimedia.org/r/150009
Comment 7 Gerrit Notification Bot 2014-07-28 21:30:39 UTC
Change 150009 merged by jenkins-bot:
jquery.textSelection: re-add iframe check due to regression

https://gerrit.wikimedia.org/r/150009

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links