From 639a083d84a28e45c703ba79a127d93747233d98 Mon Sep 17 00:00:00 2001 From: Chad Horohoe Date: Fri, 26 Aug 2016 17:01:53 -0700 Subject: [PATCH] Rollback: Catch error when unable to load latest revision data 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 | 3 +++ languages/i18n/en.json | 1 + languages/i18n/qqq.json | 1 + 3 files changed, 5 insertions(+) diff --git a/includes/actions/RollbackAction.php b/includes/actions/RollbackAction.php index 3e760fd99b..3dc611b1ae 100644 --- a/includes/actions/RollbackAction.php +++ b/includes/actions/RollbackAction.php @@ -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(), diff --git a/languages/i18n/en.json b/languages/i18n/en.json index 892ac2c2c1..dcd398154e 100644 --- a/languages/i18n/en.json +++ b/languages/i18n/en.json @@ -2144,6 +2144,7 @@ "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: $1.", diff --git a/languages/i18n/qqq.json b/languages/i18n/qqq.json index 2c5041ca56..48f2013056 100644 --- a/languages/i18n/qqq.json +++ b/languages/i18n/qqq.json @@ -2327,6 +2327,7 @@ "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", -- 2.20.1