Fixing PHP deprcation Issue in OJS 3.4.0.8

Dear Team,
I use OJS 3.4.0.8 with PHP 8.1.
I asked ChatGPT to help me to reduce PHP warnings as bellow:

PHP Deprecated:  stripslashes(): Passing null to parameter #1 ($string) of type string is deprecated in /home   ....../lib/pkp/classes/citation/Citation.php on line 118
[05-Apr-2025 06:09:27 Asia/Baghdad] PHP Deprecated:  stripslashes(): Passing null to parameter #1 ($string) of type string is deprecated in /home   ....../lib/pkp/classes/citation/Citation.php on line 118
PHP Deprecated:  stripslashes(): Passing null to parameter #1 ($string) of type string is deprecated in /home   ....../lib/pkp/classes/citation/Citation.php on line 118
[05-Apr-2025 06:09:27 Asia/Baghdad] PHP Deprecated:  stripslashes(): Passing null to parameter #1 ($string) of type string is deprecated in /home   ....../lib/pkp/classes/citation/Citation.php on line 118
PHP Deprecated:  stripslashes(): Passing null to parameter #1 ($string) of type string is deprecated in /home   ....../lib/pkp/classes/citation/Citation.php on line 118
 PHP Deprecated:  stripslashes(): Passing null to parameter #1 ($string) of type string is deprecated in /home   ....../lib/pkp/classes/citation/Citation.php on line 118
PHP Deprecated:  stripslashes(): Passing null to parameter #1 ($string) of type string is deprecated in /home   ....../lib/pkp/classes/citation/Citation.php on line 118
PHP Deprecated:  stripslashes(): Passing null to parameter #1 ($string) of type string is deprecated in /home   ....../lib/pkp/classes/citation/Citation.php on line 118
PHP Deprecated:  stripslashes(): Passing null to parameter #1 ($string) of type string is deprecated in /home   ....../lib/pkp/classes/citation/Citation.php on line 118
PHP Deprecated:  stripslashes(): Passing null to parameter #1 ($string) of type string is deprecated in /home   ....../lib/pkp/classes/citation/Citation.php on line 118
PHP Deprecated:  stripslashes(): Passing null to parameter #1 ($string) of type string is deprecated in /home   ....../lib/pkp/classes/citation/Citation.php on line 118
PHP Deprecated:  stripslashes(): Passing null to parameter #1 ($string) of type string is deprecated in /home   ....../lib/pkp/classes/citation/Citation.php on line 118

And the suggested was the following and it worked fine. my question is: Can I use it in my current installation since ChatGPT can give wrong solutions sometimes.

Suggested fix by ChatGPT:

To avoid the warning, we should ensure $citationString is a string before passing it to stripslashes(). Here’s a safe way to fix it:

$citationString = trim(stripslashes((string) $citationString));

But if you want to preserve null (i.e., not convert it to an empty string), a safer and more compatible fix would be:

if (!is_null($citationString)) {
    $citationString = trim(stripslashes($citationString));
}

Updated _cleanCitationString function:

Here’s the updated version of the method:

public function _cleanCitationString($citationString)
{
    // 1) Strip slashes and whitespace if not null
    if (!is_null($citationString)) {
        $citationString = trim(stripslashes($citationString));

        // 2) Normalize whitespace
        $citationString = PKPString::regexp_replace('/[\s]+/', ' ', $citationString);
    }

    return $citationString;
}

Many Thanks
-Salam