error under PHP 8

Dear Sir or Madam,

I have purchased Feed Creator 2.2.1 in Dec '21 and am very happy with the software.

Recently my hosting provider wrote that support for PHP 7.4 would be discontinued. I would have to update to PHP 8.0 or PHP 8.1 until 28.11.2022.

I have tried updating to PHP 8.1, but I get the following error with Feed Creator 2.2.1:

stderr: "[20-Nov-2022 15:29:10 Europe/Berlin] PHP Deprecated:  Return type of RollingCurl::count() should either be compatible with Countable::count(): int, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/virtual/redacted/html/lib/humble-http-agent/RollingCurl.php on line 168"
stderr: "[20-Nov-2022 15:29:10 Europe/Berlin] PHP Deprecated:  DOMImplementation::createDocument(): Passing null to parameter #2 ($qualifiedName) of type string is deprecated in /var/www/virtual/redacted/html/lib/html5php/HTML5/Parser/DOMTreeBuilder.php on line 178"
stderr: "[20-Nov-2022 15:29:10 Europe/Berlin] PHP Deprecated:  DOMElement::setAttribute(): Passing null to parameter #2 ($value) of type string is deprecated in /var/www/virtual/redacted/html/lib/html5php/HTML5/Parser/DOMTreeBuilder.php on line 417"
stderr: "[20-Nov-2022 15:29:10 Europe/Berlin] PHP Deprecated:  DOMElement::setAttribute(): Passing null to parameter #2 ($value) of type string is deprecated in /var/www/virtual/redacted/html/lib/html5php/HTML5/Parser/DOMTreeBuilder.php on line 417"
stderr: "[20-Nov-2022 15:29:10 Europe/Berlin] PHP Deprecated:  DOMElement::setAttribute(): Passing null to parameter #2 ($value) of type string is deprecated in /var/www/virtual/redacted/html/lib/html5php/HTML5/Parser/DOMTreeBuilder.php on line 417"
stderr: "[20-Nov-2022 15:29:10 Europe/Berlin] PHP Deprecated:  DOMElement::setAttribute(): Passing null to parameter #2 ($value) of type string is deprecated in /var/www/virtual/redacted/html/lib/html5php/HTML5/Parser/DOMTreeBuilder.php on line 417"
stderr: "[20-Nov-2022 15:29:10 Europe/Berlin] PHP Deprecated:  strtolower(): Passing null to parameter #1 ($string) of type string is deprecated in /var/www/virtual/redacted/html/lib/vendor/symfony/css-selector/XPath/Extension/NodeExtension.php on line 161"
stderr: "[20-Nov-2022 15:29:10 Europe/Berlin] PHP Deprecated:  strtolower(): Passing null to parameter #1 ($string) of type string is deprecated in /var/www/virtual/redacted/html/lib/vendor/symfony/css-selector/XPath/Extension/NodeExtension.php on line 161"
stderr: "[20-Nov-2022 15:29:10 Europe/Berlin] PHP Deprecated:  strtolower(): Passing null to parameter #1 ($string) of type string is deprecated in /var/www/virtual/redacted/html/lib/vendor/symfony/css-selector/XPath/Extension/NodeExtension.php on line 161"
stderr: "[20-Nov-2022 15:29:10 Europe/Berlin] PHP Fatal error:  Uncaught TypeError: htmlspecialchars(): Argument #2 ($flags) must be of type int, string given in /var/www/virtual/redacted/html/extract.php:1336"
stderr: "Stack trace:"
stderr: "#0 /var/www/virtual/redacted/html/extract.php(1336): htmlspecialchars('<p>redacted...', '8</p>')"
stderr: "#1 /var/www/virtual/redacted/html/extract.php(922): output_rss('redacted...', 'https://redacted...', Array, Array, Array, Array, Array)"
stderr: "#2 {main}"
stderr: "  thrown in /var/www/virtual/redacted/html/extract.php on line 1336"

I assume the problem is htmlspecialchars(): Argument #2 ($flags) must be of type int, string given.

Could you please provide help?

Best regards,

I had to change line 1336 of extract.php to:

echo htmlspecialchars('<p>'.reduce_length($descriptions[$key], $options->max_desc_length).'</p>', ENT_SUBSTITUTE);

Hi there, thanks for letting us know.

The last release of Feed Creator was tested on PHP 8.0 and should be compatible with that version.

We’ll have a new release that’s compatible with PHP 8.1 before the end of the year.

In addition to your fix, if the only other warnings you get are deprecation notices for PHP 8.1, you can disable those notices by doing the following:

  1. Open extract.php in a text editor
  2. Find the line error_reporting(E_ALL ^ E_NOTICE);
  3. Change it to error_reporting(E_ALL & ~E_DEPRECATED & ~E_NOTICE);
  4. Save and upload the file to your server

Now deprecation notices should not appear. Let us know if you still have trouble.