RollbackAction: Allow 'from' to be an empty string
authorTimo Tijhof <krinklemail@gmail.com>
Wed, 7 Sep 2016 20:52:42 +0000 (13:52 -0700)
committerAaron Schulz <aschulz@wikimedia.org>
Wed, 7 Sep 2016 21:09:22 +0000 (21:09 +0000)
Fix regression from 9af38c046c86, which made 'from' a required
non-empty parameter where previously an empty value was allowed.

The rollback links always include a 'from' parameter, but it is
set to an empty string by Revision::getUserText if the current
revision has its username hidden.

Test plan:
* Go to action=history, tick latest revision and "Change visibility".
* Tick "Editor's username" and apply the change.
* Hit "rollback" on the history page.
* Before: "missing parameter" error.
  After: Success.

Bug: T141985
Change-Id: I20d23e2aeec858f82231910c030c14ffa3af656f

includes/actions/RollbackAction.php
resources/src/mediawiki/page/rollback.js

index 3dc611b..aa2858d 100644 (file)
@@ -54,7 +54,7 @@ class RollbackAction extends FormlessAction {
                $user = $this->getUser();
                $from = $request->getVal( 'from' );
                $rev = $this->page->getRevision();
-               if ( $from === null || $from === '' ) {
+               if ( $from === null ) {
                        throw new ErrorPageError( 'rollbackfailed', 'rollback-missingparam' );
                }
                if ( !$rev ) {
index d973d07..1ff62ba 100644 (file)
@@ -15,7 +15,7 @@
                                page = mw.util.getParamValue( 'title', url ),
                                user = mw.util.getParamValue( 'from', url );
 
-                       if ( !page || !user ) {
+                       if ( !page || user === null ) {
                                // Let native browsing handle the link
                                return true;
                        }