Page MenuHomePhabricator

Cancel button returns Undefined error
Closed, ResolvedPublic


I recently installed MediaWiki for a group I'm affiliated with:

When I enabled the Publish/Cancel buttons, I discovered that the Cancel button returns an undefined error. The Publish button works as expected

See this discussion for details:

This is browser-displayed error. The error is not browser-dependent. (I've tested it in Safari, Chrome and Edge.)

Not Found
The requested URL /undefined was not found on this server.

This is my system software:

Installed software
Product Version
MediaWiki 1.29.1
PHP 7.1.9 (apache2handler)
MySQL 5.6.36
ICU 59.1

I have it disabled until I can resolve this.

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald TranscriptOct 3 2017, 6:44 PM
TheDJ added a subscriber: TheDJ.Oct 4 2017, 9:33 AM

As this is a configuration that is not in use by WMF, it is not well maintained. There's been some talk of removing it for that reason.

Has this been closed? Or is it still being worked on?

@Txantimedia: Neither nor. The task status is "Open" (see upper left corner) and anyone interested is welcome to propose a code change.

Where do I find the code? I'll take a look, but I'm not a programmer, so....

I found out that the code is in jquery.WikiEditor.publish.js.
This is the relevant section:

context.fn.addButton( {
                                       captionMsg: 'wikieditor-publish-button-cancel',
                                       action: function () {
                                               window.location.href = $( '#mw-editform-cancel' ).attr( 'href' );
                                               return false;
                               } );

window.location.href seems odd here. Why wouldn't you use window.history.back()? Cancelling should take you back to the previous page, just as hitting back in the browser.

I changed the code to this, and it worked as expected.

context.fn.addButton( {
        captionMsg: 'wikieditor-publish-button-cancel',
        action: function () {
/*              window.location.href = $( '#mw-editform-cancel' ).attr( 'href' ); */
                window.history.back() ;
                return false;
} );
TheDJ added a comment.Oct 6 2017, 9:14 AM

"Why wouldn't you use"

Because that's not supported in older versions of IE.

So what is supported? And what would happen in older versions of IE? Would it crater? Or just not work?

The internet might know... I'm afraid you have to dig a bit. :)

Frankly, I'd be inclined to tell the user to upgrade their browser. :)

It's working fine on my site, so I'm happy.

Aklapper triaged this task as Low priority.Nov 13 2017, 10:17 AM
Seb35 added a subscriber: Seb35.Nov 24 2017, 4:28 PM

I propose window.location.href = $( '#mw-editform-cancel a' ).attr( 'href' ); hence, as soon as jQuery works (it’s a pre-condition here), it will work.

jQuery 1.x (provided until MW 1.30) supports old browsers (IE 6-8) and jQuery 3 (provided by MW 1.31) supports only more recent browsers like IE9+.

With such a pure-jQuery solution, the associated support is linked to the MediaWiki version. Compared to the current situation where it works nowhere, any of the two proposed solution would be an improvement.

Change 393282 had a related patch set uploaded (by Seb35; owner: Seb35):
[mediawiki/extensions/WikiEditor@master] Cancel button returns Undefined error

Txantimedia added a comment.EditedNov 24 2017, 6:21 PM

I can confirm that this change works on my site using Mac OS High Sierra 10.13.1 and Safari 11.0.1 as well as Google Chrome 62.0.3202.94.

Change 393282 merged by jenkins-bot:
[mediawiki/extensions/WikiEditor@master] Cancel button returns Undefined error

Seb35 closed this task as Resolved.Dec 8 2017, 10:34 AM
Seb35 claimed this task.
happy5214 moved this task from Backlog to Closed on the WikiEditor board.Aug 4 2019, 11:34 AM