aboutsummaryrefslogtreecommitdiffstats
path: root/includes/parser
diff options
context:
space:
mode:
authorJames D. Forrester <jforrester@wikimedia.org>2025-03-16 19:11:19 -0400
committerJforrester <jforrester@wikimedia.org>2025-03-17 12:34:40 +0000
commit2e4e9428580d4829911313644913c3c74cf43244 (patch)
tree5e1643eb8b8e67a6b20922c25bb34ab862bc9337 /includes/parser
parenta0b926c81ff8b6737a42aec4dbf9eda15c9a5084 (diff)
downloadmediawikicore-2e4e9428580d4829911313644913c3c74cf43244.tar.gz
mediawikicore-2e4e9428580d4829911313644913c3c74cf43244.zip
MagicWord::replace*: Make sure we don't pass null into preg_match/preg_replace
Bug: T388924 Change-Id: I02a3e724dc614f0a2306548f58f71d16a8a1dc5b
Diffstat (limited to 'includes/parser')
-rw-r--r--includes/parser/MagicWord.php10
1 files changed, 5 insertions, 5 deletions
diff --git a/includes/parser/MagicWord.php b/includes/parser/MagicWord.php
index 3347740afe71..94677e1a9912 100644
--- a/includes/parser/MagicWord.php
+++ b/includes/parser/MagicWord.php
@@ -178,7 +178,7 @@ class MagicWord {
* @return bool
*/
public function match( $text ): bool {
- return (bool)preg_match( $this->getRegex(), $text );
+ return (bool)preg_match( $this->getRegex(), $text ?? '' );
}
/**
@@ -189,7 +189,7 @@ class MagicWord {
* @since 1.23
*/
public function matchStartToEnd( $text ): bool {
- return (bool)preg_match( $this->getRegexStartToEnd(), $text );
+ return (bool)preg_match( $this->getRegexStartToEnd(), $text ?? '' );
}
/**
@@ -203,7 +203,7 @@ class MagicWord {
* @return bool
*/
public function matchAndRemove( &$text ): bool {
- $text = preg_replace( $this->getRegex(), '', $text, -1, $count );
+ $text = preg_replace( $this->getRegex(), '', $text ?? '', -1, $count );
return (bool)$count;
}
@@ -212,7 +212,7 @@ class MagicWord {
* @return bool
*/
public function matchStartAndRemove( &$text ): bool {
- $text = preg_replace( $this->getRegexStart(), '', $text, -1, $count );
+ $text = preg_replace( $this->getRegexStart(), '', $text ?? '', -1, $count );
return (bool)$count;
}
@@ -229,7 +229,7 @@ class MagicWord {
$res = preg_replace(
$this->getRegex(),
StringUtils::escapeRegexReplacement( $replacement ),
- $subject,
+ $subject ?? '',
$limit
);
return $res;