Rollback: Catch error when unable to load latest revision data
authorChad Horohoe <chadh@wikimedia.org>
Sat, 27 Aug 2016 00:01:53 +0000 (17:01 -0700)
committerChad Horohoe <chadh@wikimedia.org>
Sat, 27 Aug 2016 00:21:41 +0000 (17:21 -0700)
Ideally this never happens, but it can, so fail gracefully instead
of just throwing a 'call to a member function on non-object' message

Change-Id: Iac8be9c7994aa3e74ed3c0eecff211524037165e

includes/actions/RollbackAction.php
languages/i18n/en.json
languages/i18n/qqq.json

index 3e760fd..3dc611b 100644 (file)
@@ -57,6 +57,9 @@ class RollbackAction extends FormlessAction {
                if ( $from === null || $from === '' ) {
                        throw new ErrorPageError( 'rollbackfailed', 'rollback-missingparam' );
                }
+               if ( !$rev ) {
+                       throw new ErrorPageError( 'rollbackfailed', 'rollback-missingrevision' );
+               }
                if ( $from !== $rev->getUserText() ) {
                        throw new ErrorPageError( 'rollbackfailed', 'alreadyrolled', [
                                $this->getTitle()->getPrefixedText(),
index 892ac2c..dcd3981 100644 (file)
        "rollbacklinkcount-morethan": "rollback more than $1 {{PLURAL:$1|edit|edits}}",
        "rollbackfailed": "Rollback failed",
        "rollback-missingparam": "Missing required parameters on request.",
+       "rollback-missingrevision": "Unable to load revision data.",
        "cantrollback": "Cannot revert edit;\nlast contributor is only author of this page.",
        "alreadyrolled": "Cannot rollback last edit of [[:$1]] by [[User:$2|$2]] ([[User talk:$2|talk]]{{int:pipe-separator}}[[Special:Contributions/$2|{{int:contribslink}}]]);\nsomeone else has edited or rolled back the page already.\n\nThe last edit to the page was by [[User:$3|$3]] ([[User talk:$3|talk]]{{int:pipe-separator}}[[Special:Contributions/$3|{{int:contribslink}}]]).",
        "editcomment": "The edit summary was: <em>$1</em>.",
index 2c5041c..48f2013 100644 (file)
        "rollbacklinkcount-morethan": "{{doc-actionlink}}\nText of the rollback link when a greater number of edits is to be rolled back. See also {{msg-mw|rollbacklink}}.\n\nWhen the number of edits rolled back is smaller than [[mw:Special:MyLanguage/Manual:$wgShowRollbackEditCount|$wgShowRollbackEditCount]], {{msg-mw|rollbacklinkcount}} is used instead.\n\nParameters:\n* $1 - number of edits",
        "rollbackfailed": "{{Identical|Rollback}}",
        "rollback-missingparam": "Used as error message that rollback is accessed without the required parameters\n\nSee also:\n* {{msg-mw|Rollbackfailed}}",
+       "rollback-missingrevision": "Used as error message that rollback failed to load revision data\n\nSee also:\n* {{msg-mw|Rollbackfailed}}",
        "cantrollback": "Used as error message when rollback fails due to there not being a valid revision to revert back to.\n\nSee also:\n* {{msg-mw|Notvisiblerev}}\n{{Identical|Revert}}\n{{Identical|Rollback}}",
        "alreadyrolled": "Appear when there's rollback and/or edit collision.\n\nRefers to:\n* {{msg-mw|Pipe-separator}}\n* {{msg-mw|Contribslink}}\nParameters:\n* $1 - the page to be rolled back\n* $2 - the editor to be rolled-back of that page\n* $3 - the editor that cause collision\n{{Identical|Rollback}}",
        "editcomment": "Only shown if there is an edit {{msg-mw|Summary}}. Parameters:\n* $1 - the edit summary",