Page MenuHomePhabricator

UploadWizard broken in Opera 12.15
Closed, ResolvedPublic

Description

UploadWizard currently errors out on the first screen. Error console with debug mode enabled shows the error "Undefined variable: UploadWizardConfig" is triggered in line 24 of mw.LanguageUpWiz.js. This is with Opera 12.15 on Ubuntu.


Version: unspecified
Severity: critical
See Also:
https://bugzilla.wikimedia.org/show_bug.cgi?id=48515

Details

Reference
bz48091

Event Timeline

bzimport raised the priority of this task from to High.Nov 22 2014, 1:39 AM
bzimport set Reference to bz48091.
bzimport added a subscriber: Unknown Object (MLST).

The same problem with XP and Win7 with Opera 12.15 (Build 1748). UploadWizard doesn't work at all for about 1 week.

Related URL: https://gerrit.wikimedia.org/r/62480 (Gerrit Change Iaf23ae56d610471a8ac2b49b303a96adb957cd48)

The change is based just on the error shown above and has to be verified with the browser. I don't have a Opera installation yet.

I updated my copy of UW and the error didn't show, then updated core to master and its there. The patch doesn't solve the problem for me.

Created attachment 12331
HTML DOM of Special:UploadWizard in debug mode

If you set the config *after* calling mw.loader.load for ext.uploadWizard, this might happen:

  • Browser sees "mw.loader.load"
  • RL creates script tags and inserts them directly after the script node containing the call (creating new script nodes which are above the config)
  • Browser loads all these scripts (requested by RL) synchronously and "sees" the UpWiz config after all scripts have been loaded. Most browsers do this async for scripts inside <body> now, but Opera might behave differently.

As soon as mw.config is available, the UpWiz config can be set.

UpWiz config is shipped directly within the HTML (no separate script). Since mw.config is available as soon as the head-scripts are loaded (which always happens synchronously [except when using a special attribute]) and UpWiz config contains only constants, you can put it directly at the beginning of the body or better, as the last node into the head.

I will upload another image showing the HTML DOM of a browser having JS disabled. You will see that, indeed Opera wrote all script requests directly below the call to mw.loader which is highlighted here.

Attached:

UpWizConfigAfterUpWizLoading.png (464×971 px, 74 KB)

Created attachment 12332
HTML DOM of Special:UploadWizard in debug mode with JS disabled

Attached:

UpWizConfigAfterUpWizLoading2.png (210×757 px, 7 KB)

(In reply to comment #5)

So you suggest that the config should be added into the head, I can try this but how is this done? currently its being added using

		$this->getOutput()->addScript(

(In reply to comment #9)

I think this is what you would want for that:
http://www.mediawiki.org/wiki/Manual:Hooks/MakeGlobalVariablesScript

I tried to hack in https://gerrit.wikimedia.org/r/#/c/64520/ but didn't work in Opera yet.

(In reply to comment #10)

I tried to hack in https://gerrit.wikimedia.org/r/#/c/64520/ but didn't work in
Opera yet.

Please be more specific: What did not work?

Here is what I did:

  1. Installed a local proxy (Fiddler2)

1a) Configurated Opera to use the local proxy
1b) went to http://commons.wikimedia.org/wiki/Special:UploadWizard in Opera

  1. Dumped the UploadWizard HTML page
  2. Enabled auto-response for UploadWizard from the dump; other requests were passed through to the WMF servers
  3. Verified that the Upload Wizard still "hangs" and threw the same error at the JS Error console
  4. MODIFIED THE DUMP:

5a) Moved
<script>if(window.mw){
mw.config.set({"UploadWizardConfig":{ [...]

directly before the loading call

<script>if(window.mw){
mw.loader.load(["mediawiki.htmlform","ext.uploadWizard"
AND IT WORKED!
5b) Moved the config into the head but below the other config so it looks like this:
<script>if(window.mw){
mw.config.set({"wgCanonicalNamespace":"Special" [...]
<script>if(window.mw){
mw.loader.implement("user.options" [...]
<script>if(window.mw){
mw.config.set({"UploadWizardConfig":
AND IT WORKED!

Conclusion: There are many points where you can insert the config, you just have to care that:
a) mw.config is there
b) it must be *before* telling RL to load ext.UploadWizard

Is this that difficult? Isn't there anyone who developed this OutPage.php monster?

(In reply to comment #11)

Please be more specific: What did not work?

My comment could be understood if you read the previous comments in that order.
Anyways, I tried to put the config variable above the load calls in a *hacky* way and couldn't make it work on Opera; that's what I meant.

(In reply to comment #12)

and couldn't make it work on Opera

Sorry for the misunderstanding. I would be still curious what the issue was exactly. Was the error message in Opera Dragonfly the same? Did you inspect the HTML DOM before and after it was altered by the JS engine?

Related URL: https://gerrit.wikimedia.org/r/67090 (Gerrit Change I14b231bfb73e8382c59f34331b822837c651a34e)

(In reply to comment #14)
The following change demonstrates possible solution

(In reply to comment #15)
Both provided "solutions" are a no-go.

Timeouts and listening for DOMready are not suitable checks for determining whether a script was executed. jQuery event listeners may be but since the UpWiz config is written directly into the output page, it must be possible to place it before the loader-call.

(In reply to comment #16)
Actually they aren't solutions, but more of a analysis of the problem.
Surely the config should be before the load call but I was able to see different results on Chrome and Opera confusing me what the fix would be.

On Opera I was seeing window.load getting called while on Chrome both were getting called.

Related URL: https://gerrit.wikimedia.org/r/68475 (Gerrit Change Ia09ace5dc985524634ee2c225207ee5050a046c2)

Fixed, deployed to commons, reopen if you see more problems.

Thanks all!

Gilles raised the priority of this task from High to Unbreak Now!.Dec 4 2014, 10:21 AM
Gilles moved this task from Untriaged to Done on the Multimedia board.
Gilles lowered the priority of this task from Unbreak Now! to High.Dec 4 2014, 11:20 AM