From ed423ca16dd8528da281d3fd9789a46950eb81e1 Mon Sep 17 00:00:00 2001 From: swentel Date: Thu, 13 Oct 2022 16:17:14 +0200 Subject: [PATCH] Fix preg_replace deprecations --- lib/XRay/Formats/Mf2.php | 6 +++--- lib/XRay/PostType.php | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/XRay/Formats/Mf2.php b/lib/XRay/Formats/Mf2.php index f103f26..542efa6 100644 --- a/lib/XRay/Formats/Mf2.php +++ b/lib/XRay/Formats/Mf2.php @@ -408,11 +408,11 @@ class Mf2 extends Format { $checkedname = $name; if($content) { // Trim ellipses from the name - $name = preg_replace('/ ?(\.\.\.|…)$/', '', $name); + $name = preg_replace('/ ?(\.\.\.|…)$/', '', $name ?: ''); // Remove all whitespace when checking equality - $nameCompare = preg_replace('/\s/','',trim($name)); - $contentCompare = preg_replace('/\s/','',trim($textContent)); + $nameCompare = preg_replace('/\s/','',trim($name) ?: ''); + $contentCompare = preg_replace('/\s/','',trim($textContent) ?: ''); // Check if the name is a prefix of the content if($contentCompare && $nameCompare && strpos($contentCompare, $nameCompare) === 0) { diff --git a/lib/XRay/PostType.php b/lib/XRay/PostType.php index 3c9dc72..180c2c0 100644 --- a/lib/XRay/PostType.php +++ b/lib/XRay/PostType.php @@ -54,8 +54,8 @@ class PostType { $name = trim($post['name']); // Collapse all sequences of internal whitespace to a single space (0x20) character each - $name = preg_replace('/\s+/', ' ', $name); - $content = preg_replace('/\s+/', ' ', $content); + $name = preg_replace('/\s+/', ' ', $name ?: ''); + $content = preg_replace('/\s+/', ' ', $content ?: ''); // If this processed "name" property value is NOT a prefix of the // processed "content" property, then it is an article post.