From 35e511086bc7304d3fb1330b20f2c16549fa093e Mon Sep 17 00:00:00 2001 From: Kunal Mehta Date: Wed, 7 Sep 2016 20:52:19 -0700 Subject: [PATCH] Don't throw exceptions in ContentHandler::getUndoContent() The method is not documented to throw any exceptions, and already returns false on failure, and it can be seen as a failure case when the content models are not the same. Bug: T145044 Change-Id: I0394d19cd65f9dd3ee350d2cde95afb11ab9e7f4 --- includes/content/ContentHandler.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/includes/content/ContentHandler.php b/includes/content/ContentHandler.php index 22db08a45e..9ea4f40901 100644 --- a/includes/content/ContentHandler.php +++ b/includes/content/ContentHandler.php @@ -1018,9 +1018,15 @@ abstract class ContentHandler { return false; // no content to undo } - $this->checkModelID( $cur_content->getModel() ); - $this->checkModelID( $undo_content->getModel() ); - $this->checkModelID( $undoafter_content->getModel() ); + try { + $this->checkModelID( $cur_content->getModel() ); + $this->checkModelID( $undo_content->getModel() ); + $this->checkModelID( $undoafter_content->getModel() ); + } catch ( MWException $e ) { + // If the revisions have different content models + // just return false + return false; + } if ( $cur_content->equals( $undo_content ) ) { // No use doing a merge if it's just a straight revert. -- 2.20.1