Last modified: 2014-02-04 11:01:31 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 T45910, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 43910 - AJAX button not working on MW 1.20+: "ReferenceError: wgDraft is not defined"
AJAX button not working on MW 1.20+: "ReferenceError: wgDraft is not defined"
Status: NEW
Product: MediaWiki extensions
Classification: Unclassified
Drafts (Other open bugs)
master
All All
: Normal normal (vote)
: ---
Assigned To: Nobody - You can work on this!
:
: 55395 (view as bug list)
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2013-01-12 19:48 UTC by Ilia Kats
Modified: 2014-02-04 11:01 UTC (History)
5 users (show)

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


Attachments

Description Ilia Kats 2013-01-12 19:48:34 UTC
Upon clicking the Save Draft button, the page is normally saved and I am redirected to the page view, where my changes have been incorporated. A draft is not saved, the error console says ReferenceError: wgDraft is not defined. The following changes need to be applied to make it work:

--- Drafts.hooks.php.bak        2013-01-12 20:28:03.000000000 +0100
+++ Drafts.hooks.php    2013-01-12 20:29:00.000000000 +0100
@@ -211,7 +211,7 @@
                        }
                        $ajaxButton = Xml::escapeJsString(
                                Xml::element( 'input',
-                                       array( 'type' => 'submit' ) + $buttonAttribs
+                                       array( 'type' => 'button' ) + $buttonAttribs
                                        + ( $wgRequest->getText( 'action' ) !== 'submit' ?
                                                array ( 'disabled' => 'disabled' )
                                                : array()

--- modules/ext.Drafts.js.bak   2013-01-12 20:08:37.000000000 +0100
+++ modules/ext.Drafts.js       2013-01-12 20:27:45.000000000 +0100
@@ -194,5 +194,5 @@
        }
 }
 
-var wgDraft = new Draft();
+window["wgDraft"] = new Draft();
 wgDraft.initialize();
Comment 1 Andre Klapper 2013-01-14 10:49:13 UTC
Hi! Thanks for your patch!

You are welcome to use Developer access
  https://www.mediawiki.org/wiki/Developer_access
to submit this as a Git branch directly into Gerrit:
  https://www.mediawiki.org/wiki/Git/Tutorial

Putting your branch in Git makes it easier for us to review it quickly.
Thanks again! We appreciate your contribution.
Comment 2 Andre Klapper 2013-04-08 10:51:40 UTC
Hi Ilia! Thanks for your patch!
You are welcome to use Developer access
  https://www.mediawiki.org/wiki/Developer_access
to submit this as a Git branch directly into Gerrit:
  https://www.mediawiki.org/wiki/Git/Tutorial
Putting your branch in Git makes it easier for us to review it quickly.
Thanks again! We appreciate your contribution.
Comment 3 gavin 2013-06-18 14:54:30 UTC
I used other way to solve this bug.
I modify modules/ext.Drafts.js.
You have to modify 2 position.
line:121
line:135

BEFORE: 

// Sets timer to save automatically after a period of time
timer = setTimeout(
  'wgDraft.save()', configuration.autoSaveWait * 1000
);

AFTER:

// Sets timer to save automatically after a period of time
timer = setTimeout(
  function () {self.save()}, configuration.autoSaveWait * 1000
);

I use v1.21 .
In IE9 & chrome & firefox,it can work.
Comment 4 Kunal Mehta (Legoktm) 2013-10-07 16:06:53 UTC
*** Bug 55395 has been marked as a duplicate of this bug. ***
Comment 5 Kunal Mehta (Legoktm) 2013-10-07 16:08:31 UTC
Confirming that this bug exists in current master (1.22), and I was able to reproduce it on 1.21 too.
Comment 6 Kunal Mehta (Legoktm) 2013-10-07 16:19:34 UTC
I can easily reproduce this bug, but when I use &debug=true it works just fine.

Also, Chromium and Firefox both handle this error differently. Firefox will submit the form and save the page (bug 55395), but Chromium just sits there.
Comment 7 Gerrit Notification Bot 2013-10-07 18:13:49 UTC
Change 88151 had a related patch set uploaded by Legoktm:
ReferenceError: wgDraft is not defined

https://gerrit.wikimedia.org/r/88151
Comment 8 Kunal Mehta (Legoktm) 2013-10-07 18:17:46 UTC
(In reply to comment #0)

> --- Drafts.hooks.php.bak        2013-01-12 20:28:03.000000000 +0100
> +++ Drafts.hooks.php    2013-01-12 20:29:00.000000000 +0100

<snip>

So this part was already committed for the most part.

> --- modules/ext.Drafts.js.bak   2013-01-12 20:08:37.000000000 +0100
> +++ modules/ext.Drafts.js       2013-01-12 20:27:45.000000000 +0100
> @@ -194,5 +194,5 @@
>         }
>  }
> 
> -var wgDraft = new Draft();
> +window["wgDraft"] = new Draft();
>  wgDraft.initialize();

I put this part in gerrit.
Comment 9 Gerrit Notification Bot 2013-11-20 02:13:44 UTC
Change 88151 abandoned by Legoktm:
ReferenceError: wgDraft is not defined

https://gerrit.wikimedia.org/r/88151
Comment 10 Kunal Mehta (Legoktm) 2013-11-20 02:15:14 UTC
(In reply to comment #9)
> Change 88151 abandoned by Legoktm:

As Yuvi pointed out, this is an ugly hack, and should be fixed in some other way.

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


Navigation
Links