Page MenuHomePhabricator

JavaScript error prevents WikiEditor from showing up
Closed, ResolvedPublic

Description

When using WikiEditor together with SemanticForms, and editing a which has textareas but no text area for the main content, I get a following JavaScript error:

Uncaught TypeError: Cannot read property 'selectionStart' of undefined jquery.textSelection.js:352
getCaret jquery.textSelection.js:352
fn.getCaretPosition jquery.textSelection.js:359
$.fn.textSelection jquery.textSelection.js:565
$.fn.wikiEditor jquery.wikiEditor.js:491
(anonymous function) ext.wikiEditor.js:6
fire load.php?debug=true&lang=fi&modules=jquery%2Cmediawiki&only=scripts&skin=vector&version=20140423T14…:974
self.add load.php?debug=true&lang=fi&modules=jquery%2Cmediawiki&only=scripts&skin=vector&version=20140423T14…:1020
jQuery.fn.jQuery.ready load.php?debug=true&lang=fi&modules=jquery%2Cmediawiki&only=scripts&skin=vector&version=20140423T14…:246
(anonymous function) ext.wikiEditor.js:4


Version: master
Severity: major

Details

Reference
bz64289

Event Timeline

bzimport raised the priority of this task from to Unbreak Now!.Nov 22 2014, 3:12 AM
bzimport set Reference to bz64289.
bzimport added a subscriber: Unknown Object (MLST).

This error is also showing up on Wikipedias.

This happens when something loads the 'ext.wikiEditor' module on a page with no #wpTextbox1. WikiEditor then tries to get the caret position (using the 'jquery.textSelection' module) in a non-existent <textarea> and it blows up.

It's amazing that this has ever worked, but if it did, then it probably should keep working. textSelection probably shouldn't throw errors in this case, as jQuery functions generally handle empty collections just fine.

Change 129683 had a related patch set uploaded by Bartosz Dziewoński:
jquery.textSelection: Don't throw errors on empty collections

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

Change 129683 merged by Mwalker:
jquery.textSelection: Don't throw errors on empty collections

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

BTW, anyone got actual examples of such pages ?

It's helpful to be able to take such pages into account with future changes to WikiEditor perhaps.

Change 129813 had a related patch set uploaded by Mwalker:
jquery.textSelection: Don't throw errors on empty collections

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

mwalker wrote:

OK; I've reverted the original patch that caused this issue to surface [1] (because it's Friday and that was safer than deploying this.) The plan is to deploy the fix [2] to this bug on Monday, and then deploy the revert to the revert that I did today on Tuesday once we know this patch doesn't cause issues.

[1] https://gerrit.wikimedia.org/r/#/c/129807/
[2] https://gerrit.wikimedia.org/r/#/c/129813/

Increasing priority due to comment 1 (comment 0 only mentioned SemanticForms)

Change 129813 merged by Mwalker:
jquery.textSelection: Don't throw errors on empty collections

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

Where are we with this ? Do we still need to do the revert of the revert ?

Does anyone have a good test case that doesn't require a full install of semantic mediawiki ?

The patch has now been reapplied in 1.24wmf2

Everything should be fixed, then.

Requesting backport of Ib97f47ef1d66420682bd429c9c12e66c3392e77d to fix editing with forms in tieteentermipankki.fi

Change 133942 had a related patch set uploaded by TheDJ:
jquery.textSelection: Don't throw errors on empty collections

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

Change 133942 merged by jenkins-bot:
jquery.textSelection: Don't throw errors on empty collections

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

Change 134616 had a related patch set uploaded by Krinkle:
Sync 1.23 release notes for bug 64289 from REL1_23

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

Change 134616 merged by jenkins-bot:
Sync 1.23 release notes for bug 64289 from REL1_23

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

All patches merged, closing again.