FeedWriter icon indicating copy to clipboard operation
FeedWriter copied to clipboard

Cast $string to string if not string(ex:null) in filterInvalidXMLChars().

Open uzulla opened this issue 4 years ago • 0 comments

Hi.

I got a ignore-able tiny error with PHP>=8.1

  • PHP>=8.1 trigger deprecation error in some old code.
  • Deprecated: preg_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in /work/Feed.php on line 687

ex code

// Add some line to sample code.

$nullable_value = null;
$TestFeed->setChannelElement('description', $nullable_value);

// ... SNIP ... 

$TestFeed->generateFeed(); // error.

error output.

Deprecated: preg_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in /work/Feed.php on line 687
Deprecated: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in /work/Feed.php on line 1015
Deprecated: preg_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in /work/Feed.php on line 687
Deprecated: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in /work/Feed.php on line 1015
Deprecated: preg_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in /work/Feed.php on line 687
Deprecated: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in /work/Feed.php on line 1015
Deprecated: preg_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in /work/Feed.php on line 687
Deprecated: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in /work/Feed.php on line 1015

Of course, $TestFeed->setChannelElement('something', NULL) is absolutly wrong. but many php are still using NULL as blank strings. It save some codes if cast NULL to string here.

thanks.

uzulla avatar Jan 01 '22 03:01 uzulla