From bfd6406ff52f090dc2834cd099cd3cf903ca2eee Mon Sep 17 00:00:00 2001 From: =?utf8?q?Gerg=C5=91=20Tisza?= Date: Thu, 26 Jul 2018 20:39:21 +0200 Subject: [PATCH] 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 --- includes/Title.php | 4 ++++ 1 file changed, 4 insertions(+) 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(); -- 2.20.1