From e95564bcdc8c9da8da79b14496e659a7efb73ba1 Mon Sep 17 00:00:00 2001 From: Fomafix Date: Thu, 8 Sep 2022 11:46:16 +0000 Subject: [PATCH] Check for invalid new titles This change avoids a null pointer exception. The unmovable old title gets added to the unmoveable_titles. Bug: T280148 Change-Id: I6d879d18f2ba29d55d0da3e37c0f5b8aa5d30ec2 --- src/SpecialReplaceText.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/SpecialReplaceText.php b/src/SpecialReplaceText.php index eb554098..b78ef6da 100644 --- a/src/SpecialReplaceText.php +++ b/src/SpecialReplaceText.php @@ -371,7 +371,7 @@ class SpecialReplaceText extends SpecialPage { $movePageFactory = MediaWikiServices::getInstance()->getMovePageFactory(); foreach ( $res as $row ) { $title = Title::makeTitleSafe( $row->page_namespace, $row->page_title ); - if ( $title == null ) { + if ( !$title ) { continue; } @@ -381,6 +381,11 @@ class SpecialReplaceText extends SpecialPage { $this->replacement, $this->use_regex ); + if ( !$new_title ) { + // New title is not valid because it contains invalid characters. + $unmoveable_titles[] = $title; + continue; + } $mvPage = $movePageFactory->newMovePage( $title, $new_title ); $moveStatus = $mvPage->isValidMove();