From: Kunal Mehta Date: Thu, 8 Sep 2016 03:52:19 +0000 (-0700) Subject: Don't throw exceptions in ContentHandler::getUndoContent() X-Git-Tag: 1.31.0-rc.0~5707^2 X-Git-Url: https://git.cyclocoop.org/%7B%7B%20url_for%28?a=commitdiff_plain;h=35e511086bc7304d3fb1330b20f2c16549fa093e;p=lhc%2Fweb%2Fwiklou.git 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 --- 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.