From: Gergő Tisza Date: Thu, 26 Jul 2018 18:39:21 +0000 (+0200) Subject: Handle $title === null in Title::newFromText X-Git-Tag: 1.34.0-rc.0~4649^2 X-Git-Url: http://git.cyclocoop.org/%22%2C%20generer_url_ecrire%28?a=commitdiff_plain;h=bfd6406ff52f090dc2834cd099cd3cf903ca2eee;p=lhc%2Fweb%2Fwiklou.git Handle $title === null in Title::newFromText This relied on TitleCodec throwing MalformedTitleException in the past, but that is fragile as other parts of the logic do not expect null. Bug: T200456 Change-Id: I1aca3971e2a9c0b1fe3adbcf34f3ee65b2271234 --- diff --git a/includes/Title.php b/includes/Title.php index b583554ab4..f6bc9475d0 100644 --- a/includes/Title.php +++ b/includes/Title.php @@ -306,6 +306,10 @@ class Title implements LinkTarget { public static function newFromTextThrow( $text, $defaultNamespace = NS_MAIN ) { if ( is_object( $text ) ) { throw new MWException( '$text must be a string, given an object' ); + } elseif ( $text === null ) { + // Legacy code relies on MalformedTitleException being thrown in this case + // (happens when URL with no title in it is parsed). TODO fix + throw new MalformedTitleException( 'title-invalid-empty' ); } $titleCache = self::getTitleCache();