Sanitizer::normalizeSectionNameWhitespace: Apply same anti-null fix as 270499b

Follow-up to 270499b6e1f96f402c852843d446a7946589986b.

Bug: T388728
Bug: T385519
Change-Id: Idae7128c09bcf32a6c2d40e02158902c289898b9
(cherry picked from commit e130d34c15e418004a5ae42c0238206d70b2be0f)
This commit is contained in:
James D. Forrester 2025-03-16 18:51:32 -04:00 committed by Jforrester
parent fe57b122b5
commit 6b0ed71937

View file

@ -1139,7 +1139,7 @@ class Sanitizer {
$normalized = preg_replace( '/(?:\r\n|[\x20\x0d\x0a\x09])+/', ' ', $text );
if ( $normalized === null ) {
wfLogWarning( __METHOD__ . ': Failed to normalize whitespace: ' . preg_last_error() );
return "";
return '';
}
return trim( $normalized );
}
@ -1150,7 +1150,12 @@ class Sanitizer {
* section links.
*/
public static function normalizeSectionNameWhitespace( string $section ): string {
return trim( preg_replace( '/[ _]+/', ' ', $section ) );
$normalized = preg_replace( '/[ _]+/', ' ', $section );
if ( $normalized === null ) {
wfLogWarning( __METHOD__ . ': Failed to normalize whitespace: ' . preg_last_error() );
return '';
}
return trim( $normalized );
}
/**