diff options
author | jenkins-bot <jenkins-bot@gerrit.wikimedia.org> | 2024-01-21 01:22:26 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@wikimedia.org> | 2024-01-21 01:22:26 +0000 |
commit | 25f83a9ce6b91edec3d1913ec7dbb984c9b2d130 (patch) | |
tree | 0dc4185cc2b1e2564d2419894ac1fab5d5648306 /includes/content | |
parent | 50c367153718c3aa52c7e2e626f1561761b99c60 (diff) | |
parent | 0ea7599e3ef16d148f22bda633162835602c3f7c (diff) | |
download | mediawikicore-25f83a9ce6b91edec3d1913ec7dbb984c9b2d130.tar.gz mediawikicore-25f83a9ce6b91edec3d1913ec7dbb984c9b2d130.zip |
Merge "Replace unspecific exceptions with InvalidArgumentException"
Diffstat (limited to 'includes/content')
-rw-r--r-- | includes/content/ContentHandler.php | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/includes/content/ContentHandler.php b/includes/content/ContentHandler.php index 7b0ece335f00..0835899136eb 100644 --- a/includes/content/ContentHandler.php +++ b/includes/content/ContentHandler.php @@ -157,17 +157,13 @@ abstract class ContentHandler { */ public static function makeContent( $text, Title $title = null, $modelId = null, $format = null ) { - if ( $modelId === null ) { - if ( $title === null ) { - throw new BadMethodCallException( "Must provide a Title object or a content model ID." ); - } - - $modelId = $title->getContentModel(); + if ( !$title && !$modelId ) { + throw new InvalidArgumentException( "Must provide a Title object or a content model ID." ); } return MediaWikiServices::getInstance() ->getContentHandlerFactory() - ->getContentHandler( $modelId ) + ->getContentHandler( $modelId ?? $title->getContentModel() ) ->unserializeContent( $text, $format ); } |